{"version":3,"file":"productsStore.mjs","names":["create","devtools","apiMutate","ProductView","ConfigService","ProductsState","products","fetchedTenantId","fetchProducts","tenantId","Promise","useProductsStore","set","get","response","tenantV1ApiUrl","method","data"],"sources":["../../src/stores/productsStore.ts"],"sourcesContent":["import { create } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { apiMutate } from '../utilities/useAxiosMutate';\nimport { ProductView } from '../utilities/types';\nimport { ConfigService } from '../configService';\n\ninterface ProductsState {\n  products: ProductView[];\n  fetchedTenantId: string | null;\n  fetchProducts: (tenantId: string) => Promise<void>;\n}\n\nexport const useProductsStore = create<ProductsState>()(\n  devtools((set, get) => ({\n    products: [],\n    fetchedTenantId: null,\n    fetchProducts: async (tenantId) => {\n      if (get().fetchedTenantId === tenantId) return;\n      set({ fetchedTenantId: tenantId });\n      const response = await apiMutate(\n        ConfigService.tenantV1ApiUrl,\n        `tenants/products?tenantId=${tenantId}`,\n        { method: 'GET' },\n        {}\n      );\n      set({ products: response.data as ProductView[] });\n    },\n  }))\n);\n"],"mappings":";;;;;AAYA,MAAaW,mBAAmBX,QAAuB,CACrDC,UAAUW,KAAKC,SAAS;CACtBP,UAAU,EAAE;CACZC,iBAAiB;CACjBC,eAAe,OAAOC,aAAa;AACjC,MAAII,KAAK,CAACN,oBAAoBE,SAAU;AACxCG,MAAI,EAAEL,iBAAiBE,UAAU,CAAC;AAOlCG,MAAI,EAAEN,WANW,MAAMJ,UACrBE,cAAcW,gBACd,6BAA6BN,YAC7B,EAAEO,QAAQ,OAAO,EACjB,EACF,CAAC,EACwBC,MAAuB,CAAC;;CAEpD,EACH,CAAC"}