@fctc/interface-logic 5.0.3 → 5.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/provider.mjs CHANGED
@@ -694,6 +694,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
694
694
  UriConstants2["TOKEN_BY_CODE"] = "/token";
695
695
  UriConstants2["LOGOUT"] = "/logout";
696
696
  UriConstants2["SUPABASE_LOGIN_PATH"] = "/api/v2/auth/login";
697
+ UriConstants2["SUPABASE_CURRENT_USER"] = "/api/v2/auth/me";
697
698
  UriConstants2["CREATE_UPDATE"] = "/create_update";
698
699
  UriConstants2["SEARCH_READ"] = "/search_read";
699
700
  UriConstants2["CREATE_PATH"] = "/create";
@@ -7379,6 +7380,144 @@ var getPartnerTitlesSupabaseService = () => {
7379
7380
  };
7380
7381
  };
7381
7382
 
7383
+ // src/services/pos-service/supabase/get-supa-current-user.ts
7384
+ import { useCallback as useCallback70 } from "react";
7385
+ var getSupaCurrentUser = (env) => {
7386
+ const getSupaCurrentUser2 = useCallback70(
7387
+ ({ tenantId }) => {
7388
+ return env?.requests.get("/api/v2/auth/me" /* SUPABASE_CURRENT_USER */, {
7389
+ headers: {
7390
+ "Content-Type": "application/json",
7391
+ "x-tenant-id": tenantId
7392
+ }
7393
+ });
7394
+ },
7395
+ [env]
7396
+ );
7397
+ return {
7398
+ getSupaCurrentUser: getSupaCurrentUser2
7399
+ };
7400
+ };
7401
+
7402
+ // src/services/pos-service/supabase/update-category.ts
7403
+ import { useCallback as useCallback71 } from "react";
7404
+ var updateCategorySupabaseService = () => {
7405
+ const supabase = useSupabaseOptional();
7406
+ const updateCategorySupabase = useCallback71(
7407
+ async (values) => {
7408
+ if (!supabase) {
7409
+ console.error("Supabase client not initialized");
7410
+ return null;
7411
+ }
7412
+ try {
7413
+ const { category_id, ...rest } = values;
7414
+ const { data, error } = await supabase.from("pos_categories" /* POS_CATEGORIES */).update(rest).eq("id", category_id).select("id").single();
7415
+ if (error) {
7416
+ console.error("Error updating category:", error);
7417
+ return null;
7418
+ }
7419
+ return [data.id];
7420
+ } catch (error) {
7421
+ console.error("Error updating category:", error);
7422
+ return null;
7423
+ }
7424
+ },
7425
+ [supabase]
7426
+ );
7427
+ return {
7428
+ updateCategorySupabase
7429
+ };
7430
+ };
7431
+
7432
+ // src/services/pos-service/supabase/delete-category.ts
7433
+ import { useCallback as useCallback72 } from "react";
7434
+ var deleteCategorySupabaseService = () => {
7435
+ const supabase = useSupabaseOptional();
7436
+ const deleteCategorySupabase = useCallback72(
7437
+ async (values) => {
7438
+ if (!supabase) {
7439
+ console.error("Supabase client not initialized");
7440
+ return null;
7441
+ }
7442
+ try {
7443
+ const { error } = await supabase.from("pos_categories" /* POS_CATEGORIES */).delete().eq("id", values.category_id);
7444
+ if (error) {
7445
+ console.error("Error deleting category:", error);
7446
+ return null;
7447
+ }
7448
+ return [values.category_id];
7449
+ } catch (error) {
7450
+ console.error("Error deleting category:", error);
7451
+ return null;
7452
+ }
7453
+ },
7454
+ [supabase]
7455
+ );
7456
+ return {
7457
+ deleteCategorySupabase
7458
+ };
7459
+ };
7460
+
7461
+ // src/services/pos-service/supabase/update-product.ts
7462
+ import { useCallback as useCallback73 } from "react";
7463
+ var updateProductSupabaseService = () => {
7464
+ const supabase = useSupabaseOptional();
7465
+ const updateProductSupabase = useCallback73(
7466
+ async (values) => {
7467
+ if (!supabase) {
7468
+ console.error("Supabase client not initialized");
7469
+ return null;
7470
+ }
7471
+ try {
7472
+ const { product_id, ...rest } = values;
7473
+ const updateData = cleanObject(rest);
7474
+ const { data, error } = await supabase.from("products" /* PRODUCTS */).update(updateData).eq("id", product_id).select("id").single();
7475
+ if (error) {
7476
+ console.error("Error updating product:", error);
7477
+ return null;
7478
+ }
7479
+ return [data.id];
7480
+ } catch (error) {
7481
+ console.error("Error updating product:", error);
7482
+ return null;
7483
+ }
7484
+ },
7485
+ [supabase]
7486
+ );
7487
+ return {
7488
+ updateProductSupabase
7489
+ };
7490
+ };
7491
+
7492
+ // src/services/pos-service/supabase/delete-product.ts
7493
+ import { useCallback as useCallback74 } from "react";
7494
+ var deleteProductSupabaseService = () => {
7495
+ const supabase = useSupabaseOptional();
7496
+ const deleteProductSupabase = useCallback74(
7497
+ async (values) => {
7498
+ if (!supabase) {
7499
+ console.error("Supabase client not initialized");
7500
+ return null;
7501
+ }
7502
+ try {
7503
+ const { error } = await supabase.from("products" /* PRODUCTS */).delete().eq("id", values.product_id);
7504
+ if (error) {
7505
+ console.error("Error deleting product:", error);
7506
+ return null;
7507
+ }
7508
+ return [values.product_id];
7509
+ } catch (error) {
7510
+ console.error("Error deleting product:", error);
7511
+ return null;
7512
+ }
7513
+ },
7514
+ [supabase]
7515
+ );
7516
+ return {
7517
+ deleteProductSupabase
7518
+ };
7519
+ };
7520
+
7382
7521
  // src/services/pos-service/index.ts
