@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/constants.d.mts +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.mjs +1 -0
- package/dist/hooks.d.mts +39 -1
- package/dist/hooks.d.ts +39 -1
- package/dist/hooks.js +207 -3
- package/dist/hooks.mjs +202 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +212 -3
- package/dist/index.mjs +207 -3
- package/dist/provider.d.mts +6 -1
- package/dist/provider.d.ts +6 -1
- package/dist/provider.js +223 -24
- package/dist/provider.mjs +212 -13
- package/dist/services.d.mts +38 -0
- package/dist/services.d.ts +38 -0
- package/dist/services.js +257 -98
- package/dist/services.mjs +254 -95
- package/package.json +1 -1
package/dist/provider.js
CHANGED
|
@@ -700,7 +700,7 @@ var MainProvider = ({ children }) => {
|
|
|
700
700
|
};
|
|
701
701
|
|
|
702
702
|
// src/provider/version-gate-provider.tsx
|
|
703
|
-
var
|
|
703
|
+
var import_react78 = require("react");
|
|
704
704
|
var import_react_query2 = require("@tanstack/react-query");
|
|
705
705
|
|
|
706
706
|
// src/services/action-service/index.ts
|
|
@@ -739,6 +739,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
|
|
|
739
739
|
UriConstants2["TOKEN_BY_CODE"] = "/token";
|
|
740
740
|
UriConstants2["LOGOUT"] = "/logout";
|
|
741
741
|
UriConstants2["SUPABASE_LOGIN_PATH"] = "/api/v2/auth/login";
|
|
742
|
+
UriConstants2["SUPABASE_CURRENT_USER"] = "/api/v2/auth/me";
|
|
742
743
|
UriConstants2["CREATE_UPDATE"] = "/create_update";
|
|
743
744
|
UriConstants2["SEARCH_READ"] = "/search_read";
|
|
744
745
|
UriConstants2["CREATE_PATH"] = "/create";
|
|
@@ -7424,6 +7425,144 @@ var getPartnerTitlesSupabaseService = () => {
|
|
|
7424
7425
|
};
|
|
7425
7426
|
};
|
|
7426
7427
|
|
|
7428
|
+
// src/services/pos-service/supabase/get-supa-current-user.ts
|
|
7429
|
+
var import_react73 = require("react");
|
|
7430
|
+
var getSupaCurrentUser = (env) => {
|
|
7431
|
+
const getSupaCurrentUser2 = (0, import_react73.useCallback)(
|
|
7432
|
+
({ tenantId }) => {
|
|
7433
|
+
return env?.requests.get("/api/v2/auth/me" /* SUPABASE_CURRENT_USER */, {
|
|
7434
|
+
headers: {
|
|
7435
|
+
"Content-Type": "application/json",
|
|
7436
|
+
"x-tenant-id": tenantId
|
|
7437
|
+
}
|
|
7438
|
+
});
|
|
7439
|
+
},
|
|
7440
|
+
[env]
|
|
7441
|
+
);
|
|
7442
|
+
return {
|
|
7443
|
+
getSupaCurrentUser: getSupaCurrentUser2
|
|
7444
|
+
};
|
|
7445
|
+
};
|
|
7446
|
+
|
|
7447
|
+
// src/services/pos-service/supabase/update-category.ts
|
|
7448
|
+
var import_react74 = require("react");
|
|
7449
|
+
var updateCategorySupabaseService = () => {
|
|
7450
|
+
const supabase = useSupabaseOptional();
|
|
7451
|
+
const updateCategorySupabase = (0, import_react74.useCallback)(
|
|
7452
|
+
async (values) => {
|
|
7453
|
+
if (!supabase) {
|
|
7454
|
+
console.error("Supabase client not initialized");
|
|
7455
|
+
return null;
|
|
7456
|
+
}
|
|
7457
|
+
try {
|
|
7458
|
+
const { category_id, ...rest } = values;
|
|
7459
|
+
const { data, error } = await supabase.from("pos_categories" /* POS_CATEGORIES */).update(rest).eq("id", category_id).select("id").single();
|
|
7460
|
+
if (error) {
|
|
7461
|
+
console.error("Error updating category:", error);
|
|
7462
|
+
return null;
|
|
7463
|
+
}
|
|
7464
|
+
return [data.id];
|
|
7465
|
+
} catch (error) {
|
|
7466
|
+
console.error("Error updating category:", error);
|
|
7467
|
+
return null;
|
|
7468
|
+
}
|
|
7469
|
+
},
|
|
7470
|
+
[supabase]
|
|
7471
|
+
);
|
|
7472
|
+
return {
|
|
7473
|
+
updateCategorySupabase
|
|
7474
|
+
};
|
|
7475
|
+
};
|
|
7476
|
+
|
|
7477
|
+
// src/services/pos-service/supabase/delete-category.ts
|
|
7478
|
+
var import_react75 = require("react");
|
|
7479
|
+
var deleteCategorySupabaseService = () => {
|
|
7480
|
+
const supabase = useSupabaseOptional();
|
|
7481
|
+
const deleteCategorySupabase = (0, import_react75.useCallback)(
|
|
7482
|
+
async (values) => {
|
|
7483
|
+
if (!supabase) {
|
|
7484
|
+
console.error("Supabase client not initialized");
|
|
7485
|
+
return null;
|
|
7486
|
+
}
|
|
7487
|
+
try {
|
|
7488
|
+
const { error } = await supabase.from("pos_categories" /* POS_CATEGORIES */).delete().eq("id", values.category_id);
|
|
7489
|
+
if (error) {
|
|
7490
|
+
console.error("Error deleting category:", error);
|
|
7491
|
+
return null;
|
|
7492
|
+
}
|
|
7493
|
+
return [values.category_id];
|
|
7494
|
+
} catch (error) {
|
|
7495
|
+
console.error("Error deleting category:", error);
|
|
7496
|
+
return null;
|
|
7497
|
+
}
|
|
7498
|
+
},
|
|
7499
|
+
[supabase]
|
|
7500
|
+
);
|
|
7501
|
+
return {
|
|
7502
|
+
deleteCategorySupabase
|
|
7503
|
+
};
|
|
7504
|
+
};
|
|
7505
|
+
|
|
7506
|
+
// src/services/pos-service/supabase/update-product.ts
|
|
7507
|
+
var import_react76 = require("react");
|
|
7508
|
+
var updateProductSupabaseService = () => {
|
|
7509
|
+
const supabase = useSupabaseOptional();
|
|
7510
|
+
const updateProductSupabase = (0, import_react76.useCallback)(
|
|
7511
|
+
async (values) => {
|
|
7512
|
+
if (!supabase) {
|
|
7513
|
+
console.error("Supabase client not initialized");
|
|
7514
|
+
return null;
|
|
7515
|
+
}
|
|
7516
|
+
try {
|
|
7517
|
+
const { product_id, ...rest } = values;
|
|
7518
|
+
const updateData = cleanObject(rest);
|
|
7519
|
+
const { data, error } = await supabase.from("products" /* PRODUCTS */).update(updateData).eq("id", product_id).select("id").single();
|
|
7520
|
+
if (error) {
|
|
7521
|
+
console.error("Error updating product:", error);
|
|
7522
|
+
return null;
|
|
7523
|
+
}
|
|
7524
|
+
return [data.id];
|
|
7525
|
+
} catch (error) {
|
|
7526
|
+
console.error("Error updating product:", error);
|
|
7527
|
+
return null;
|
|
7528
|
+
}
|
|
7529
|
+
},
|
|
7530
|
+
[supabase]
|
|
7531
|
+
);
|
|
7532
|
+
return {
|
|
7533
|
+
updateProductSupabase
|
|
7534
|
+
};
|
|
7535
|
+
};
|
|
7536
|
+
|
|
7537
|
+
// src/services/pos-service/supabase/delete-product.ts
|
|
7538
|
+
var import_react77 = require("react");
|
|
7539
|
+
var deleteProductSupabaseService = () => {
|
|
7540
|
+
const supabase = useSupabaseOptional();
|
|
7541
|
+
const deleteProductSupabase = (0, import_react77.useCallback)(
|
|
7542
|
+
async (values) => {
|
|
7543
|
+
if (!supabase) {
|
|
7544
|
+
console.error("Supabase client not initialized");
|
|
7545
|
+
return null;
|
|
7546
|
+
}
|
|
7547
|
+
try {
|
|
7548
|
+
const { error } = await supabase.from("products" /* PRODUCTS */).delete().eq("id", values.product_id);
|
|
7549
|
+
if (error) {
|
|
7550
|
+
console.error("Error deleting product:", error);
|
|
7551
|
+
return null;
|
|
7552
|
+
}
|
|
7553
|
+
return [values.product_id];
|
|
7554
|
+
} catch (error) {
|
|
7555
|
+
console.error("Error deleting product:", error);
|
|
7556
|
+
return null;
|
|
7557
|
+
}
|
|
7558
|
+
},
|
|
7559
|
+
[supabase]
|
|
7560
|
+
);
|
|
7561
|
+
return {
|
|
7562
|
+
deleteProductSupabase
|
|
7563
|
+
};
|
|
7564
|
+
};
|
|
7565
|
+
|
|
7427
7566
|
// src/services/pos-service/index.ts
|
|
7428
7567
|
var serviceFactories = [
|
|
7429
7568
|
addEntityService,
|
|
@@ -7484,7 +7623,12 @@ var serviceFactories = [
|
|
|
7484
7623
|
assignRoleService,
|
|
7485
7624
|
getStatesSupabaseService,
|
|
7486
7625
|
getWardsSupabaseService,
|
|
7487
|
-
getPartnerTitlesSupabaseService
|
|
7626
|
+
getPartnerTitlesSupabaseService,
|
|
7627
|
+
getSupaCurrentUser,
|
|
7628
|
+
updateCategorySupabaseService,
|
|
7629
|
+
deleteCategorySupabaseService,
|
|
7630
|
+
updateProductSupabaseService,
|
|
7631
|
+
deleteProductSupabaseService
|
|
7488
7632
|
];
|
|
7489
7633
|
var usePosService = () => {
|
|
7490
7634
|
const { env } = useEnv();
|
|
@@ -7500,9 +7644,9 @@ var usePosService = () => {
|
|
|
7500
7644
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
7501
7645
|
var VersionGate = ({ children }) => {
|
|
7502
7646
|
const queryClient = (0, import_react_query2.useQueryClient)();
|
|
7503
|
-
const [ready, setReady] = (0,
|
|
7647
|
+
const [ready, setReady] = (0, import_react78.useState)(false);
|
|
7504
7648
|
const { getVersion } = useViewService();
|
|
7505
|
-
(0,
|
|
7649
|
+
(0, import_react78.useEffect)(() => {
|
|
7506
7650
|
const clearVersion = () => {
|
|
7507
7651
|
queryClient.clear();
|
|
7508
7652
|
localStorage.removeItem("__api_version__");
|
|
@@ -7533,7 +7677,7 @@ var VersionGate = ({ children }) => {
|
|
|
7533
7677
|
};
|
|
7534
7678
|
|
|
7535
7679
|
// src/provider/env-provider.tsx
|
|
7536
|
-
var
|
|
7680
|
+
var import_react79 = require("react");
|
|
7537
7681
|
|
|
7538
7682
|
// src/configs/axios-client.ts
|
|
7539
7683
|
var import_axios = __toESM(require("axios"));
|
|
@@ -7887,18 +8031,18 @@ var initialEnvState = {
|
|
|
7887
8031
|
excludeLanguages: [],
|
|
7888
8032
|
isSupaMode: false
|
|
7889
8033
|
};
|
|
7890
|
-
var EnvContext = (0,
|
|
8034
|
+
var EnvContext = (0, import_react79.createContext)(null);
|
|
7891
8035
|
function EnvProvider({
|
|
7892
8036
|
children,
|
|
7893
8037
|
localStorageUtils: localStorageUtil = localStorageUtils(),
|
|
7894
8038
|
sessionStorageUtils: sessionStorageUtil = sessionStorageUtils
|
|
7895
8039
|
}) {
|
|
7896
|
-
const [env, setEnvState] = (0,
|
|
8040
|
+
const [env, setEnvState] = (0, import_react79.useState)({
|
|
7897
8041
|
...initialEnvState,
|
|
7898
8042
|
localStorageUtils: localStorageUtil,
|
|
7899
8043
|
sessionStorageUtils: sessionStorageUtil
|
|
7900
8044
|
});
|
|
7901
|
-
const setupEnv = (0,
|
|
8045
|
+
const setupEnv = (0, import_react79.useCallback)(
|
|
7902
8046
|
(envConfig) => {
|
|
7903
8047
|
const updatedEnv = {
|
|
7904
8048
|
...env,
|
|
@@ -7912,31 +8056,31 @@ function EnvProvider({
|
|
|
7912
8056
|
},
|
|
7913
8057
|
[env, localStorageUtil, sessionStorageUtil]
|
|
7914
8058
|
);
|
|
7915
|
-
const setUid2 = (0,
|
|
8059
|
+
const setUid2 = (0, import_react79.useCallback)((uid) => {
|
|
7916
8060
|
setEnvState((prev) => ({
|
|
7917
8061
|
...prev,
|
|
7918
8062
|
context: { ...prev.context, uid }
|
|
7919
8063
|
}));
|
|
7920
8064
|
}, []);
|
|
7921
|
-
const setLang2 = (0,
|
|
8065
|
+
const setLang2 = (0, import_react79.useCallback)((lang) => {
|
|
7922
8066
|
setEnvState((prev) => ({
|
|
7923
8067
|
...prev,
|
|
7924
8068
|
context: { ...prev.context, lang }
|
|
7925
8069
|
}));
|
|
7926
8070
|
}, []);
|
|
7927
|
-
const setAllowCompanies2 = (0,
|
|
8071
|
+
const setAllowCompanies2 = (0, import_react79.useCallback)((allowed_company_ids) => {
|
|
7928
8072
|
setEnvState((prev) => ({
|
|
7929
8073
|
...prev,
|
|
7930
8074
|
context: { ...prev.context, allowed_company_ids }
|
|
7931
8075
|
}));
|
|
7932
8076
|
}, []);
|
|
7933
|
-
const setCompanies2 = (0,
|
|
8077
|
+
const setCompanies2 = (0, import_react79.useCallback)((companies) => {
|
|
7934
8078
|
setEnvState((prev) => ({
|
|
7935
8079
|
...prev,
|
|
7936
8080
|
companies
|
|
7937
8081
|
}));
|
|
7938
8082
|
}, []);
|
|
7939
|
-
const setDefaultCompany2 = (0,
|
|
8083
|
+
const setDefaultCompany2 = (0, import_react79.useCallback)(
|
|
7940
8084
|
(defaultCompany) => {
|
|
7941
8085
|
setEnvState((prev) => ({
|
|
7942
8086
|
...prev,
|
|
@@ -7945,19 +8089,19 @@ function EnvProvider({
|
|
|
7945
8089
|
},
|
|
7946
8090
|
[]
|
|
7947
8091
|
);
|
|
7948
|
-
const setUserInfo = (0,
|
|
8092
|
+
const setUserInfo = (0, import_react79.useCallback)((user) => {
|
|
7949
8093
|
setEnvState((prev) => ({
|
|
7950
8094
|
...prev,
|
|
7951
8095
|
user
|
|
7952
8096
|
}));
|
|
7953
8097
|
}, []);
|
|
7954
|
-
const setConfig2 = (0,
|
|
8098
|
+
const setConfig2 = (0, import_react79.useCallback)((config) => {
|
|
7955
8099
|
setEnvState((prev) => ({
|
|
7956
8100
|
...prev,
|
|
7957
8101
|
config
|
|
7958
8102
|
}));
|
|
7959
8103
|
}, []);
|
|
7960
|
-
const setEnvFile2 = (0,
|
|
8104
|
+
const setEnvFile2 = (0, import_react79.useCallback)((envFile) => {
|
|
7961
8105
|
setEnvState((prev) => ({
|
|
7962
8106
|
...prev,
|
|
7963
8107
|
envFile
|
|
@@ -7983,7 +8127,7 @@ function EnvProvider({
|
|
|
7983
8127
|
);
|
|
7984
8128
|
}
|
|
7985
8129
|
function useEnv() {
|
|
7986
|
-
const context = (0,
|
|
8130
|
+
const context = (0, import_react79.useContext)(EnvContext);
|
|
7987
8131
|
if (!context) {
|
|
7988
8132
|
throw new Error("useEnv must be used within an EnvProvider");
|
|
7989
8133
|
}
|
|
@@ -7991,7 +8135,7 @@ function useEnv() {
|
|
|
7991
8135
|
}
|
|
7992
8136
|
|
|
7993
8137
|
// src/provider/service-provider.tsx
|
|
7994
|
-
var
|
|
8138
|
+
var import_react81 = require("react");
|
|
7995
8139
|
|
|
7996
8140
|
// src/hooks/auth/use-forgot-password.ts
|
|
7997
8141
|
var import_react_query3 = require("@tanstack/react-query");
|
|
@@ -8879,9 +9023,9 @@ var BaseModel = class {
|
|
|
8879
9023
|
};
|
|
8880
9024
|
|
|
8881
9025
|
// src/hooks/model/use-model.ts
|
|
8882
|
-
var
|
|
9026
|
+
var import_react80 = require("react");
|
|
8883
9027
|
var useModel = () => {
|
|
8884
|
-
const initModel = (0,
|
|
9028
|
+
const initModel = (0, import_react80.useCallback)((modelData) => {
|
|
8885
9029
|
switch (modelData?.name) {
|
|
8886
9030
|
default:
|
|
8887
9031
|
return new BaseModel(modelData);
|
|
@@ -10271,9 +10415,59 @@ var useAssignRole = () => {
|
|
|
10271
10415
|
};
|
|
10272
10416
|
var use_assign_role_default = useAssignRole;
|
|
10273
10417
|
|
|
10418
|
+
// src/hooks/pos/supabase/use-get-supa-current-user.ts
|
|
10419
|
+
var import_react_query142 = require("@tanstack/react-query");
|
|
10420
|
+
var useGetSupaCurrentUser = () => {
|
|
10421
|
+
const pos = usePosService();
|
|
10422
|
+
return (0, import_react_query142.useMutation)({
|
|
10423
|
+
mutationFn: pos.getSupaCurrentUser
|
|
10424
|
+
});
|
|
10425
|
+
};
|
|
10426
|
+
var use_get_supa_current_user_default = useGetSupaCurrentUser;
|
|
10427
|
+
|
|
10428
|
+
// src/hooks/pos/supabase/use-update-category.ts
|
|
10429
|
+
var import_react_query143 = require("@tanstack/react-query");
|
|
10430
|
+
var useUpdateCategory = () => {
|
|
10431
|
+
const pos = usePosService();
|
|
10432
|
+
return (0, import_react_query143.useMutation)({
|
|
10433
|
+
mutationFn: pos.updateCategorySupabase
|
|
10434
|
+
});
|
|
10435
|
+
};
|
|
10436
|
+
var use_update_category_default = useUpdateCategory;
|
|
10437
|
+
|
|
10438
|
+
// src/hooks/pos/supabase/use-delete-category.ts
|
|
10439
|
+
var import_react_query144 = require("@tanstack/react-query");
|
|
10440
|
+
var useDeleteCategory = () => {
|
|
10441
|
+
const pos = usePosService();
|
|
10442
|
+
return (0, import_react_query144.useMutation)({
|
|
10443
|
+
mutationFn: pos.deleteCategorySupabase
|
|
10444
|
+
});
|
|
10445
|
+
};
|
|
10446
|
+
var use_delete_category_default = useDeleteCategory;
|
|
10447
|
+
|
|
10448
|
+
// src/hooks/pos/supabase/use-update-product.ts
|
|
10449
|
+
var import_react_query145 = require("@tanstack/react-query");
|
|
10450
|
+
var useUpdateProduct = () => {
|
|
10451
|
+
const pos = usePosService();
|
|
10452
|
+
return (0, import_react_query145.useMutation)({
|
|
10453
|
+
mutationFn: pos.updateProductSupabase
|
|
10454
|
+
});
|
|
10455
|
+
};
|
|
10456
|
+
var use_update_product_default = useUpdateProduct;
|
|
10457
|
+
|
|
10458
|
+
// src/hooks/pos/supabase/use-delete-product.ts
|
|
10459
|
+
var import_react_query146 = require("@tanstack/react-query");
|
|
10460
|
+
var useDeleteProduct = () => {
|
|
10461
|
+
const pos = usePosService();
|
|
10462
|
+
return (0, import_react_query146.useMutation)({
|
|
10463
|
+
mutationFn: pos.deleteProductSupabase
|
|
10464
|
+
});
|
|
10465
|
+
};
|
|
10466
|
+
var use_delete_product_default = useDeleteProduct;
|
|
10467
|
+
|
|
10274
10468
|
// src/provider/service-provider.tsx
|
|
10275
10469
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
10276
|
-
var ServiceContext = (0,
|
|
10470
|
+
var ServiceContext = (0, import_react81.createContext)(null);
|
|
10277
10471
|
var ServiceProvider = ({
|
|
10278
10472
|
children
|
|
10279
10473
|
}) => {
|
|
@@ -10418,12 +10612,17 @@ var ServiceProvider = ({
|
|
|
10418
10612
|
useGetListUsers: use_get_list_users_default,
|
|
10419
10613
|
useGetListRoles: use_get_list_roles_default,
|
|
10420
10614
|
useAssignRole: use_assign_role_default,
|
|
10615
|
+
useGetSupaCurrentUser: use_get_supa_current_user_default,
|
|
10616
|
+
useUpdateCategory: use_update_category_default,
|
|
10617
|
+
useDeleteCategory: use_delete_category_default,
|
|
10618
|
+
useUpdateProduct: use_update_product_default,
|
|
10619
|
+
useDeleteProduct: use_delete_product_default,
|
|
10421
10620
|
useActionServerHome: use_action_server_home_default
|
|
10422
10621
|
};
|
|
10423
10622
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ServiceContext.Provider, { value: services, children });
|
|
10424
10623
|
};
|
|
10425
10624
|
var useService = () => {
|
|
10426
|
-
const context = (0,
|
|
10625
|
+
const context = (0, import_react81.useContext)(ServiceContext);
|
|
10427
10626
|
if (!context) {
|
|
10428
10627
|
throw new Error("useService must be used within a ServiceProvider");
|
|
10429
10628
|
}
|
|
@@ -10431,7 +10630,7 @@ var useService = () => {
|
|
|
10431
10630
|
};
|
|
10432
10631
|
|
|
10433
10632
|
// src/provider/meta-provider.tsx
|
|
10434
|
-
var
|
|
10633
|
+
var import_react82 = require("react");
|
|
10435
10634
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
10436
10635
|
var MetaProvider = ({ children }) => {
|
|
10437
10636
|
const { env } = useEnv();
|
|
@@ -10480,7 +10679,7 @@ var MetaProvider = ({ children }) => {
|
|
|
10480
10679
|
}
|
|
10481
10680
|
}
|
|
10482
10681
|
}
|
|
10483
|
-
(0,
|
|
10682
|
+
(0, import_react82.useEffect)(() => {
|
|
10484
10683
|
updateMetadata();
|
|
10485
10684
|
}, [env?.defaultCompany]);
|
|
10486
10685
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children });
|