@fctc/interface-logic 4.9.6 → 4.9.8

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
@@ -666,6 +666,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
666
666
  UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
667
667
  UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
668
668
  UriConstants2["CALL_PATH"] = "/call";
669
+ UriConstants2["SUPABASE_CALL_PATH"] = "/api/v2/call";
669
670
  UriConstants2["COMPANY_PATH"] = "/company";
670
671
  UriConstants2["PROFILE_PATH"] = "/userinfo";
671
672
  UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
@@ -692,6 +693,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
692
693
  UriConstants2["GRANT_ACCESS"] = "/grant-access";
693
694
  UriConstants2["TOKEN_BY_CODE"] = "/token";
694
695
  UriConstants2["LOGOUT"] = "/logout";
696
+ UriConstants2["SUPABASE_LOGIN_PATH"] = "/api/v2/auth/login";
695
697
  UriConstants2["CREATE_UPDATE"] = "/create_update";
696
698
  UriConstants2["SEARCH_READ"] = "/search_read";
697
699
  UriConstants2["CREATE_PATH"] = "/create";
@@ -3233,11 +3235,7 @@ function useActionService() {
3233
3235
  [env]
3234
3236
  );
3235
3237
  const actionServerHome = useCallback(async () => {
3236
- return await env.requests.get("/action_server_home" /* ACTION_SERVER_HOME */, {
3237
- headers: {
3238
- "Content-Type": "application/json"
3239
- }
3240
- });
3238
+ return env?.requests?.get("/action_server_home" /* ACTION_SERVER_HOME */);
3241
3239
  }, [env]);
