@fctc/interface-logic 1.7.4 → 1.7.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.
@@ -1,631 +1,3 @@
1
- // src/store/index.ts
2
- import { useDispatch, useSelector } from "react-redux";
3
-
4
- // src/store/reducers/breadcrums-slice/index.ts
5
- import { createSlice } from "@reduxjs/toolkit";
6
- var initialState = {
7
- breadCrumbs: []
8
- };
9
- var breadcrumbsSlice = createSlice({
10
- name: "breadcrumbs",
11
- initialState,
12
- reducers: {
13
- setBreadCrumbs: (state, action) => {
14
- state.breadCrumbs = [...state.breadCrumbs, action.payload];
15
- }
16
- }
17
- });
18
- var { setBreadCrumbs } = breadcrumbsSlice.actions;
19
- var breadcrums_slice_default = breadcrumbsSlice.reducer;
20
-
21
- // src/store/reducers/env-slice/index.ts
22
- import { createSlice as createSlice2 } from "@reduxjs/toolkit";
23
- var initialState2 = {
24
- baseUrl: "",
25
- companies: [],
26
- user: {},
27
- db: "",
28
- refreshTokenEndpoint: "",
29
- config: {
30
- grantType: "",
31
- clientId: "",
32
- clientSecret: "",
33
- redirectUri: ""
34
- },
35
- envFile: null,
36
- requests: {
37
- get: async (url, headers) => ({}),
38
- post: async (url, body, headers) => ({}),
39
- post_excel: async (url, body, headers) => ({}),
40
- put: async (url, body, headers) => ({}),
41
- patch: async (url, body) => ({}),
42
- delete: async (url, body) => ({})
43
- },
44
- defaultCompany: {
45
- id: null,
46
- logo: "",
47
- secondary_color: "",
48
- primary_color: ""
49
- },
50
- context: {
51
- uid: null,
52
- allowed_company_ids: [],
53
- lang: "vi_VN",
54
- tz: "Asia/Saigon"
55
- }
56
- };
57
- var envSlice = createSlice2({
58
- name: "env",
59
- initialState: initialState2,
60
- reducers: {
61
- setEnv: (state, action) => {
62
- Object.assign(state, action.payload);
63
- },
64
- setUid: (state, action) => {
65
- state.context.uid = action.payload;
66
- },
67
- setAllowCompanies: (state, action) => {
68
- state.context.allowed_company_ids = action.payload;
69
- },
70
- setCompanies: (state, action) => {
71
- state.companies = action.payload;
72
- },
73
- setDefaultCompany: (state, action) => {
74
- state.defaultCompany = action.payload;
75
- },
76
- setLang: (state, action) => {
77
- state.context.lang = action.payload;
78
- },
79
- setUser: (state, action) => {
80
- state.user = action.payload;
81
- },
82
- setConfig: (state, action) => {
83
- state.config = action.payload;
84
- },
85
- setEnvFile: (state, action) => {
86
- state.envFile = action.payload;
87
- }
88
- }
89
- });
90
- var {
91
- setEnv,
92
- setUid,
93
- setLang,
94
- setAllowCompanies,
95
- setCompanies,
96
- setDefaultCompany,
97
- setUser,
98
- setConfig,
99
- setEnvFile
100
- } = envSlice.actions;
101
- var env_slice_default = envSlice.reducer;
102
-
103
- // src/store/reducers/excel-slice/index.ts
104
- import { createSlice as createSlice3 } from "@reduxjs/toolkit";
105
- var initialState3 = {
106
- dataParse: null,
107
- idFile: null,
108
- isFileLoaded: false,
109
- loadingImport: false,
110
- selectedFile: null,
111
- errorData: null
112
- };
113
- var excelSlice = createSlice3({
114
- name: "excel",
115
- initialState: initialState3,
116
- reducers: {
117
- setDataParse: (state, action) => {
118
- state.dataParse = action.payload;
119
- },
120
- setIdFile: (state, action) => {
121
- state.idFile = action.payload;
122
- },
123
- setIsFileLoaded: (state, action) => {
124
- state.isFileLoaded = action.payload;
125
- },
126
- setLoadingImport: (state, action) => {
127
- state.loadingImport = action.payload;
128
- },
129
- setSelectedFile: (state, action) => {
130
- state.selectedFile = action.payload;
131
- },
132
- setErrorData: (state, action) => {
133
- state.errorData = action.payload;
134
- }
135
- }
136
- });
137
- var {
138
- setDataParse,
139
- setIdFile,
140
- setIsFileLoaded,
141
- setLoadingImport,
142
- setSelectedFile,
143
- setErrorData
144
- } = excelSlice.actions;
145
- var excel_slice_default = excelSlice.reducer;
146
-
147
- // src/store/reducers/form-slice/index.ts
148
- import { createSlice as createSlice4 } from "@reduxjs/toolkit";
149
- var initialState4 = {
150
- viewDataStore: {},
151
- isShowingModalDetail: false,
152
- isShowModalTranslate: false,
153
- formSubmitComponent: {},
154
- fieldTranslation: null,
155
- listSubject: {},
156
- dataUser: {}
157
- };
158
- var formSlice = createSlice4({
159
- name: "form",
160
- initialState: initialState4,
161
- reducers: {
162
- setViewDataStore: (state, action) => {
163
- state.viewDataStore = action.payload;
164
- },
165
- setIsShowingModalDetail: (state, action) => {
166
- state.isShowingModalDetail = action.payload;
167
- },
168
- setIsShowModalTranslate: (state, action) => {
169
- state.isShowModalTranslate = action.payload;
170
- },
171
- setFormSubmitComponent: (state, action) => {
172
- state.formSubmitComponent[action.payload.key] = action.payload.component;
173
- },
174
- setFieldTranslate: (state, action) => {
175
- state.fieldTranslation = action.payload;
176
- },
177
- setListSubject: (state, action) => {
178
- state.listSubject = action.payload;
179
- },
180
- setDataUser: (state, action) => {
181
- state.dataUser = action.payload;
182
- }
183
- }
184
- });
185
- var {
186
- setViewDataStore,
187
- setIsShowingModalDetail,
188
- setIsShowModalTranslate,
189
- setFormSubmitComponent,
190
- setFieldTranslate,
191
- setListSubject,
192
- setDataUser
193
- } = formSlice.actions;
194
- var form_slice_default = formSlice.reducer;
195
-
196
- // src/store/reducers/header-slice/index.ts
197
- import { createSlice as createSlice5 } from "@reduxjs/toolkit";
198
- var headerSlice = createSlice5({
199
- name: "header",
200
- initialState: {
201
- value: { allowedCompanyIds: [] }
202
- },
203
- reducers: {
204
- setHeader: (state, action) => {
205
- state.value = { ...state.value, ...action.payload };
206
- },
207
- setAllowedCompanyIds: (state, action) => {
208
- state.value.allowedCompanyIds = action.payload;
209
- }
210
- }
211
- });
212
- var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
213
- var header_slice_default = headerSlice.reducer;
214
-
215
- // src/store/reducers/list-slice/index.ts
216
- import { createSlice as createSlice6 } from "@reduxjs/toolkit";
217
- var initialState5 = {
218
- pageLimit: 10,
219
- fields: {},
220
- order: "",
221
- selectedRowKeys: [],
222
- selectedRadioKey: 0,
223
- indexRowTableModal: -2,
224
- isUpdateTableModal: false,
225
- footerGroupTable: {},
226
- transferDetail: null,
227
- page: 0,
228
- domainTable: []
229
- };
230
- var listSlice = createSlice6({
231
- name: "list",
232
- initialState: initialState5,
233
- reducers: {
234
- setPageLimit: (state, action) => {
235
- state.pageLimit = action.payload;
236
- },
237
- setFields: (state, action) => {
238
- state.fields = action.payload;
239
- },
240
- setOrder: (state, action) => {
241
- state.order = action.payload;
242
- },
243
- setSelectedRowKeys: (state, action) => {
244
- state.selectedRowKeys = action.payload;
245
- },
246
- setSelectedRadioKey: (state, action) => {
247
- state.selectedRadioKey = action.payload;
248
- },
249
- setIndexRowTableModal: (state, action) => {
250
- state.indexRowTableModal = action.payload;
251
- },
252
- setTransferDetail: (state, action) => {
253
- state.transferDetail = action.payload;
254
- },
255
- setIsUpdateTableModal: (state, action) => {
256
- state.isUpdateTableModal = action.payload;
257
- },
258
- setPage: (state, action) => {
259
- state.page = action.payload;
260
- },
261
- setDomainTable: (state, action) => {
262
- state.domainTable = action.payload;
263
- }
264
- }
265
- });
266
- var {
267
- setPageLimit,
268
- setFields,
269
- setOrder,
270
- setSelectedRowKeys,
271
- setIndexRowTableModal,
272
- setIsUpdateTableModal,
273
- setPage,
274
- setSelectedRadioKey,
275
- setTransferDetail,
276
- setDomainTable
277
- } = listSlice.actions;
278
- var list_slice_default = listSlice.reducer;
279
-
280
- // src/store/reducers/login-slice/index.ts
281
- import { createSlice as createSlice7 } from "@reduxjs/toolkit";
282
- var initialState6 = {
283
- db: "",
284
- redirectTo: "/",
285
- forgotPasswordUrl: "/"
286
- };
287
- var loginSlice = createSlice7({
288
- name: "login",
289
- initialState: initialState6,
290
- reducers: {
291
- setDb: (state, action) => {
292
- state.db = action.payload;
293
- },
294
- setRedirectTo: (state, action) => {
295
- state.redirectTo = action.payload;
296
- },
297
- setForgotPasswordUrl: (state, action) => {
298
- state.forgotPasswordUrl = action.payload;
299
- }
300
- }
301
- });
302
- var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
303
- var login_slice_default = loginSlice.reducer;
304
-
305
- // src/store/reducers/navbar-slice/index.ts
306
- import { createSlice as createSlice8 } from "@reduxjs/toolkit";
307
- var initialState7 = {
308
- menuFocus: {},
309
- menuAction: {},
310
- navbarWidth: 250,
311
- menuList: []
312
- };
313
- var navbarSlice = createSlice8({
314
- name: "navbar",
315
- initialState: initialState7,
316
- reducers: {
317
- setMenuFocus: (state, action) => {
318
- state.menuFocus = action.payload;
319
- },
320
- setMenuFocusAction: (state, action) => {
321
- state.menuAction = action.payload;
322
- },
323
- setNavbarWidth: (state, action) => {
324
- state.navbarWidth = action.payload;
325
- },
326
- setMenuList: (state, action) => {
327
- state.menuList = action.payload;
328
- }
329
- }
330
- });
331
- var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
332
- var navbar_slice_default = navbarSlice.reducer;
333
-
334
- // src/store/reducers/profile-slice/index.ts
335
- import { createSlice as createSlice9 } from "@reduxjs/toolkit";
336
- var initialState8 = {
337
- profile: {}
338
- };
339
- var profileSlice = createSlice9({
340
- name: "profile",
341
- initialState: initialState8,
342
- reducers: {
343
- setProfile: (state, action) => {
344
- state.profile = action.payload;
345
- }
346
- }
347
- });
348
- var { setProfile } = profileSlice.actions;
349
- var profile_slice_default = profileSlice.reducer;
350
-
351
- // src/store/reducers/search-slice/index.ts
352
- import { createSlice as createSlice10 } from "@reduxjs/toolkit";
353
- var initialState9 = {
354
- groupByDomain: null,
355
- searchBy: [],
356
- searchString: "",
357
- hoveredIndexSearchList: null,
358
- selectedTags: [],
359
- firstDomain: null,
360
- searchMap: {},
361
- filterBy: [],
362
- groupBy: []
363
- };
364
- var searchSlice = createSlice10({
365
- name: "search",
366
- initialState: initialState9,
367
- reducers: {
368
- setGroupByDomain: (state, action) => {
369
- state.groupByDomain = action.payload;
370
- },
371
- setSearchBy: (state, action) => {
372
- state.searchBy = action.payload;
373
- },
374
- setSearchString: (state, action) => {
375
- state.searchString = action.payload;
376
- },
377
- setHoveredIndexSearchList: (state, action) => {
378
- state.hoveredIndexSearchList = action.payload;
379
- },
380
- setSelectedTags: (state, action) => {
381
- state.selectedTags = action.payload;
382
- },
383
- setFirstDomain: (state, action) => {
384
- state.firstDomain = action.payload;
385
- },
386
- setFilterBy: (state, action) => {
387
- state.filterBy = action.payload;
388
- },
389
- setGroupBy: (state, action) => {
390
- state.groupBy = action.payload;
391
- },
392
- setSearchMap: (state, action) => {
393
- state.searchMap = action.payload;
394
- },
395
- updateSearchMap: (state, action) => {
396
- if (!state.searchMap[action.payload.key]) {
397
- state.searchMap[action.payload.key] = [];
398
- }
399
- state.searchMap[action.payload.key].push(action.payload.value);
400
- },
401
- removeKeyFromSearchMap: (state, action) => {
402
- const { key, item } = action.payload;
403
- const values = state.searchMap[key];
404
- if (!values) return;
405
- if (item) {
406
- const filtered = values.filter((value) => value.name !== item.name);
407
- if (filtered.length > 0) {
408
- state.searchMap[key] = filtered;
409
- } else {
410
- delete state.searchMap[key];
411
- }
412
- } else {
413
- delete state.searchMap[key];
414
- }
415
- },
416
- clearSearchMap: (state) => {
417
- state.searchMap = {};
418
- }
419
- }
420
- });
421
- var {
422
- setGroupByDomain,
423
- setSelectedTags,
424
- setSearchString,
425
- setHoveredIndexSearchList,
426
- setFirstDomain,
427
- setSearchBy,
428
- setFilterBy,
429
- setSearchMap,
430
- updateSearchMap,
431
- removeKeyFromSearchMap,
432
- setGroupBy,
433
- clearSearchMap
434
- } = searchSlice.actions;
435
- var search_slice_default = searchSlice.reducer;
436
-
437
- // src/store/store.ts
438
- import { configureStore } from "@reduxjs/toolkit";
439
-
440
- // node_modules/redux/dist/redux.mjs
441
- function formatProdErrorMessage(code) {
442
- return `Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
443
- }
444
- var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
445
- var ActionTypes = {
446
- INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
447
- REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
448
- PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
449
- };
450
- var actionTypes_default = ActionTypes;
451
- function isPlainObject(obj) {
452
- if (typeof obj !== "object" || obj === null)
453
- return false;
454
- let proto = obj;
455
- while (Object.getPrototypeOf(proto) !== null) {
456
- proto = Object.getPrototypeOf(proto);
457
- }
458
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
459
- }
460
- function miniKindOf(val) {
461
- if (val === void 0)
462
- return "undefined";
463
- if (val === null)
464
- return "null";
465
- const type = typeof val;
466
- switch (type) {
467
- case "boolean":
468
- case "string":
469
- case "number":
470
- case "symbol":
471
- case "function": {
472
- return type;
473
- }
474
- }
475
- if (Array.isArray(val))
476
- return "array";
477
- if (isDate(val))
478
- return "date";
479
- if (isError(val))
480
- return "error";
481
- const constructorName = ctorName(val);
482
- switch (constructorName) {
483
- case "Symbol":
484
- case "Promise":
485
- case "WeakMap":
486
- case "WeakSet":
487
- case "Map":
488
- case "Set":
489
- return constructorName;
490
- }
491
- return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
492
- }
493
- function ctorName(val) {
494
- return typeof val.constructor === "function" ? val.constructor.name : null;
495
- }
496
- function isError(val) {
497
- return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
498
- }
499
- function isDate(val) {
500
- if (val instanceof Date)
501
- return true;
502
- return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
503
- }
504
- function kindOf(val) {
505
- let typeOfVal = typeof val;
506
- if (process.env.NODE_ENV !== "production") {
507
- typeOfVal = miniKindOf(val);
508
- }
509
- return typeOfVal;
510
- }
511
- function warning(message) {
512
- if (typeof console !== "undefined" && typeof console.error === "function") {
513
- console.error(message);
514
- }
515
- try {
516
- throw new Error(message);
517
- } catch (e) {
518
- }
519
- }
520
- function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
521
- const reducerKeys = Object.keys(reducers);
522
- const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
523
- if (reducerKeys.length === 0) {
524
- return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
525
- }
526
- if (!isPlainObject(inputState)) {
527
- return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
528
- }
529
- const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
530
- unexpectedKeys.forEach((key) => {
531
- unexpectedKeyCache[key] = true;
532
- });
533
- if (action && action.type === actionTypes_default.REPLACE)
534
- return;
535
- if (unexpectedKeys.length > 0) {
536
- return `Unexpected ${unexpectedKeys.length > 1 ? "keys" : "key"} "${unexpectedKeys.join('", "')}" found in ${argumentName}. Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}". Unexpected keys will be ignored.`;
537
- }
538
- }
539
- function assertReducerShape(reducers) {
540
- Object.keys(reducers).forEach((key) => {
541
- const reducer = reducers[key];
542
- const initialState10 = reducer(void 0, {
543
- type: actionTypes_default.INIT
544
- });
545
- if (typeof initialState10 === "undefined") {
546
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
547
- }
548
- if (typeof reducer(void 0, {
549
- type: actionTypes_default.PROBE_UNKNOWN_ACTION()
550
- }) === "undefined") {
551
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : `The slice reducer for key "${key}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`);
552
- }
553
- });
554
- }
555
- function combineReducers(reducers) {
556
- const reducerKeys = Object.keys(reducers);
557
- const finalReducers = {};
558
- for (let i = 0; i < reducerKeys.length; i++) {
559
- const key = reducerKeys[i];
560
- if (process.env.NODE_ENV !== "production") {
561
- if (typeof reducers[key] === "undefined") {
562
- warning(`No reducer provided for key "${key}"`);
563
- }
564
- }
565
- if (typeof reducers[key] === "function") {
566
- finalReducers[key] = reducers[key];
567
- }
568
- }
569
- const finalReducerKeys = Object.keys(finalReducers);
570
- let unexpectedKeyCache;
571
- if (process.env.NODE_ENV !== "production") {
572
- unexpectedKeyCache = {};
573
- }
574
- let shapeAssertionError;
575
- try {
576
- assertReducerShape(finalReducers);
577
- } catch (e) {
578
- shapeAssertionError = e;
579
- }
580
- return function combination(state = {}, action) {
581
- if (shapeAssertionError) {
582
- throw shapeAssertionError;
583
- }
584
- if (process.env.NODE_ENV !== "production") {
585
- const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
586
- if (warningMessage) {
587
- warning(warningMessage);
588
- }
589
- }
590
- let hasChanged = false;
591
- const nextState = {};
592
- for (let i = 0; i < finalReducerKeys.length; i++) {
593
- const key = finalReducerKeys[i];
594
- const reducer = finalReducers[key];
595
- const previousStateForKey = state[key];
596
- const nextStateForKey = reducer(previousStateForKey, action);
597
- if (typeof nextStateForKey === "undefined") {
598
- const actionType = action && action.type;
599
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : `When called with an action of type ${actionType ? `"${String(actionType)}"` : "(unknown type)"}, the slice reducer for key "${key}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`);
600
- }
601
- nextState[key] = nextStateForKey;
602
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
603
- }
604
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
605
- return hasChanged ? nextState : state;
606
- };
607
- }
608
-
609
- // src/store/store.ts
610
- var rootReducer = combineReducers({
611
- env: env_slice_default,
612
- header: header_slice_default,
613
- navbar: navbar_slice_default,
614
- list: list_slice_default,
615
- search: search_slice_default,
616
- form: form_slice_default,
617
- breadcrumbs: breadcrums_slice_default,
618
- login: login_slice_default,
619
- excel: excel_slice_default,
620
- profile: profile_slice_default
621
- });
622
- var envStore = configureStore({
623
- reducer: rootReducer,
624
- middleware: (getDefaultMiddleware) => getDefaultMiddleware({
625
- serializableCheck: false
626
- })
627
- });
628
-
629
1
  // src/configs/axios-client.ts
