interface ServiceItem {
    id: number;
    name: any;
    description: any;
}
export const useServiceStore = defineStore("service", {
    state: () => ({
        companyId: null as number | null,
        activeLicenseType: null as number | null,
        activeServiceId: null as number | null,
    }),

    actions: {
        resetForCompany(companyId: number) {
            if (this.companyId === companyId) return

            this.companyId = companyId;
            this.activeLicenseType = null;
            this.activeServiceId = null;
        },

        selectLicense(licenseId: number, services: any[]) {
          this.activeLicenseType = licenseId
          this.activeServiceId = services.length ? services[0].id : null
        },
        // selectLicense(licenseId: number) {
        //     const isSame = this.activeLicenseType === licenseId;
        //     this.activeLicenseType = licenseId;
        //     if (!isSame) {
        //         this.activeServiceId = null;
        //     }
        // },

        selectService(serviceId: number) {
            this.activeServiceId = serviceId;
        },
    },
});