3242
3240
  return {
3243
3241
  loadAction,
@@ -3322,19 +3320,18 @@ function useAuthService() {
3322
3320
  );
3323
3321
  const loginTenantUser = useCallback2(
3324
3322
  async (body) => {
3325
- if (!supabase) {
3326
- return {
3327
- data: null,
3328
- error: { message: "Supabase client is not initialized" }
3329
- };
3330
- }
3331
- const { data, error } = await supabase.auth.signInWithPassword({
3323
+ const payload = {
3332
3324
  email: body.email,
3333
- password: body.password
3325
+ password: body.password,
3326
+ tenant_id: body.tenantId
3327
+ };
3328
+ return env?.requests?.post("/api/v2/auth/login" /* SUPABASE_LOGIN_PATH */, payload, {
3329
+ headers: {
3330
+ "Content-Type": "application/json"
3331
+ }
3334
3332
  });
3335
- return { data, error };
3336
3333
  },
3337
- [supabase]
3334
+ [env]
3338
3335
  );
3339
3336
  const forgotPassword = useCallback2(
3340
3337
  async (email) => {
@@ -7195,6 +7192,7 @@ var uploadImageSupabaseService = () => {
7195
7192
  return { url: null, error: uploadError };
7196
7193
  }
7197
7194
  const { data: urlData } = supabase.storage.from(bucketName).getPublicUrl(fileName);
7195
+ console.log("urlData", urlData);
7198
7196
  return { url: urlData.publicUrl, error: null };
7199
7197
  } catch (error) {
7200
7198
  console.error("Error uploading image:", error);
@@ -7208,6 +7206,83 @@ var uploadImageSupabaseService = () => {
7208
7206
  };
7209
7207
  };
7210
7208
 
7209
+ // src/services/pos-service/supabase/get-list-users.ts
7210
+ import { useCallback as useCallback64 } from "react";
7211
+ var getListUsersService = (env) => {
7212
+ const getListUsers = useCallback64(
7213
+ ({ tenantId }) => {
7214
+ const jsonData = {
7215
+ model: "tenant.users",
7216
+ method: "search_read"
7217
+ };
7218
+ return env?.requests.post("/api/v2/call" /* SUPABASE_CALL_PATH */, jsonData, {
7219
+ headers: {
7220
+ "Content-Type": "application/json",
7221
+ "x-tenant-id": tenantId
7222
+ }
7223
+ });
7224
+ },
7225
+ [env]
7226
+ );
7227
+ return {
7228
+ getListUsers
7229
+ };
7230
+ };
7231
+
7232
+ // src/services/pos-service/supabase/get-list-roles.ts
7233
+ import { useCallback as useCallback65 } from "react";
7234
+ var getListRolesService = (env) => {
7235
+ const getListRoles = useCallback65(
7236
+ ({ tenantId }) => {
7237
+ const jsonData = {
7238
+ model: "tenant.roles",
7239
+ method: "search_read"
7240
+ };
7241
+ return env?.requests.post("/api/v2/call" /* SUPABASE_CALL_PATH */, jsonData, {
7242
+ headers: {
7243
+ "Content-Type": "application/json",
7244
+ "x-tenant-id": tenantId
7245
+ }
7246
+ });
7247
+ },
7248
+ [env]
7249
+ );
7250
+ return {
7251
+ getListRoles
7252
+ };
7253
+ };
7254
+
7255
+ // src/services/pos-service/supabase/assign-role.ts
7256
+ import { useCallback as useCallback66 } from "react";
7257
+ var assignRoleService = (env) => {
7258
+ const assignRole = useCallback66(
7259
+ ({
7260
+ tenantId,
7261
+ userId,
7262
+ roleId
7263
+ }) => {
7264
+ const jsonData = {
7265
+ model: "tenant.user_roles",
7266
+ method: "assign",
7267
+ kwargs: {
7268
+ user_id: userId,
7269
+ role_id: roleId
7270
+ }
7271
+ };
7272
+ return env?.requests.post("/api/v2/call" /* SUPABASE_CALL_PATH */, jsonData, {
7273
+ headers: {
7274
+ "Content-Type": "application/json",
7275
+ "x-tenant-id": tenantId
7276
+ }
7277
+ });
7278
+ },
7279
+ [env]
7280
+ );
7281
+ return {
7282
+ assignRole
7283
+ };
7284
+ };
7285
+
7211
7286
  // src/services/pos-service/index.ts
7212
7287
  var serviceFactories = [
7213
7288
  addEntityService,
@@ -7262,7 +7337,10 @@ var serviceFactories = [
7262
7337
  createCustomerSupabaseService,
7263
7338
  updateCustomerSupabaseService,
7264
7339
  deleteCustomerSupabaseService,
7265
- uploadImageSupabaseService
7340
+ uploadImageSupabaseService,
7341
+ getListUsersService,
7342
+ getListRolesService,
7343
+ assignRoleService
7266
7344
  ];
7267
7345
  var usePosService = () => {
7268
7346
  const { env } = useEnv();
@@ -7311,7 +7389,7 @@ var VersionGate = ({ children }) => {
7311
7389
  };
7312
7390
 
7313
7391
  // src/provider/env-provider.tsx
7314
- import { createContext as createContext2, useContext as useContext2, useState as useState4, useCallback as useCallback64 } from "react";
7392
+ import { createContext as createContext2, useContext as useContext2, useState as useState4, useCallback as useCallback67 } from "react";
7315
7393
 
7316
7394
  // src/configs/axios-client.ts
7317
7395
  import axios from "axios";
@@ -7324,6 +7402,7 @@ var axiosClient = {
7324
7402
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils;
7325
7403
  const db = config?.db;
7326
7404
  const database = config?.config?.database;
7405
+ const isSupabaseMode = config?.isSupaMode;
7327
7406
  let isRefreshing = false;
7328
7407
  let failedQueue = [];
7329
7408
  const processQueue = (error, token = null) => {
@@ -7585,7 +7664,7 @@ var axiosClient = {
7585
7664
  return url + (db2 ? "?db=" + db2 : "");
7586
7665
  }
7587
7666
  const getBaseUrl = (baseUrl, hardService) => {
7588
- return `${baseUrl.replace(/\/$/, "")}/${hardService || sessionStorage2.getMenuFocus().service || config?.default_service}/api/v2`;
7667
+ return isSupabaseMode ? "" : `${baseUrl.replace(/\/$/, "")}/${hardService || sessionStorage2.getMenuFocus().service || config?.default_service}/api/v2`;
7589
7668
  };
7590
7669
  const getHeaders = (header) => {
7591
7670
  const headers = {
@@ -7675,7 +7754,7 @@ function EnvProvider({
7675
7754
  localStorageUtils: localStorageUtil,
7676
7755
  sessionStorageUtils: sessionStorageUtil
7677
7756
  });
7678
- const setupEnv = useCallback64(
7757
+ const setupEnv = useCallback67(
7679
7758
  (envConfig) => {
7680
7759
  const updatedEnv = {
7681
7760
  ...env,
@@ -7689,31 +7768,31 @@ function EnvProvider({
7689
7768
  },
7690
7769
  [env, localStorageUtil, sessionStorageUtil]
7691
7770
  );
7692
- const setUid2 = useCallback64((uid) => {
7771
+ const setUid2 = useCallback67((uid) => {
7693
7772
  setEnvState((prev) => ({
7694
7773
  ...prev,
7695
7774
  context: { ...prev.context, uid }
7696
7775
  }));
7697
7776
  }, []);
7698
- const setLang2 = useCallback64((lang) => {
7777
+ const setLang2 = useCallback67((lang) => {
7699
7778
  setEnvState((prev) => ({
7700
7779
  ...prev,
7701
7780
  context: { ...prev.context, lang }
7702
7781
  }));
7703
7782
  }, []);
7704
- const setAllowCompanies2 = useCallback64((allowed_company_ids) => {
7783
+ const setAllowCompanies2 = useCallback67((allowed_company_ids) => {
7705
7784
  setEnvState((prev) => ({
7706
7785
  ...prev,
7707
7786
  context: { ...prev.context, allowed_company_ids }
7708
7787
  }));
7709
7788
  }, []);
7710
- const setCompanies2 = useCallback64((companies) => {
7789
+ const setCompanies2 = useCallback67((companies) => {
7711
7790
  setEnvState((prev) => ({
7712
7791
  ...prev,
7713
7792
  companies
7714
7793
  }));
7715
7794
  }, []);
7716
- const setDefaultCompany2 = useCallback64(
7795
+ const setDefaultCompany2 = useCallback67(
7717
7796
  (defaultCompany) => {
7718
7797
  setEnvState((prev) => ({
7719
7798
  ...prev,
@@ -7722,19 +7801,19 @@ function EnvProvider({
7722
7801
  },
7723
7802
  []
7724
7803
  );
7725
- const setUserInfo = useCallback64((user) => {
7804
+ const setUserInfo = useCallback67((user) => {
7726
7805
  setEnvState((prev) => ({
7727
7806
  ...prev,
7728
7807
  user
7729
7808
  }));
7730
7809
  }, []);
7731
- const setConfig2 = useCallback64((config) => {
7810
+ const setConfig2 = useCallback67((config) => {
7732
7811
  setEnvState((prev) => ({
7733
7812
  ...prev,
7734
7813
  config
7735
7814
  }));
7736
7815
  }, []);
7737
- const setEnvFile2 = useCallback64((envFile) => {
7816
+ const setEnvFile2 = useCallback67((envFile) => {
7738
7817
  setEnvState((prev) => ({
7739
7818
  ...prev,
7740
7819
  envFile
@@ -7854,7 +7933,8 @@ var useLoginTenantUser = () => {
7854
7933
  mutationFn: (data) => {
7855
7934
  return loginTenantUser({
7856
7935
  email: data.email,
7857
- password: data.password
7936
+ password: data.password,
7937
+ tenantId: data.tenantId
7858
7938
  });
7859
7939
  }
7860
7940
  });
@@ -8655,9 +8735,9 @@ var BaseModel = class {
8655
8735
  };
8656
8736
 
8657
8737
  // src/hooks/model/use-model.ts
8658
- import { useCallback as useCallback65 } from "react";
8738
+ import { useCallback as useCallback68 } from "react";
8659
8739
  var useModel = () => {
8660
- const initModel = useCallback65((modelData) => {
8740
+ const initModel = useCallback68((modelData) => {
8661
8741
  switch (modelData?.name) {
8662
8742
  default:
8663
8743
  return new BaseModel(modelData);
@@ -10011,6 +10091,36 @@ var useSupaUploadImage = () => {
10011
10091
  };
10012
10092
  var use_supa_upload_image_default = useSupaUploadImage;
10013
10093
 
10094
+ // src/hooks/pos/supabase/use-get-list-users.ts
10095
+ import { useMutation as useMutation112 } from "@tanstack/react-query";
10096
+ var useGetListUsers = () => {
10097
+ const pos = usePosService();
10098
+ return useMutation112({
10099
+ mutationFn: pos.getListUsers
10100
+ });
10101
+ };
10102
+ var use_get_list_users_default = useGetListUsers;
10103
+
10104
+ // src/hooks/pos/supabase/use-get-list-roles.ts
10105
+ import { useMutation as useMutation113 } from "@tanstack/react-query";
10106
+ var useGetListRoles = () => {
10107
+ const pos = usePosService();
10108
+ return useMutation113({
10109
+ mutationFn: pos.getListRoles
10110
+ });
10111
+ };
10112
+ var use_get_list_roles_default = useGetListRoles;
10113
+
10114
+ // src/hooks/pos/supabase/use-assign-role.ts
10115
+ import { useMutation as useMutation114 } from "@tanstack/react-query";
10116
+ var useAssignRole = () => {
10117
+ const pos = usePosService();
10118
+ return useMutation114({
10119
+ mutationFn: pos.assignRole
10120
+ });
10121
+ };
10122
+ var use_assign_role_default = useAssignRole;
10123
+
10014
10124
  // src/provider/service-provider.tsx
10015
10125
  import { jsx as jsx7 } from "react/jsx-runtime";
10016
10126
  var ServiceContext = createContext3(null);
@@ -10155,6 +10265,9 @@ var ServiceProvider = ({
10155
10265
  useUpdateCustomer: use_update_customer_default,
10156
10266
  useDeleteCustomer: use_delete_customer_default,
10157
10267
  useUploadImage: use_upload_image_default,
10268
+ useGetListUsers: use_get_list_users_default,
10269
+ useGetListRoles: use_get_list_roles_default,
10270
+ useAssignRole: use_assign_role_default,
10158
10271
  useActionServerHome: use_action_server_home_default
10159
10272
  };
10160
10273
  return /* @__PURE__ */ jsx7(ServiceContext.Provider, { value: services, children });
@@ -1,5 +1,4 @@
1
1
  import { C as ContextApi, L as LoginCredentialBody, R as ResetPasswordRequest, U as UpdatePasswordRequest, T as TThreadData, h as GetExternalTab, b as GetListParams, a as GetDetailParams, S as SaveParams, D as DeleteParams, O as OnChangeParams, V as ViewData, f as GetViewParams, c as GetSelectionType } from './view-type-CfcWWR0w.mjs';
2
- import * as _supabase_auth_js from '@supabase/auth-js';
3
2
 
4
3
  declare function useActionService(): {
5
4
  loadAction: ({ idAction, context, service, xNode, searchParams, }: {
@@ -60,23 +59,8 @@ declare function useAuthService(): {
60
59
  loginTenantUser: (body: {
61
60
  email: string;
62
61
  password: string;
63
- }) => Promise<{
64
- data: null;
65
- error: {
66
- message: string;
67
- };
68
- } | {
69
- data: {
70
- user: _supabase_auth_js.User;
71
- session: _supabase_auth_js.Session;
72
- weakPassword?: _supabase_auth_js.WeakPassword;
73
- } | {
74
- user: null;
75
- session: null;
76
- weakPassword?: null | undefined;
77
- };
78
- error: _supabase_auth_js.AuthError | null;
79
- }>;
62
+ tenantId: string;
63
+ }) => Promise<any>;
80
64
  forgotPassword: (email: string) => Promise<any>;
81
65
  forgotPasswordSSO: ({ email, with_context, method, }: {
82
66
  email: string;
@@ -832,6 +816,20 @@ declare const serviceFactories: readonly [(env: any) => {
832
816
  url: string | null;
833
817
  error: any;
834
818
  }>;
819
+ }, (env: any) => {
820
+ getListUsers: ({ tenantId }: {
821
+ tenantId: string;
822
+ }) => any;
823
+ }, (env: any) => {
824
+ getListRoles: ({ tenantId }: {
825
+ tenantId: string;
826
+ }) => any;
827
+ }, (env: any) => {
828
+ assignRole: ({ tenantId, userId, roleId, }: {
829
+ tenantId: string;
830
+ userId: string;
831
+ roleId: string;
832
+ }) => any;
835
833
  }];
836
834
  type ServiceFactories = (typeof serviceFactories)[number];
837
835
  type ServiceReturn<T extends ServiceFactories> = ReturnType<T>;
@@ -1,5 +1,4 @@
1
1
  import { C as ContextApi, L as LoginCredentialBody, R as ResetPasswordRequest, U as UpdatePasswordRequest, T as TThreadData, h as GetExternalTab, b as GetListParams, a as GetDetailParams, S as SaveParams, D as DeleteParams, O as OnChangeParams, V as ViewData, f as GetViewParams, c as GetSelectionType } from './view-type-CfcWWR0w.js';
2
- import * as _supabase_auth_js from '@supabase/auth-js';
3
2
 
4
3
  declare function useActionService(): {
5
4
  loadAction: ({ idAction, context, service, xNode, searchParams, }: {
@@ -60,23 +59,8 @@ declare function useAuthService(): {
60
59
  loginTenantUser: (body: {
61
60
  email: string;
62
61
  password: string;
63
- }) => Promise<{
64
- data: null;
65
- error: {
66
- message: string;
67
- };
68
- } | {
69
- data: {
70
- user: _supabase_auth_js.User;
71
- session: _supabase_auth_js.Session;
72
- weakPassword?: _supabase_auth_js.WeakPassword;
73
- } | {
74
- user: null;
75
- session: null;
76
- weakPassword?: null | undefined;
77
- };
78
- error: _supabase_auth_js.AuthError | null;
79
- }>;
62
+ tenantId: string;
63
+ }) => Promise<any>;
80
64
  forgotPassword: (email: string) => Promise<any>;
81
65
  forgotPasswordSSO: ({ email, with_context, method, }: {
82
66
  email: string;
@@ -832,6 +816,20 @@ declare const serviceFactories: readonly [(env: any) => {
832
816
  url: string | null;
833
817
  error: any;
834
818
  }>;
819
+ }, (env: any) => {
820
+ getListUsers: ({ tenantId }: {
821
+ tenantId: string;
822
+ }) => any;
823
+ }, (env: any) => {
824
+ getListRoles: ({ tenantId }: {
825
+ tenantId: string;
826
+ }) => any;
827
+ }, (env: any) => {
828
+ assignRole: ({ tenantId, userId, roleId, }: {
829
+ tenantId: string;
830
+ userId: string;
831
+ roleId: string;
832
+ }) => any;
835
833
  }];
836
834
  type ServiceFactories = (typeof serviceFactories)[number];
837
835
  type ServiceReturn<T extends ServiceFactories> = ReturnType<T>;