@fctc/interface-logic 1.7.5 → 1.7.6

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.js CHANGED
@@ -3037,91 +3037,93 @@ var axiosClient = {
3037
3037
  // src/environment/EnvStore.ts
3038
3038
  var EnvStore = class _EnvStore {
3039
3039
  static instance = null;
3040
- state = {};
3040
+ envStore;
3041
+ baseUrl;
3042
+ requests;
3043
+ context;
3044
+ defaultCompany;
3045
+ config;
3046
+ companies;
3047
+ user;
3048
+ db;
3041
3049
  localStorageUtils;
3042
3050
  sessionStorageUtils;
3043
- constructor(localStorageUtils2, sessionStorageUtils2) {
3051
+ refreshTokenEndpoint;
3052
+ constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
3053
+ this.envStore = envStore2;
3044
3054
  this.localStorageUtils = localStorageUtils2;
3045
3055
  this.sessionStorageUtils = sessionStorageUtils2;
3056
+ this.setup();
3046
3057
  }
3047
- static getInstance(localStorageUtils2, sessionStorageUtils2) {
3058
+ static getInstance(envStore2, localStorageUtils2, sessionStorageUtils2) {
3048
3059
  if (!_EnvStore.instance) {
3049
3060
  console.log("Creating new EnvStore instance");
3050
- _EnvStore.instance = new _EnvStore(localStorageUtils2, sessionStorageUtils2);
3061
+ _EnvStore.instance = new _EnvStore(envStore2, localStorageUtils2, sessionStorageUtils2);
3051
3062
  } else {
3052
3063
  console.log("Returning existing EnvStore instance");
3053
3064
  }
3054
3065
  return _EnvStore.instance;
3055
3066
  }
3067
+ setup() {
3068
+ const env = this.envStore.getState().env;
3069
+ console.log("Redux env state in A1:", env);
3070
+ this.baseUrl = env?.baseUrl;
3071
+ this.requests = env?.requests;
3072
+ this.context = env?.context;
3073
+ this.defaultCompany = env?.defaultCompany;
3074
+ this.config = env?.config;
3075
+ this.companies = env?.companies || [];
3076
+ this.user = env?.user;
3077
+ this.db = env?.db;
3078
+ this.refreshTokenEndpoint = env?.refreshTokenEndpoint;
3079
+ console.log("Env setup in A1:", this);
3080
+ }
3056
3081
  setupEnv(envConfig) {
3057
- this.state = {
3058
- ...this.state,
3082
+ const dispatch = this.envStore.dispatch;
3083
+ const env = {
3059
3084
  ...envConfig,
3060
3085
  localStorageUtils: this.localStorageUtils,
3061
3086
  sessionStorageUtils: this.sessionStorageUtils
3062
3087
  };
3063
3088
  console.log("Setting up env with config:", envConfig);
3064
- this.state.requests = axiosClient.init(this.state);
3065
- console.log("axiosClient.init result:", this.state.requests);
3089
+ const requests = axiosClient.init(env);
3090
+ console.log("axiosClient.init result:", requests);
3091
+ dispatch(setEnv({ ...env, requests }));
3092
+ this.setup();
3066
3093
  }
3067
3094
  setUid(uid) {
3068
- this.state.uid = uid;
3095
+ const dispatch = this.envStore.dispatch;
3096
+ dispatch(setUid(uid));
3097
+ this.setup();
3069
3098
  }
3070
3099
  setLang(lang) {
3071
- this.state.lang = lang;
3100
+ const dispatch = this.envStore.dispatch;
3101
+ dispatch(setLang(lang));
3102
+ this.setup();
3072
3103
  }
3073
3104
  setAllowCompanies(allowCompanies) {
3074
- this.state.allowCompanies = allowCompanies;
3105
+ const dispatch = this.envStore.dispatch;
3106
+ dispatch(setAllowCompanies(allowCompanies));
3107
+ this.setup();
3075
3108
  }
3076
3109
  setCompanies(companies) {
3077
- this.state.companies = companies;
3110
+ const dispatch = this.envStore.dispatch;
3111
+ dispatch(setCompanies(companies));
3112
+ this.setup();
3078
3113
  }
3079
3114
  setDefaultCompany(company) {
3080
- this.state.defaultCompany = company;
3115
+ const dispatch = this.envStore.dispatch;
3116
+ dispatch(setDefaultCompany(company));
3117
+ this.setup();
3081
3118
  }
3082
3119
  setUserInfo(userInfo) {
3083
- this.state.user = userInfo;
3084
- }
3085
- // Getters để truy cập trạng thái
3086
- get baseUrl() {
3087
- return this.state.baseUrl;
3088
- }
3089
- get requests() {
3090
- return this.state.requests;
3091
- }
3092
- get context() {
3093
- return this.state.context;
3094
- }
3095
- get defaultCompany() {
3096
- return this.state.defaultCompany;
3097
- }
3098
- get config() {
3099
- return this.state.config;
3100
- }
3101
- get companies() {
3102
- return this.state.companies;
3103
- }
3104
- get user() {
3105
- return this.state.user;
3106
- }
3107
- get db() {
3108
- return this.state.db;
3109
- }
3110
- get refreshTokenEndpoint() {
3111
- return this.state.refreshTokenEndpoint;
3112
- }
3113
- get uid() {
3114
- return this.state.uid;
3115
- }
3116
- get lang() {
3117
- return this.state.lang;
3118
- }
3119
- get allowCompanies() {
3120
- return this.state.allowCompanies;
3120
+ const dispatch = this.envStore.dispatch;
3121
+ dispatch(setUser(userInfo));
3122
+ this.setup();
3121
3123
  }
3122
3124
  };
3123
3125
  function getEnv() {
3124
- const instance = EnvStore.getInstance();
3126
+ const instance = EnvStore.getInstance(envStore);
3125
3127
  if (!instance) {
3126
3128
  throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
3127
3129
  }
package/dist/provider.mjs CHANGED
@@ -2999,91 +2999,93 @@ var axiosClient = {
2999
2999
  // src/environment/EnvStore.ts
3000
3000
  var EnvStore = class _EnvStore {
3001
3001
  static instance = null;
3002
- state = {};
3002
+ envStore;
3003
+ baseUrl;
3004
+ requests;
3005
+ context;
3006
+ defaultCompany;
3007
+ config;
3008
+ companies;
3009
+ user;
3010
+ db;
3003
3011
  localStorageUtils;
3004
3012
  sessionStorageUtils;
3005
- constructor(localStorageUtils2, sessionStorageUtils2) {
3013
+ refreshTokenEndpoint;
3014
+ constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
3015
+ this.envStore = envStore2;
3006
3016
  this.localStorageUtils = localStorageUtils2;
3007
3017
  this.sessionStorageUtils = sessionStorageUtils2;
3018
+ this.setup();
3008
3019
  }
3009
- static getInstance(localStorageUtils2, sessionStorageUtils2) {
3020
+ static getInstance(envStore2, localStorageUtils2, sessionStorageUtils2) {
3010
3021
  if (!_EnvStore.instance) {
3011
3022
  console.log("Creating new EnvStore instance");
3012
- _EnvStore.instance = new _EnvStore(localStorageUtils2, sessionStorageUtils2);
3023
+ _EnvStore.instance = new _EnvStore(envStore2, localStorageUtils2, sessionStorageUtils2);
3013
3024
  } else {
3014
3025
  console.log("Returning existing EnvStore instance");
3015
3026
  }
3016
3027
  return _EnvStore.instance;
3017
3028
  }
3029
+ setup() {
3030
+ const env = this.envStore.getState().env;
3031
+ console.log("Redux env state in A1:", env);
3032
+ this.baseUrl = env?.baseUrl;
3033
+ this.requests = env?.requests;
3034
+ this.context = env?.context;
3035
+ this.defaultCompany = env?.defaultCompany;
3036
+ this.config = env?.config;
3037
+ this.companies = env?.companies || [];
3038
+ this.user = env?.user;
3039
+ this.db = env?.db;
3040
+ this.refreshTokenEndpoint = env?.refreshTokenEndpoint;
3041
+ console.log("Env setup in A1:", this);
3042
+ }
3018
3043
  setupEnv(envConfig) {
3019
- this.state = {
3020
- ...this.state,
3044
+ const dispatch = this.envStore.dispatch;
3045
+ const env = {
3021
3046
  ...envConfig,
3022
3047
  localStorageUtils: this.localStorageUtils,
3023
3048
  sessionStorageUtils: this.sessionStorageUtils
3024
3049
  };
3025
3050
  console.log("Setting up env with config:", envConfig);
3026
- this.state.requests = axiosClient.init(this.state);
3027
- console.log("axiosClient.init result:", this.state.requests);
3051
+ const requests = axiosClient.init(env);
3052
+ console.log("axiosClient.init result:", requests);
3053
+ dispatch(setEnv({ ...env, requests }));
3054
+ this.setup();
3028
3055
  }
3029
3056
  setUid(uid) {
3030
- this.state.uid = uid;
3057
+ const dispatch = this.envStore.dispatch;
3058
+ dispatch(setUid(uid));
3059
+ this.setup();
3031
3060
  }
3032
3061
  setLang(lang) {
3033
- this.state.lang = lang;
3062
+ const dispatch = this.envStore.dispatch;
3063
+ dispatch(setLang(lang));
3064
+ this.setup();
3034
3065
  }
3035
3066
  setAllowCompanies(allowCompanies) {
3036
- this.state.allowCompanies = allowCompanies;
3067
+ const dispatch = this.envStore.dispatch;
3068
+ dispatch(setAllowCompanies(allowCompanies));
3069
+ this.setup();
3037
3070
  }
3038
3071
  setCompanies(companies) {
3039
- this.state.companies = companies;
3072
+ const dispatch = this.envStore.dispatch;
3073
+ dispatch(setCompanies(companies));
3074
+ this.setup();
3040
3075
  }
3041
3076
  setDefaultCompany(company) {
3042
- this.state.defaultCompany = company;
3077
+ const dispatch = this.envStore.dispatch;
3078
+ dispatch(setDefaultCompany(company));
3079
+ this.setup();
3043
3080
  }
3044
3081
  setUserInfo(userInfo) {
3045
- this.state.user = userInfo;
3046
- }
3047
- // Getters để truy cập trạng thái
3048
- get baseUrl() {
3049
- return this.state.baseUrl;
3050
- }
3051
- get requests() {
3052
- return this.state.requests;
3053
- }
3054
- get context() {
3055
- return this.state.context;
3056
- }
3057
- get defaultCompany() {
3058
- return this.state.defaultCompany;
3059
- }
3060
- get config() {
3061
- return this.state.config;
3062
- }
3063
- get companies() {
3064
- return this.state.companies;
3065
- }
3066
- get user() {
3067
- return this.state.user;
3068
- }
3069
- get db() {
3070
- return this.state.db;
3071
- }
3072
- get refreshTokenEndpoint() {
3073
- return this.state.refreshTokenEndpoint;
3074
- }
3075
- get uid() {
3076
- return this.state.uid;
3077
- }
3078
- get lang() {
3079
- return this.state.lang;
3080
- }
3081
- get allowCompanies() {
3082
- return this.state.allowCompanies;
3082
+ const dispatch = this.envStore.dispatch;
3083
+ dispatch(setUser(userInfo));
3084
+ this.setup();
3083
3085
  }
3084
3086
  };
3085
3087
  function getEnv() {
3086
- const instance = EnvStore.getInstance();
3088
+ const instance = EnvStore.getInstance(envStore);
3087
3089
  if (!instance) {
3088
3090
  throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
3089
3091
  }