630
2
  import axios from "axios";
631
3
 
@@ -2821,16 +2193,19 @@ var axiosClient = {
2821
2193
  timeout: 5e4,
2822
2194
  paramsSerializer: (params) => new URLSearchParams(params).toString()
2823
2195
  });
2824
- instance.interceptors.request.use(async (config2) => {
2825
- const { useRefreshToken, useActionToken, actionToken } = config2;
2826
- if (useActionToken && actionToken) {
2827
- config2.headers["Action-Token"] = actionToken;
2196
+ instance.interceptors.request.use(
2197
+ async (config2) => {
2198
+ const useRefreshToken = config2.useRefreshToken;
2199
+ const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
2200
+ if (token) {
2201
+ config2.headers["Authorization"] = "Bearer " + token;
2202
+ }
2203
+ return config2;
2204
+ },
2205
+ (error) => {
2206
+ Promise.reject(error);
2828
2207
  }
2829
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2830
- const token = await getToken?.();
2831
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2832
- return config2;
2833
- }, Promise.reject);
2208
+ );
2834
2209
  instance.interceptors.response.use(
2835
2210
  (response) => {
2836
2211
  return handleResponse(response);
@@ -2971,20 +2346,106 @@ var axiosClient = {
2971
2346
  };
2972
2347
 
2973
2348
  // src/environment/EnvStore.ts
2974
- function setupEnv(envConfig) {
2975
- const requests = axiosClient.init(envConfig);
2976
- envStore.dispatch(
2977
- setEnv({
2349
+ var EnvStore = class _EnvStore {
2350
+ static instance = null;
2351
+ state = {};
2352
+ localStorageUtils;
2353
+ sessionStorageUtils;
2354
+ constructor(localStorageUtils2, sessionStorageUtils2) {
2355
+ this.localStorageUtils = localStorageUtils2;
2356
+ this.sessionStorageUtils = sessionStorageUtils2;
2357
+ }
2358
+ static getInstance(localStorageUtils2, sessionStorageUtils2) {
2359
+ if (!_EnvStore.instance) {
2360
+ console.log("Creating new EnvStore instance");
2361
+ _EnvStore.instance = new _EnvStore(localStorageUtils2, sessionStorageUtils2);
2362
+ } else {
2363
+ console.log("Returning existing EnvStore instance");
2364
+ }
2365
+ return _EnvStore.instance;
2366
+ }
2367
+ setupEnv(envConfig) {
2368
+ this.state = {
2369
+ ...this.state,
2978
2370
  ...envConfig,
2979
- requests
2980
- })
2981
- );
2371
+ localStorageUtils: this.localStorageUtils,
2372
+ sessionStorageUtils: this.sessionStorageUtils
2373
+ };
2374
+ console.log("Setting up env with config:", envConfig);
2375
+ this.state.requests = axiosClient.init(this.state);
2376
+ console.log("axiosClient.init result:", this.state.requests);
2377
+ }
2378
+ setUid(uid) {
2379
+ this.state.uid = uid;
2380
+ }
2381
+ setLang(lang) {
2382
+ this.state.lang = lang;
2383
+ }
2384
+ setAllowCompanies(allowCompanies) {
2385
+ this.state.allowCompanies = allowCompanies;
2386
+ }
2387
+ setCompanies(companies) {
2388
+ this.state.companies = companies;
2389
+ }
2390
+ setDefaultCompany(company) {
2391
+ this.state.defaultCompany = company;
2392
+ }
2393
+ setUserInfo(userInfo) {
2394
+ this.state.user = userInfo;
2395
+ }
2396
+ // Getters để truy cập trạng thái
2397
+ get baseUrl() {
2398
+ return this.state.baseUrl;
2399
+ }
2400
+ get requests() {
2401
+ return this.state.requests;
2402
+ }
2403
+ get context() {
2404
+ return this.state.context;
2405
+ }
2406
+ get defaultCompany() {
2407
+ return this.state.defaultCompany;
2408
+ }
2409
+ get config() {
2410
+ return this.state.config;
2411
+ }
2412
+ get companies() {
2413
+ return this.state.companies;
2414
+ }
2415
+ get user() {
2416
+ return this.state.user;
2417
+ }
2418
+ get db() {
2419
+ return this.state.db;
2420
+ }
2421
+ get refreshTokenEndpoint() {
2422
+ return this.state.refreshTokenEndpoint;
2423
+ }
2424
+ get uid() {
2425
+ return this.state.uid;
2426
+ }
2427
+ get lang() {
2428
+ return this.state.lang;
2429
+ }
2430
+ get allowCompanies() {
2431
+ return this.state.allowCompanies;
2432
+ }
2433
+ };
2434
+ function initEnv({
2435
+ localStorageUtils: localStorageUtils2,
2436
+ sessionStorageUtils: sessionStorageUtils2
2437
+ }) {
2438
+ return EnvStore.getInstance(localStorageUtils2, sessionStorageUtils2);
2982
2439
  }
2983
2440
  function getEnv() {
2984
- console.log("getEnv", envStore.getState().env);
2985
- return envStore.getState().env;
2441
+ const instance = EnvStore.getInstance();
2442
+ if (!instance) {
2443
+ throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
2444
+ }
2445
+ return instance;
2986
2446
  }
2987
2447
  export {
2448
+ EnvStore,
2988
2449
  getEnv,
2989
- setupEnv
2450
+ initEnv
2990
2451
  };