@fctc/interface-logic 1.9.9 → 1.10.0

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/hooks.js CHANGED
@@ -4869,12 +4869,33 @@ var import_jsx_runtime4 = require("react/jsx-runtime");
4869
4869
  // src/provider/env-provider.tsx
4870
4870
  var import_react4 = require("react");
4871
4871
  var import_jsx_runtime5 = require("react/jsx-runtime");
4872
+ var initialEnvState = {
4873
+ env: null,
4874
+ baseUrl: "",
4875
+ requests: null,
4876
+ companies: [],
4877
+ user: {},
4878
+ config: null,
4879
+ envFile: null,
4880
+ defaultCompany: {
4881
+ id: null,
4882
+ logo: "",
4883
+ secondary_color: "",
4884
+ primary_color: ""
4885
+ },
4886
+ context: {
4887
+ uid: null,
4888
+ allowed_company_ids: [],
4889
+ lang: "vi_VN",
4890
+ tz: "Asia/Saigon"
4891
+ }
4892
+ };
4872
4893
  var EnvContext = (0, import_react4.createContext)(null);
4873
4894
  function useEnv() {
4874
4895
  const context = (0, import_react4.useContext)(EnvContext);
4875
4896
  console.log("useEnv context:", context, new Error().stack);
4876
4897
  if (!context) {
4877
- throw new Error("useEnv must be used within an EnvProvider");
4898
+ return initialEnvState;
4878
4899
  }
4879
4900
  return context;
4880
4901
  }
@@ -4887,6 +4908,7 @@ var EnvShareContext = (0, import_react5.createContext)(null);
4887
4908
  // src/services/auth-service/backup.ts