7383
7522
  var serviceFactories = [
7384
7523
  addEntityService,
@@ -7439,7 +7578,12 @@ var serviceFactories = [
7439
7578
  assignRoleService,
7440
7579
  getStatesSupabaseService,
7441
7580
  getWardsSupabaseService,
7442
- getPartnerTitlesSupabaseService
7581
+ getPartnerTitlesSupabaseService,
7582
+ getSupaCurrentUser,
7583
+ updateCategorySupabaseService,
7584
+ deleteCategorySupabaseService,
7585
+ updateProductSupabaseService,
7586
+ deleteProductSupabaseService
7443
7587
  ];
7444
7588
  var usePosService = () => {
7445
7589
  const { env } = useEnv();
@@ -7488,7 +7632,7 @@ var VersionGate = ({ children }) => {
7488
7632
  };
7489
7633
 
7490
7634
  // src/provider/env-provider.tsx
7491
- import { createContext as createContext2, useContext as useContext2, useState as useState4, useCallback as useCallback70 } from "react";
7635
+ import { createContext as createContext2, useContext as useContext2, useState as useState4, useCallback as useCallback75 } from "react";
7492
7636
 
7493
7637
  // src/configs/axios-client.ts
7494
7638
  import axios from "axios";
@@ -7853,7 +7997,7 @@ function EnvProvider({
7853
7997
  localStorageUtils: localStorageUtil,
7854
7998
  sessionStorageUtils: sessionStorageUtil
7855
7999
  });
7856
- const setupEnv = useCallback70(
8000
+ const setupEnv = useCallback75(
7857
8001
  (envConfig) => {
7858
8002
  const updatedEnv = {
7859
8003
  ...env,
@@ -7867,31 +8011,31 @@ function EnvProvider({
7867
8011
  },
7868
8012
  [env, localStorageUtil, sessionStorageUtil]
7869
8013
  );
7870
- const setUid2 = useCallback70((uid) => {
8014
+ const setUid2 = useCallback75((uid) => {
7871
8015
  setEnvState((prev) => ({
7872
8016
  ...prev,
7873
8017
  context: { ...prev.context, uid }
7874
8018
  }));
7875
8019
  }, []);
7876
- const setLang2 = useCallback70((lang) => {
8020
+ const setLang2 = useCallback75((lang) => {
7877
8021
  setEnvState((prev) => ({
7878
8022
  ...prev,
7879
8023
  context: { ...prev.context, lang }
7880
8024
  }));
7881
8025
  }, []);
7882
- const setAllowCompanies2 = useCallback70((allowed_company_ids) => {
8026
+ const setAllowCompanies2 = useCallback75((allowed_company_ids) => {
7883
8027
  setEnvState((prev) => ({
7884
8028
  ...prev,
7885
8029
  context: { ...prev.context, allowed_company_ids }
7886
8030
  }));
7887
8031
  }, []);
7888
- const setCompanies2 = useCallback70((companies) => {
8032
+ const setCompanies2 = useCallback75((companies) => {
7889
8033
  setEnvState((prev) => ({
7890
8034
  ...prev,
7891
8035
  companies
7892
8036
  }));
7893
8037
  }, []);
7894
- const setDefaultCompany2 = useCallback70(
8038
+ const setDefaultCompany2 = useCallback75(
7895
8039
  (defaultCompany) => {
7896
8040
  setEnvState((prev) => ({
7897
8041
  ...prev,
@@ -7900,19 +8044,19 @@ function EnvProvider({
7900
8044
  },
7901
8045
  []
7902
8046
  );
7903
- const setUserInfo = useCallback70((user) => {
8047
+ const setUserInfo = useCallback75((user) => {
7904
8048
  setEnvState((prev) => ({
7905
8049
  ...prev,
7906
8050
  user
7907
8051
  }));
7908
8052
  }, []);
7909
- const setConfig2 = useCallback70((config) => {
8053
+ const setConfig2 = useCallback75((config) => {
7910
8054
  setEnvState((prev) => ({
7911
8055
  ...prev,
7912
8056
  config
7913
8057
  }));
7914
8058
  }, []);
7915
- const setEnvFile2 = useCallback70((envFile) => {
8059
+ const setEnvFile2 = useCallback75((envFile) => {
7916
8060
  setEnvState((prev) => ({
7917
8061
  ...prev,
7918
8062
  envFile
@@ -8834,9 +8978,9 @@ var BaseModel = class {
8834
8978
  };
8835
8979
 
8836
8980
  // src/hooks/model/use-model.ts
8837
- import { useCallback as useCallback71 } from "react";
8981
+ import { useCallback as useCallback76 } from "react";
8838
8982
  var useModel = () => {
8839
- const initModel = useCallback71((modelData) => {
8983
+ const initModel = useCallback76((modelData) => {
8840
8984
  switch (modelData?.name) {
8841
8985
  default:
8842
8986
  return new BaseModel(modelData);
@@ -10226,6 +10370,56 @@ var useAssignRole = () => {
10226
10370
  };
10227
10371
  var use_assign_role_default = useAssignRole;
10228
10372
 
10373
+ // src/hooks/pos/supabase/use-get-supa-current-user.ts
10374
+ import { useMutation as useMutation115 } from "@tanstack/react-query";
10375
+ var useGetSupaCurrentUser = () => {
10376
+ const pos = usePosService();
10377
+ return useMutation115({
10378
+ mutationFn: pos.getSupaCurrentUser
10379
+ });
10380
+ };
10381
+ var use_get_supa_current_user_default = useGetSupaCurrentUser;
10382
+
10383
+ // src/hooks/pos/supabase/use-update-category.ts
10384
+ import { useMutation as useMutation116 } from "@tanstack/react-query";
10385
+ var useUpdateCategory = () => {
10386
+ const pos = usePosService();
10387
+ return useMutation116({
10388
+ mutationFn: pos.updateCategorySupabase
10389
+ });
10390
+ };
10391
+ var use_update_category_default = useUpdateCategory;
10392
+
10393
+ // src/hooks/pos/supabase/use-delete-category.ts
10394
+ import { useMutation as useMutation117 } from "@tanstack/react-query";
10395
+ var useDeleteCategory = () => {
10396
+ const pos = usePosService();
10397
+ return useMutation117({
10398
+ mutationFn: pos.deleteCategorySupabase
10399
+ });
10400
+ };
10401
+ var use_delete_category_default = useDeleteCategory;
10402
+
10403
+ // src/hooks/pos/supabase/use-update-product.ts
10404
+ import { useMutation as useMutation118 } from "@tanstack/react-query";
10405
+ var useUpdateProduct = () => {
10406
+ const pos = usePosService();
10407
+ return useMutation118({
10408
+ mutationFn: pos.updateProductSupabase
10409
+ });
10410
+ };
10411
+ var use_update_product_default = useUpdateProduct;
10412
+
10413
+ // src/hooks/pos/supabase/use-delete-product.ts
10414
+ import { useMutation as useMutation119 } from "@tanstack/react-query";
10415
+ var useDeleteProduct = () => {
10416
+ const pos = usePosService();
10417
+ return useMutation119({
10418
+ mutationFn: pos.deleteProductSupabase
10419
+ });
10420
+ };
10421
+ var use_delete_product_default = useDeleteProduct;
10422
+
10229
10423
  // src/provider/service-provider.tsx
10230
10424
  import { jsx as jsx7 } from "react/jsx-runtime";
10231
10425
  var ServiceContext = createContext3(null);
@@ -10373,6 +10567,11 @@ var ServiceProvider = ({
10373
10567
  useGetListUsers: use_get_list_users_default,
10374
10568
  useGetListRoles: use_get_list_roles_default,
10375
10569
  useAssignRole: use_assign_role_default,
10570
+ useGetSupaCurrentUser: use_get_supa_current_user_default,
10571
+ useUpdateCategory: use_update_category_default,
10572
+ useDeleteCategory: use_delete_category_default,
10573
+ useUpdateProduct: use_update_product_default,
10574
+ useDeleteProduct: use_delete_product_default,
10376
10575
  useActionServerHome: use_action_server_home_default
10377
10576
  };
10378
10577
  return /* @__PURE__ */ jsx7(ServiceContext.Provider, { value: services, children });
@@ -845,6 +845,44 @@ declare const serviceFactories: readonly [(env: any) => {
845
845
  length: number;
846
846
  records: any[];
847
847
  }>;
848
+ }, (env: any) => {
849
+ getSupaCurrentUser: ({ tenantId }: {
850
+ tenantId: string;
851
+ }) => any;
852
+ }, () => {
853
+ updateCategorySupabase: (values: {
854
+ category_id: number;
855
+ name?: string;
856
+ parent_id?: number | null;
857
+ sequence?: number;
858
+ image_128?: string;
859
+ }) => Promise<number[] | null>;
860
+ }, () => {
861
+ deleteCategorySupabase: (values: {
862
+ category_id: number;
863
+ }) => Promise<number[] | null>;
864
+ }, () => {
865
+ updateProductSupabase: (values: {
866
+ product_id: number;
867
+ name?: string;
868
+ product_tmpl_id?: number;
869
+ product_template_variant_value_ids?: number[];
870
+ combo_ids?: number[];
871
+ categ_id?: number;
872
+ pos_categ_ids?: number[];
873
+ display_name?: string;
874
+ default_code?: string;
875
+ description_sale?: string;
876
+ lst_price?: number;
877
+ standard_price?: number;
878
+ barcode?: string;
879
+ image_url?: string;
880
+ active?: boolean;
881
+ }) => Promise<number[] | null>;
882
+ }, () => {
883
+ deleteProductSupabase: (values: {
884
+ product_id: number;
885
+ }) => Promise<number[] | null>;
848
886
  }];
849
887
  type ServiceFactories = (typeof serviceFactories)[number];
850
888
  type ServiceReturn<T extends ServiceFactories> = ReturnType<T>;
@@ -845,6 +845,44 @@ declare const serviceFactories: readonly [(env: any) => {
845
845
  length: number;
846
846
  records: any[];
847
847
  }>;
848
+ }, (env: any) => {
849
+ getSupaCurrentUser: ({ tenantId }: {
850
+ tenantId: string;
851
+ }) => any;
852
+ }, () => {
853
+ updateCategorySupabase: (values: {
854
+ category_id: number;
855
+ name?: string;
856
+ parent_id?: number | null;
857
+ sequence?: number;
858
+ image_128?: string;
859
+ }) => Promise<number[] | null>;
860
+ }, () => {
861
+ deleteCategorySupabase: (values: {
862
+ category_id: number;
863
+ }) => Promise<number[] | null>;
864
+ }, () => {
865
+ updateProductSupabase: (values: {
866
+ product_id: number;
867
+ name?: string;
868
+ product_tmpl_id?: number;
869
+ product_template_variant_value_ids?: number[];
870
+ combo_ids?: number[];
871
+ categ_id?: number;
872
+ pos_categ_ids?: number[];
873
+ display_name?: string;
874
+ default_code?: string;
875
+ description_sale?: string;
876
+ lst_price?: number;
877
+ standard_price?: number;
878
+ barcode?: string;
879
+ image_url?: string;
880
+ active?: boolean;
881
+ }) => Promise<number[] | null>;
882
+ }, () => {
883
+ deleteProductSupabase: (values: {
884
+ product_id: number;
885
+ }) => Promise<number[] | null>;
848
886
  }];
849
887
  type ServiceFactories = (typeof serviceFactories)[number];
850
888
  type ServiceReturn<T extends ServiceFactories> = ReturnType<T>;