@fctc/interface-logic 1.7.5 → 1.7.7

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.
@@ -30,12 +30,631 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/environment.ts
31
31
  var environment_exports = {};
32
32
  __export(environment_exports, {
33
- EnvStore: () => EnvStore,
34
33
  getEnv: () => getEnv,
35
- initEnv: () => initEnv
34
+ setupEnv: () => setupEnv
36
35
  });
37
36
  module.exports = __toCommonJS(environment_exports);
38
37
 
38
+ // src/store/index.ts
39
+ var import_react_redux = require("react-redux");
40
+
41
+ // src/store/reducers/breadcrums-slice/index.ts
42
+ var import_toolkit = require("@reduxjs/toolkit");
43
+ var initialState = {
44
+ breadCrumbs: []
45
+ };
46
+ var breadcrumbsSlice = (0, import_toolkit.createSlice)({
47
+ name: "breadcrumbs",
48
+ initialState,
49
+ reducers: {
50
+ setBreadCrumbs: (state, action) => {
51
+ state.breadCrumbs = [...state.breadCrumbs, action.payload];
52
+ }
53
+ }
54
+ });
55
+ var { setBreadCrumbs } = breadcrumbsSlice.actions;
56
+ var breadcrums_slice_default = breadcrumbsSlice.reducer;
57
+
58
+ // src/store/reducers/env-slice/index.ts
59
+ var import_toolkit2 = require("@reduxjs/toolkit");
60
+ var initialState2 = {
61
+ baseUrl: "",
62
+ companies: [],
63
+ user: {},
64
+ db: "",
65
+ refreshTokenEndpoint: "",
66
+ config: {
67
+ grantType: "",
68
+ clientId: "",
69
+ clientSecret: "",
70
+ redirectUri: ""
71
+ },
72
+ envFile: null,
73
+ defaultCompany: {
74
+ id: null,
75
+ logo: "",
76
+ secondary_color: "",
77
+ primary_color: ""
78
+ },
79
+ context: {
80
+ uid: null,
81
+ allowed_company_ids: [],
82
+ lang: "vi_VN",
83
+ tz: "Asia/Saigon"
84
+ }
85
+ };
86
+ var envSlice = (0, import_toolkit2.createSlice)({
87
+ name: "env",
88
+ initialState: initialState2,
89
+ reducers: {
90
+ setEnv: (state, action) => {
91
+ Object.assign(state, action.payload);
92
+ },
93
+ setUid: (state, action) => {
94
+ state.context.uid = action.payload;
95
+ },
96
+ setAllowCompanies: (state, action) => {
97
+ state.context.allowed_company_ids = action.payload;
98
+ },
99
+ setCompanies: (state, action) => {
100
+ state.companies = action.payload;
101
+ },
102
+ setDefaultCompany: (state, action) => {
103
+ state.defaultCompany = action.payload;
104
+ },
105
+ setLang: (state, action) => {
106
+ state.context.lang = action.payload;
107
+ },
108
+ setUser: (state, action) => {
109
+ state.user = action.payload;
110
+ },
111
+ setConfig: (state, action) => {
112
+ state.config = action.payload;
113
+ },
114
+ setEnvFile: (state, action) => {
115
+ state.envFile = action.payload;
116
+ }
117
+ }
118
+ });
119
+ var {
120
+ setEnv,
121
+ setUid,
122
+ setLang,
123
+ setAllowCompanies,
124
+ setCompanies,
125
+ setDefaultCompany,
126
+ setUser,
127
+ setConfig,
128
+ setEnvFile
129
+ } = envSlice.actions;
130
+ var env_slice_default = envSlice.reducer;
131
+
132
+ // src/store/reducers/excel-slice/index.ts
133
+ var import_toolkit3 = require("@reduxjs/toolkit");
134
+ var initialState3 = {
135
+ dataParse: null,
136
+ idFile: null,
137
+ isFileLoaded: false,
138
+ loadingImport: false,
139
+ selectedFile: null,
140
+ errorData: null
141
+ };
142
+ var excelSlice = (0, import_toolkit3.createSlice)({
143
+ name: "excel",
144
+ initialState: initialState3,
145
+ reducers: {
146
+ setDataParse: (state, action) => {
147
+ state.dataParse = action.payload;
148
+ },
149
+ setIdFile: (state, action) => {
150
+ state.idFile = action.payload;
151
+ },
152
+ setIsFileLoaded: (state, action) => {
153
+ state.isFileLoaded = action.payload;
154
+ },
155
+ setLoadingImport: (state, action) => {
156
+ state.loadingImport = action.payload;
157
+ },
158
+ setSelectedFile: (state, action) => {
159
+ state.selectedFile = action.payload;
160
+ },
161
+ setErrorData: (state, action) => {
162
+ state.errorData = action.payload;
163
+ }
164
+ }
165
+ });
166
+ var {
167
+ setDataParse,
168
+ setIdFile,
169
+ setIsFileLoaded,
170
+ setLoadingImport,
171
+ setSelectedFile,
172
+ setErrorData
173
+ } = excelSlice.actions;
174
+ var excel_slice_default = excelSlice.reducer;
175
+
176
+ // src/store/reducers/form-slice/index.ts
177
+ var import_toolkit4 = require("@reduxjs/toolkit");
178
+ var initialState4 = {
179
+ viewDataStore: {},
180
+ isShowingModalDetail: false,
181
+ isShowModalTranslate: false,
182
+ formSubmitComponent: {},
183
+ fieldTranslation: null,
184
+ listSubject: {},
185
+ dataUser: {}
186
+ };
187
+ var formSlice = (0, import_toolkit4.createSlice)({
188
+ name: "form",
189
+ initialState: initialState4,
190
+ reducers: {
191
+ setViewDataStore: (state, action) => {
192
+ state.viewDataStore = action.payload;
193
+ },
194
+ setIsShowingModalDetail: (state, action) => {
195
+ state.isShowingModalDetail = action.payload;
196
+ },
197
+ setIsShowModalTranslate: (state, action) => {
198
+ state.isShowModalTranslate = action.payload;
199
+ },
200
+ setFormSubmitComponent: (state, action) => {
201
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
202
+ },
203
+ setFieldTranslate: (state, action) => {
204
+ state.fieldTranslation = action.payload;
205
+ },
206
+ setListSubject: (state, action) => {
207
+ state.listSubject = action.payload;
208
+ },
209
+ setDataUser: (state, action) => {
210
+ state.dataUser = action.payload;
211
+ }
212
+ }
213
+ });
214
+ var {
215
+ setViewDataStore,
216
+ setIsShowingModalDetail,
217
+ setIsShowModalTranslate,
218
+ setFormSubmitComponent,
219
+ setFieldTranslate,
220
+ setListSubject,
221
+ setDataUser
222
+ } = formSlice.actions;
223
+ var form_slice_default = formSlice.reducer;
224
+
225
+ // src/store/reducers/header-slice/index.ts
226
+ var import_toolkit5 = require("@reduxjs/toolkit");
227
+ var headerSlice = (0, import_toolkit5.createSlice)({
228
+ name: "header",
229
+ initialState: {
230
+ value: { allowedCompanyIds: [] }
231
+ },
232
+ reducers: {
233
+ setHeader: (state, action) => {
234
+ state.value = { ...state.value, ...action.payload };
235
+ },
236
+ setAllowedCompanyIds: (state, action) => {
237
+ state.value.allowedCompanyIds = action.payload;
238
+ }
239
+ }
240
+ });
241
+ var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
242
+ var header_slice_default = headerSlice.reducer;
243
+
244
+ // src/store/reducers/list-slice/index.ts
245
+ var import_toolkit6 = require("@reduxjs/toolkit");
246
+ var initialState5 = {
247
+ pageLimit: 10,
248
+ fields: {},
249
+ order: "",
250
+ selectedRowKeys: [],
251
+ selectedRadioKey: 0,
252
+ indexRowTableModal: -2,
253
+ isUpdateTableModal: false,
254
+ footerGroupTable: {},
255
+ transferDetail: null,
256
+ page: 0,
257
+ domainTable: []
258
+ };
259
+ var listSlice = (0, import_toolkit6.createSlice)({
260
+ name: "list",
261
+ initialState: initialState5,
262
+ reducers: {
263
+ setPageLimit: (state, action) => {
264
+ state.pageLimit = action.payload;
265
+ },
266
+ setFields: (state, action) => {
267
+ state.fields = action.payload;
268
+ },
269
+ setOrder: (state, action) => {
270
+ state.order = action.payload;
271
+ },
272
+ setSelectedRowKeys: (state, action) => {
273
+ state.selectedRowKeys = action.payload;
274
+ },
275
+ setSelectedRadioKey: (state, action) => {
276
+ state.selectedRadioKey = action.payload;
277
+ },
278
+ setIndexRowTableModal: (state, action) => {
279
+ state.indexRowTableModal = action.payload;
280
+ },
281
+ setTransferDetail: (state, action) => {
282
+ state.transferDetail = action.payload;
283
+ },
284
+ setIsUpdateTableModal: (state, action) => {
285
+ state.isUpdateTableModal = action.payload;
286
+ },
287
+ setPage: (state, action) => {
288
+ state.page = action.payload;
289
+ },
290
+ setDomainTable: (state, action) => {
291
+ state.domainTable = action.payload;
292
+ }
293
+ }
294
+ });
295
+ var {
296
+ setPageLimit,
297
+ setFields,
298
+ setOrder,
299
+ setSelectedRowKeys,
300
+ setIndexRowTableModal,
301
+ setIsUpdateTableModal,
302
+ setPage,
303
+ setSelectedRadioKey,
304
+ setTransferDetail,
305
+ setDomainTable
306
+ } = listSlice.actions;
307
+ var list_slice_default = listSlice.reducer;
308
+
309
+ // src/store/reducers/login-slice/index.ts
310
+ var import_toolkit7 = require("@reduxjs/toolkit");
311
+ var initialState6 = {
312
+ db: "",
313
+ redirectTo: "/",
314
+ forgotPasswordUrl: "/"
315
+ };
316
+ var loginSlice = (0, import_toolkit7.createSlice)({
317
+ name: "login",
318
+ initialState: initialState6,
319
+ reducers: {
320
+ setDb: (state, action) => {
321
+ state.db = action.payload;
322
+ },
323
+ setRedirectTo: (state, action) => {
324
+ state.redirectTo = action.payload;
325
+ },
326
+ setForgotPasswordUrl: (state, action) => {
327
+ state.forgotPasswordUrl = action.payload;
328
+ }
329
+ }
330
+ });
331
+ var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
332
+ var login_slice_default = loginSlice.reducer;
333
+
334
+ // src/store/reducers/navbar-slice/index.ts
335
+ var import_toolkit8 = require("@reduxjs/toolkit");
336
+ var initialState7 = {
337
+ menuFocus: {},
338
+ menuAction: {},
339
+ navbarWidth: 250,
340
+ menuList: []
341
+ };
342
+ var navbarSlice = (0, import_toolkit8.createSlice)({
343
+ name: "navbar",
344
+ initialState: initialState7,
345
+ reducers: {
346
+ setMenuFocus: (state, action) => {
347
+ state.menuFocus = action.payload;
348
+ },
349
+ setMenuFocusAction: (state, action) => {
350
+ state.menuAction = action.payload;
351
+ },
352
+ setNavbarWidth: (state, action) => {
353
+ state.navbarWidth = action.payload;
354
+ },
355
+ setMenuList: (state, action) => {
356
+ state.menuList = action.payload;
357
+ }
358
+ }
359
+ });
360
+ var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
361
+ var navbar_slice_default = navbarSlice.reducer;
362
+
363
+ // src/store/reducers/profile-slice/index.ts
364
+ var import_toolkit9 = require("@reduxjs/toolkit");
365
+ var initialState8 = {
366
+ profile: {}
367
+ };
368
+ var profileSlice = (0, import_toolkit9.createSlice)({
369
+ name: "profile",
370
+ initialState: initialState8,
371
+ reducers: {
372
+ setProfile: (state, action) => {
373
+ state.profile = action.payload;
374
+ }
375
+ }
376
+ });
377
+ var { setProfile } = profileSlice.actions;
378
+ var profile_slice_default = profileSlice.reducer;
379
+
380
+ // src/store/reducers/search-slice/index.ts
381
+ var import_toolkit10 = require("@reduxjs/toolkit");
382
+ var initialState9 = {
383
+ groupByDomain: null,
384
+ searchBy: [],
385
+ searchString: "",
386
+ hoveredIndexSearchList: null,
387
+ selectedTags: [],
388
+ firstDomain: null,
389
+ searchMap: {},
390
+ filterBy: [],
391
+ groupBy: []
392
+ };
393
+ var searchSlice = (0, import_toolkit10.createSlice)({
394
+ name: "search",
395
+ initialState: initialState9,
396
+ reducers: {
397
+ setGroupByDomain: (state, action) => {
398
+ state.groupByDomain = action.payload;
399
+ },
400
+ setSearchBy: (state, action) => {
401
+ state.searchBy = action.payload;
402
+ },
403
+ setSearchString: (state, action) => {
404
+ state.searchString = action.payload;
405
+ },
406
+ setHoveredIndexSearchList: (state, action) => {
407
+ state.hoveredIndexSearchList = action.payload;
408
+ },
409
+ setSelectedTags: (state, action) => {
410
+ state.selectedTags = action.payload;
411
+ },
412
+ setFirstDomain: (state, action) => {
413
+ state.firstDomain = action.payload;
414
+ },
415
+ setFilterBy: (state, action) => {
416
+ state.filterBy = action.payload;
417
+ },
418
+ setGroupBy: (state, action) => {
419
+ state.groupBy = action.payload;
420
+ },
421
+ setSearchMap: (state, action) => {
422
+ state.searchMap = action.payload;
423
+ },
424
+ updateSearchMap: (state, action) => {
425
+ if (!state.searchMap[action.payload.key]) {
426
+ state.searchMap[action.payload.key] = [];
427
+ }
428
+ state.searchMap[action.payload.key].push(action.payload.value);
429
+ },
430
+ removeKeyFromSearchMap: (state, action) => {
431
+ const { key, item } = action.payload;
432
+ const values = state.searchMap[key];
433
+ if (!values) return;
434
+ if (item) {
435
+ const filtered = values.filter((value) => value.name !== item.name);
436
+ if (filtered.length > 0) {
437
+ state.searchMap[key] = filtered;
438
+ } else {
439
+ delete state.searchMap[key];
440
+ }
441
+ } else {
442
+ delete state.searchMap[key];
443
+ }
444
+ },
445
+ clearSearchMap: (state) => {
446
+ state.searchMap = {};
447
+ }
448
+ }
449
+ });
450
+ var {
451
+ setGroupByDomain,
452
+ setSelectedTags,
453
+ setSearchString,
454
+ setHoveredIndexSearchList,
455
+ setFirstDomain,
456
+ setSearchBy,
457
+ setFilterBy,
458
+ setSearchMap,
459
+ updateSearchMap,
460
+ removeKeyFromSearchMap,
461
+ setGroupBy,
462
+ clearSearchMap
463
+ } = searchSlice.actions;
464
+ var search_slice_default = searchSlice.reducer;
465
+
466
+ // src/store/store.ts
467
+ var import_toolkit11 = require("@reduxjs/toolkit");
468
+
469
+ // node_modules/redux/dist/redux.mjs
470
+ function formatProdErrorMessage(code) {
471
+ 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. `;
472
+ }
473
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
474
+ var ActionTypes = {
475
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
476
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
477
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
478
+ };
479
+ var actionTypes_default = ActionTypes;
480
+ function isPlainObject(obj) {
481
+ if (typeof obj !== "object" || obj === null)
482
+ return false;
483
+ let proto = obj;
484
+ while (Object.getPrototypeOf(proto) !== null) {
485
+ proto = Object.getPrototypeOf(proto);
486
+ }
487
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
488
+ }
489
+ function miniKindOf(val) {
490
+ if (val === void 0)
491
+ return "undefined";
492
+ if (val === null)
493
+ return "null";
494
+ const type = typeof val;
495
+ switch (type) {
496
+ case "boolean":
497
+ case "string":
498
+ case "number":
499
+ case "symbol":
500
+ case "function": {
501
+ return type;
502
+ }
503
+ }
504
+ if (Array.isArray(val))
505
+ return "array";
506
+ if (isDate(val))
507
+ return "date";
508
+ if (isError(val))
509
+ return "error";
510
+ const constructorName = ctorName(val);
511
+ switch (constructorName) {
512
+ case "Symbol":
513
+ case "Promise":
514
+ case "WeakMap":
515
+ case "WeakSet":
516
+ case "Map":
517
+ case "Set":
518
+ return constructorName;
519
+ }
520
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
521
+ }
522
+ function ctorName(val) {
523
+ return typeof val.constructor === "function" ? val.constructor.name : null;
524
+ }
525
+ function isError(val) {
526
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
527
+ }
528
+ function isDate(val) {
529
+ if (val instanceof Date)
530
+ return true;
531
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
532
+ }
533
+ function kindOf(val) {
534
+ let typeOfVal = typeof val;
535
+ if (process.env.NODE_ENV !== "production") {
536
+ typeOfVal = miniKindOf(val);
537
+ }
538
+ return typeOfVal;
539
+ }
540
+ function warning(message) {
541
+ if (typeof console !== "undefined" && typeof console.error === "function") {
542
+ console.error(message);
543
+ }
544
+ try {
545
+ throw new Error(message);
546
+ } catch (e) {
547
+ }
548
+ }
549
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
550
+ const reducerKeys = Object.keys(reducers);
551
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
552
+ if (reducerKeys.length === 0) {
553
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
554
+ }
555
+ if (!isPlainObject(inputState)) {
556
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
557
+ }
558
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
559
+ unexpectedKeys.forEach((key) => {
560
+ unexpectedKeyCache[key] = true;
561
+ });
562
+ if (action && action.type === actionTypes_default.REPLACE)
563
+ return;
564
+ if (unexpectedKeys.length > 0) {
565
+ 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.`;
566
+ }
567
+ }
568
+ function assertReducerShape(reducers) {
569
+ Object.keys(reducers).forEach((key) => {
570
+ const reducer = reducers[key];
571
+ const initialState10 = reducer(void 0, {
572
+ type: actionTypes_default.INIT
573
+ });
574
+ if (typeof initialState10 === "undefined") {
575
+ 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.`);
576
+ }
577
+ if (typeof reducer(void 0, {
578
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
579
+ }) === "undefined") {
580
+ 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.`);
581
+ }
582
+ });
583
+ }
584
+ function combineReducers(reducers) {
585
+ const reducerKeys = Object.keys(reducers);
586
+ const finalReducers = {};
587
+ for (let i = 0; i < reducerKeys.length; i++) {
588
+ const key = reducerKeys[i];
589
+ if (process.env.NODE_ENV !== "production") {
590
+ if (typeof reducers[key] === "undefined") {
591
+ warning(`No reducer provided for key "${key}"`);
592
+ }
593
+ }
594
+ if (typeof reducers[key] === "function") {
595
+ finalReducers[key] = reducers[key];
596
+ }
597
+ }
598
+ const finalReducerKeys = Object.keys(finalReducers);
599
+ let unexpectedKeyCache;
600
+ if (process.env.NODE_ENV !== "production") {
601
+ unexpectedKeyCache = {};
602
+ }
603
+ let shapeAssertionError;
604
+ try {
605
+ assertReducerShape(finalReducers);
606
+ } catch (e) {
607
+ shapeAssertionError = e;
608
+ }
609
+ return function combination(state = {}, action) {
610
+ if (shapeAssertionError) {
611
+ throw shapeAssertionError;
612
+ }
613
+ if (process.env.NODE_ENV !== "production") {
614
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
615
+ if (warningMessage) {
616
+ warning(warningMessage);
617
+ }
618
+ }
619
+ let hasChanged = false;
620
+ const nextState = {};
621
+ for (let i = 0; i < finalReducerKeys.length; i++) {
622
+ const key = finalReducerKeys[i];
623
+ const reducer = finalReducers[key];
624
+ const previousStateForKey = state[key];
625
+ const nextStateForKey = reducer(previousStateForKey, action);
626
+ if (typeof nextStateForKey === "undefined") {
627
+ const actionType = action && action.type;
628
+ 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.`);
629
+ }
630
+ nextState[key] = nextStateForKey;
631
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
632
+ }
633
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
634
+ return hasChanged ? nextState : state;
635
+ };
636
+ }
637
+
638
+ // src/store/store.ts
639
+ var rootReducer = combineReducers({
640
+ env: env_slice_default,
641
+ header: header_slice_default,
642
+ navbar: navbar_slice_default,
643
+ list: list_slice_default,
644
+ search: search_slice_default,
645
+ form: form_slice_default,
646
+ breadcrumbs: breadcrums_slice_default,
647
+ login: login_slice_default,
648
+ excel: excel_slice_default,
649
+ profile: profile_slice_default
650
+ });
651
+ var envStore = (0, import_toolkit11.configureStore)({
652
+ reducer: rootReducer,
653
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
654
+ serializableCheck: false
655
+ })
656
+ });
657
+
39
658
  // src/configs/axios-client.ts
40
659
  var import_axios = __toESM(require("axios"));
41
660
 
@@ -2231,19 +2850,16 @@ var axiosClient = {
2231
2850
  timeout: 5e4,
2232
2851
  paramsSerializer: (params) => new URLSearchParams(params).toString()
2233
2852
  });
2234
- instance.interceptors.request.use(
2235
- async (config2) => {
2236
- const useRefreshToken = config2.useRefreshToken;
2237
- const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
2238
- if (token) {
2239
- config2.headers["Authorization"] = "Bearer " + token;
2240
- }
2241
- return config2;
2242
- },
2243
- (error) => {
2244
- Promise.reject(error);
2853
+ instance.interceptors.request.use(async (config2) => {
2854
+ const { useRefreshToken, useActionToken, actionToken } = config2;
2855
+ if (useActionToken && actionToken) {
2856
+ config2.headers["Action-Token"] = actionToken;
2245
2857
  }
2246
- );
2858
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2859
+ const token = await getToken?.();
2860
+ if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2861
+ return config2;
2862
+ }, Promise.reject);
2247
2863
  instance.interceptors.response.use(
2248
2864
  (response) => {
2249
2865
  return handleResponse(response);
@@ -2365,7 +2981,7 @@ var axiosClient = {
2365
2981
  return url + (db2 ? "?db=" + db2 : "");
2366
2982
  }
2367
2983
  const responseBody = (response) => response;
2368
- const requests = {
2984
+ const requests2 = {
2369
2985
  get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2370
2986
  post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2371
2987
  post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
@@ -2379,112 +2995,30 @@ var axiosClient = {
2379
2995
  patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2380
2996
  delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2381
2997
  };
2382
- return requests;
2998
+ return requests2;
2383
2999
  }
2384
3000
  };
2385
3001
 
2386
3002
  // src/environment/EnvStore.ts
2387
- var EnvStore = class _EnvStore {
2388
- static instance = null;
2389
- state = {};
2390
- localStorageUtils;
2391
- sessionStorageUtils;
2392
- constructor(localStorageUtils2, sessionStorageUtils2) {
2393
- this.localStorageUtils = localStorageUtils2;
2394
- this.sessionStorageUtils = sessionStorageUtils2;
2395
- }
2396
- static getInstance(localStorageUtils2, sessionStorageUtils2) {
2397
- if (!_EnvStore.instance) {
2398
- console.log("Creating new EnvStore instance");
2399
- _EnvStore.instance = new _EnvStore(localStorageUtils2, sessionStorageUtils2);
2400
- } else {
2401
- console.log("Returning existing EnvStore instance");
2402
- }
2403
- return _EnvStore.instance;
2404
- }
2405
- setupEnv(envConfig) {
2406
- this.state = {
2407
- ...this.state,
2408
- ...envConfig,
2409
- localStorageUtils: this.localStorageUtils,
2410
- sessionStorageUtils: this.sessionStorageUtils
2411
- };
2412
- console.log("Setting up env with config:", envConfig);
2413
- this.state.requests = axiosClient.init(this.state);
2414
- console.log("axiosClient.init result:", this.state.requests);
2415
- }
2416
- setUid(uid) {
2417
- this.state.uid = uid;
2418
- }
2419
- setLang(lang) {
2420
- this.state.lang = lang;
2421
- }
2422
- setAllowCompanies(allowCompanies) {
2423
- this.state.allowCompanies = allowCompanies;
2424
- }
2425
- setCompanies(companies) {
2426
- this.state.companies = companies;
2427
- }
2428
- setDefaultCompany(company) {
2429
- this.state.defaultCompany = company;
2430
- }
2431
- setUserInfo(userInfo) {
2432
- this.state.user = userInfo;
2433
- }
2434
- // Getters để truy cập trạng thái
2435
- get baseUrl() {
2436
- return this.state.baseUrl;
2437
- }
2438
- get requests() {
2439
- return this.state.requests;
2440
- }
2441
- get context() {
2442
- return this.state.context;
2443
- }
2444
- get defaultCompany() {
2445
- return this.state.defaultCompany;
2446
- }
2447
- get config() {
2448
- return this.state.config;
2449
- }
2450
- get companies() {
2451
- return this.state.companies;
2452
- }
2453
- get user() {
2454
- return this.state.user;
2455
- }
2456
- get db() {
2457
- return this.state.db;
2458
- }
2459
- get refreshTokenEndpoint() {
2460
- return this.state.refreshTokenEndpoint;
2461
- }
2462
- get uid() {
2463
- return this.state.uid;
2464
- }
2465
- get lang() {
2466
- return this.state.lang;
2467
- }
2468
- get allowCompanies() {
2469
- return this.state.allowCompanies;
2470
- }
3003
+ var requests = {
3004
+ get: async (url, headers) => ({}),
3005
+ post: async (url, body, headers) => ({}),
3006
+ post_excel: async (url, body, headers) => ({}),
3007
+ put: async (url, body, headers) => ({}),
3008
+ patch: async (url, body) => ({}),
3009
+ delete: async (url, body) => ({})
2471
3010
  };
2472
- function initEnv({
2473
- localStorageUtils: localStorageUtils2,
2474
- sessionStorageUtils: sessionStorageUtils2
2475
- }) {
2476
- return EnvStore.getInstance(localStorageUtils2, sessionStorageUtils2);
3011
+ function setupEnv(envConfig) {
3012
+ requests = axiosClient.init(envConfig);
3013
+ envStore.dispatch(setEnv(envConfig));
3014
+ return { ...envConfig, requests };
2477
3015
  }
2478
3016
  function getEnv() {
2479
- const instance = EnvStore.getInstance();
2480
- if (!instance) {
2481
- throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
2482
- }
2483
- return instance;
3017
+ const env = envStore.getState().env;
3018
+ return { ...env, requests };
2484
3019
  }
2485
3020
  // Annotate the CommonJS export names for ESM import in node:
2486
3021
  0 && (module.exports = {
2487
- EnvStore,
2488
3022
  getEnv,
2489
- initEnv
3023
+ setupEnv
2490
3024
  });