4888
4909
  function useAuthService() {
4889
4910
  const { env: env2 } = useEnv();
4911
+ console.log("auth env", env2);
4890
4912
  const login = (0, import_react6.useCallback)(
4891
4913
  async (body) => {
4892
4914
  const payload = Object.fromEntries(
@@ -5104,7 +5126,8 @@ function useAuthService() {
5104
5126
 
5105
5127
  // src/hooks/auth/use-login-credential.tsx
5106
5128
  var useLoginCredential = () => {
5107
- console.log("useLoginCredential called", new Error().stack);
5129
+ const { env: env2 } = useEnv();
5130
+ console.log("useLoginCredential called", env2, new Error().stack);
5108
5131
  const { login } = useAuthService();
5109
5132
  return (0, import_react_query7.useMutation)({
5110
5133
  mutationFn: (data) => {
package/dist/hooks.mjs CHANGED
@@ -4765,12 +4765,33 @@ import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
4765
4765
  // src/provider/env-provider.tsx
4766
4766
  import { createContext, useContext, useState as useState3, useCallback as useCallback2 } from "react";
4767
4767
  import { jsx as jsx5 } from "react/jsx-runtime";
4768
+ var initialEnvState = {
4769
+ env: null,
4770
+ baseUrl: "",
4771
+ requests: null,
4772
+ companies: [],
4773
+ user: {},
4774
+ config: null,
4775
+ envFile: null,
4776
+ defaultCompany: {
4777
+ id: null,
4778
+ logo: "",
4779
+ secondary_color: "",
4780
+ primary_color: ""
4781
+ },
4782
+ context: {
4783
+ uid: null,
4784
+ allowed_company_ids: [],
4785
+ lang: "vi_VN",
4786
+ tz: "Asia/Saigon"
4787
+ }
4788
+ };
4768
4789
  var EnvContext = createContext(null);
4769
4790
  function useEnv() {
4770
4791
  const context = useContext(EnvContext);
4771
4792
  console.log("useEnv context:", context, new Error().stack);
4772
4793
  if (!context) {
4773
- throw new Error("useEnv must be used within an EnvProvider");
4794
+ return initialEnvState;
4774
4795
  }
4775
4796
  return context;
4776
4797
  }
@@ -4783,6 +4804,7 @@ var EnvShareContext = createContext2(null);
4783
4804
  // src/services/auth-service/backup.ts
4784
4805
  function useAuthService() {
4785
4806
  const { env: env2 } = useEnv();
4807
+ console.log("auth env", env2);
4786
4808
  const login = useCallback3(
4787
4809
  async (body) => {
4788
4810
  const payload = Object.fromEntries(
@@ -5000,7 +5022,8 @@ function useAuthService() {
5000
5022
 
5001
5023
  // src/hooks/auth/use-login-credential.tsx
5002
5024
  var useLoginCredential = () => {
5003
- console.log("useLoginCredential called", new Error().stack);
5025
+ const { env: env2 } = useEnv();
5026
+ console.log("useLoginCredential called", env2, new Error().stack);
5004
5027
  const { login } = useAuthService();
5005
5028
  return useMutation5({
5006
5029
  mutationFn: (data) => {
@@ -15,6 +15,7 @@ declare const VersionGate: ({ children }: {
15
15
  }) => react_jsx_runtime.JSX.Element | null;
16
16
 
17
17
  interface EnvConfig {
18
+ env?: any;
18
19
  baseUrl?: string;
19
20
  requests?: any;
20
21
  context?: {
@@ -43,7 +44,7 @@ declare function EnvProvider({ children, localStorageUtils: localStorageUtil, se
43
44
  localStorageUtils?: LocalStorageUtilsType;
44
45
  sessionStorageUtils?: SessionStorageUtilsType;
45
46
  }): react_jsx_runtime.JSX.Element;
46
- declare function useEnv(): {
47
+ declare function useEnv(): EnvConfig | {
47
48
  env: EnvConfig;
48
49
  setupEnv: (envConfig: Partial<EnvConfig>) => EnvConfig;
49
50
  setUid: (uid: number) => void;
@@ -15,6 +15,7 @@ declare const VersionGate: ({ children }: {
15
15
  }) => react_jsx_runtime.JSX.Element | null;
16
16
 
17
17
  interface EnvConfig {
18
+ env?: any;
18
19
  baseUrl?: string;
19
20
  requests?: any;
20
21
  context?: {
@@ -43,7 +44,7 @@ declare function EnvProvider({ children, localStorageUtils: localStorageUtil, se
43
44
  localStorageUtils?: LocalStorageUtilsType;
44
45
  sessionStorageUtils?: SessionStorageUtilsType;
45
46
  }): react_jsx_runtime.JSX.Element;
46
- declare function useEnv(): {
47
+ declare function useEnv(): EnvConfig | {
47
48
  env: EnvConfig;
48
49
  setupEnv: (envConfig: Partial<EnvConfig>) => EnvConfig;
49
50
  setUid: (uid: number) => void;
package/dist/provider.js CHANGED
@@ -3331,6 +3331,7 @@ var axiosClient = {
3331
3331
  // src/provider/env-provider.tsx
3332
3332
  var import_jsx_runtime5 = require("react/jsx-runtime");
3333
3333
  var initialEnvState = {
3334
+ env: null,
3334
3335
  baseUrl: "",
3335
3336
  requests: null,
3336
3337
  companies: [],
@@ -3449,7 +3450,7 @@ function useEnv() {
3449
3450
  const context = (0, import_react4.useContext)(EnvContext);
3450
3451
  console.log("useEnv context:", context, new Error().stack);
3451
3452
  if (!context) {
3452
- throw new Error("useEnv must be used within an EnvProvider");
3453
+ return initialEnvState;
3453
3454
  }
3454
3455
  return context;
3455
3456
  }
package/dist/provider.mjs CHANGED
@@ -3289,6 +3289,7 @@ var axiosClient = {
3289
3289
  // src/provider/env-provider.tsx
3290
3290
  import { jsx as jsx5 } from "react/jsx-runtime";
3291
3291
  var initialEnvState = {
3292
+ env: null,
3292
3293
  baseUrl: "",
3293
3294
  requests: null,
3294
3295
  companies: [],
@@ -3407,7 +3408,7 @@ function useEnv() {
3407
3408
  const context = useContext(EnvContext);
3408
3409
  console.log("useEnv context:", context, new Error().stack);
3409
3410
  if (!context) {
3410
- throw new Error("useEnv must be used within an EnvProvider");
3411
+ return initialEnvState;
3411
3412
  }
3412
3413
  return context;
3413
3414
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fctc/interface-logic",
3
- "version": "1.9.9",
3
+ "version": "1.10.0",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",