@fctc/interface-logic 1.7.3 → 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.
package/dist/hooks.mjs CHANGED
@@ -2405,708 +2405,94 @@ var axiosClient = {
2405
2405
  }
2406
2406
  };
2407
2407
 
2408
- // src/store/index.ts
2409
- import { useDispatch, useSelector } from "react-redux";
2410
-
2411
- // src/store/reducers/breadcrums-slice/index.ts
2412
- import { createSlice } from "@reduxjs/toolkit";
2413
- var initialState = {
2414
- breadCrumbs: []
2415
- };
2416
- var breadcrumbsSlice = createSlice({
2417
- name: "breadcrumbs",
2418
- initialState,
2419
- reducers: {
2420
- setBreadCrumbs: (state, action) => {
2421
- state.breadCrumbs = [...state.breadCrumbs, action.payload];
2422
- }
2423
- }
2424
- });
2425
- var { setBreadCrumbs } = breadcrumbsSlice.actions;
2426
- var breadcrums_slice_default = breadcrumbsSlice.reducer;
2427
-
2428
- // src/store/reducers/env-slice/index.ts
2429
- import { createSlice as createSlice2 } from "@reduxjs/toolkit";
2430
- var initialState2 = {
2431
- baseUrl: "",
2432
- requests: null,
2433
- companies: [],
2434
- user: {},
2435
- config: null,
2436
- envFile: null,
2437
- defaultCompany: {
2438
- id: null,
2439
- logo: "",
2440
- secondary_color: "",
2441
- primary_color: ""
2442
- },
2443
- context: {
2444
- uid: null,
2445
- allowed_company_ids: [],
2446
- lang: "vi_VN",
2447
- tz: "Asia/Saigon"
2448
- }
2449
- };
2450
- var envSlice = createSlice2({
2451
- name: "env",
2452
- initialState: initialState2,
2453
- reducers: {
2454
- setEnv: (state, action) => {
2455
- Object.assign(state, action.payload);
2456
- },
2457
- setUid: (state, action) => {
2458
- state.context.uid = action.payload;
2459
- },
2460
- setAllowCompanies: (state, action) => {
2461
- state.context.allowed_company_ids = action.payload;
2462
- },
2463
- setCompanies: (state, action) => {
2464
- state.companies = action.payload;
2465
- },
2466
- setDefaultCompany: (state, action) => {
2467
- state.defaultCompany = action.payload;
2468
- },
2469
- setLang: (state, action) => {
2470
- state.context.lang = action.payload;
2471
- },
2472
- setUser: (state, action) => {
2473
- state.user = action.payload;
2474
- },
2475
- setConfig: (state, action) => {
2476
- state.config = action.payload;
2477
- },
2478
- setEnvFile: (state, action) => {
2479
- state.envFile = action.payload;
2480
- }
2481
- }
2482
- });
2483
- var {
2484
- setEnv,
2485
- setUid,
2486
- setLang,
2487
- setAllowCompanies,
2488
- setCompanies,
2489
- setDefaultCompany,
2490
- setUser,
2491
- setConfig,
2492
- setEnvFile
2493
- } = envSlice.actions;
2494
- var env_slice_default = envSlice.reducer;
2495
-
2496
- // src/store/reducers/excel-slice/index.ts
2497
- import { createSlice as createSlice3 } from "@reduxjs/toolkit";
2498
- var initialState3 = {
2499
- dataParse: null,
2500
- idFile: null,
2501
- isFileLoaded: false,
2502
- loadingImport: false,
2503
- selectedFile: null,
2504
- errorData: null
2505
- };
2506
- var excelSlice = createSlice3({
2507
- name: "excel",
2508
- initialState: initialState3,
2509
- reducers: {
2510
- setDataParse: (state, action) => {
2511
- state.dataParse = action.payload;
2512
- },
2513
- setIdFile: (state, action) => {
2514
- state.idFile = action.payload;
2515
- },
2516
- setIsFileLoaded: (state, action) => {
2517
- state.isFileLoaded = action.payload;
2518
- },
2519
- setLoadingImport: (state, action) => {
2520
- state.loadingImport = action.payload;
2521
- },
2522
- setSelectedFile: (state, action) => {
2523
- state.selectedFile = action.payload;
2524
- },
2525
- setErrorData: (state, action) => {
2526
- state.errorData = action.payload;
2527
- }
2528
- }
2529
- });
2530
- var {
2531
- setDataParse,
2532
- setIdFile,
2533
- setIsFileLoaded,
2534
- setLoadingImport,
2535
- setSelectedFile,
2536
- setErrorData
2537
- } = excelSlice.actions;
2538
- var excel_slice_default = excelSlice.reducer;
2539
-
2540
- // src/store/reducers/form-slice/index.ts
2541
- import { createSlice as createSlice4 } from "@reduxjs/toolkit";
2542
- var initialState4 = {
2543
- viewDataStore: {},
2544
- isShowingModalDetail: false,
2545
- isShowModalTranslate: false,
2546
- formSubmitComponent: {},
2547
- fieldTranslation: null,
2548
- listSubject: {},
2549
- dataUser: {}
2550
- };
2551
- var formSlice = createSlice4({
2552
- name: "form",
2553
- initialState: initialState4,
2554
- reducers: {
2555
- setViewDataStore: (state, action) => {
2556
- state.viewDataStore = action.payload;
2557
- },
2558
- setIsShowingModalDetail: (state, action) => {
2559
- state.isShowingModalDetail = action.payload;
2560
- },
2561
- setIsShowModalTranslate: (state, action) => {
2562
- state.isShowModalTranslate = action.payload;
2563
- },
2564
- setFormSubmitComponent: (state, action) => {
2565
- state.formSubmitComponent[action.payload.key] = action.payload.component;
2566
- },
2567
- setFieldTranslate: (state, action) => {
2568
- state.fieldTranslation = action.payload;
2569
- },
2570
- setListSubject: (state, action) => {
2571
- state.listSubject = action.payload;
2572
- },
2573
- setDataUser: (state, action) => {
2574
- state.dataUser = action.payload;
2575
- }
2576
- }
2577
- });
2578
- var {
2579
- setViewDataStore,
2580
- setIsShowingModalDetail,
2581
- setIsShowModalTranslate,
2582
- setFormSubmitComponent,
2583
- setFieldTranslate,
2584
- setListSubject,
2585
- setDataUser
2586
- } = formSlice.actions;
2587
- var form_slice_default = formSlice.reducer;
2588
-
2589
- // src/store/reducers/header-slice/index.ts
2590
- import { createSlice as createSlice5 } from "@reduxjs/toolkit";
2591
- var headerSlice = createSlice5({
2592
- name: "header",
2593
- initialState: {
2594
- value: { allowedCompanyIds: [] }
2595
- },
2596
- reducers: {
2597
- setHeader: (state, action) => {
2598
- state.value = { ...state.value, ...action.payload };
2599
- },
2600
- setAllowedCompanyIds: (state, action) => {
2601
- state.value.allowedCompanyIds = action.payload;
2602
- }
2603
- }
2604
- });
2605
- var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
2606
- var header_slice_default = headerSlice.reducer;
2607
-
2608
- // src/store/reducers/list-slice/index.ts
2609
- import { createSlice as createSlice6 } from "@reduxjs/toolkit";
2610
- var initialState5 = {
2611
- pageLimit: 10,
2612
- fields: {},
2613
- order: "",
2614
- selectedRowKeys: [],
2615
- selectedRadioKey: 0,
2616
- indexRowTableModal: -2,
2617
- isUpdateTableModal: false,
2618
- footerGroupTable: {},
2619
- transferDetail: null,
2620
- page: 0,
2621
- domainTable: []
2622
- };
2623
- var listSlice = createSlice6({
2624
- name: "list",
2625
- initialState: initialState5,
2626
- reducers: {
2627
- setPageLimit: (state, action) => {
2628
- state.pageLimit = action.payload;
2629
- },
2630
- setFields: (state, action) => {
2631
- state.fields = action.payload;
2632
- },
2633
- setOrder: (state, action) => {
2634
- state.order = action.payload;
2635
- },
2636
- setSelectedRowKeys: (state, action) => {
2637
- state.selectedRowKeys = action.payload;
2638
- },
2639
- setSelectedRadioKey: (state, action) => {
2640
- state.selectedRadioKey = action.payload;
2641
- },
2642
- setIndexRowTableModal: (state, action) => {
2643
- state.indexRowTableModal = action.payload;
2644
- },
2645
- setTransferDetail: (state, action) => {
2646
- state.transferDetail = action.payload;
2647
- },
2648
- setIsUpdateTableModal: (state, action) => {
2649
- state.isUpdateTableModal = action.payload;
2650
- },
2651
- setPage: (state, action) => {
2652
- state.page = action.payload;
2653
- },
2654
- setDomainTable: (state, action) => {
2655
- state.domainTable = action.payload;
2656
- }
2657
- }
2658
- });
2659
- var {
2660
- setPageLimit,
2661
- setFields,
2662
- setOrder,
2663
- setSelectedRowKeys,
2664
- setIndexRowTableModal,
2665
- setIsUpdateTableModal,
2666
- setPage,
2667
- setSelectedRadioKey,
2668
- setTransferDetail,
2669
- setDomainTable
2670
- } = listSlice.actions;
2671
- var list_slice_default = listSlice.reducer;
2672
-
2673
- // src/store/reducers/login-slice/index.ts
2674
- import { createSlice as createSlice7 } from "@reduxjs/toolkit";
2675
- var initialState6 = {
2676
- db: "",
2677
- redirectTo: "/",
2678
- forgotPasswordUrl: "/"
2679
- };
2680
- var loginSlice = createSlice7({
2681
- name: "login",
2682
- initialState: initialState6,
2683
- reducers: {
2684
- setDb: (state, action) => {
2685
- state.db = action.payload;
2686
- },
2687
- setRedirectTo: (state, action) => {
2688
- state.redirectTo = action.payload;
2689
- },
2690
- setForgotPasswordUrl: (state, action) => {
2691
- state.forgotPasswordUrl = action.payload;
2692
- }
2693
- }
2694
- });
2695
- var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
2696
- var login_slice_default = loginSlice.reducer;
2697
-
2698
- // src/store/reducers/navbar-slice/index.ts
2699
- import { createSlice as createSlice8 } from "@reduxjs/toolkit";
2700
- var initialState7 = {
2701
- menuFocus: {},
2702
- menuAction: {},
2703
- navbarWidth: 250,
2704
- menuList: []
2705
- };
2706
- var navbarSlice = createSlice8({
2707
- name: "navbar",
2708
- initialState: initialState7,
2709
- reducers: {
2710
- setMenuFocus: (state, action) => {
2711
- state.menuFocus = action.payload;
2712
- },
2713
- setMenuFocusAction: (state, action) => {
2714
- state.menuAction = action.payload;
2715
- },
2716
- setNavbarWidth: (state, action) => {
2717
- state.navbarWidth = action.payload;
2718
- },
2719
- setMenuList: (state, action) => {
2720
- state.menuList = action.payload;
2721
- }
2722
- }
2723
- });
2724
- var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
2725
- var navbar_slice_default = navbarSlice.reducer;
2726
-
2727
- // src/store/reducers/profile-slice/index.ts
2728
- import { createSlice as createSlice9 } from "@reduxjs/toolkit";
2729
- var initialState8 = {
2730
- profile: {}
2731
- };
2732
- var profileSlice = createSlice9({
2733
- name: "profile",
2734
- initialState: initialState8,
2735
- reducers: {
2736
- setProfile: (state, action) => {
2737
- state.profile = action.payload;
2738
- }
2739
- }
2740
- });
2741
- var { setProfile } = profileSlice.actions;
2742
- var profile_slice_default = profileSlice.reducer;
2743
-
2744
- // src/store/reducers/search-slice/index.ts
2745
- import { createSlice as createSlice10 } from "@reduxjs/toolkit";
2746
- var initialState9 = {
2747
- groupByDomain: null,
2748
- searchBy: [],
2749
- searchString: "",
2750
- hoveredIndexSearchList: null,
2751
- selectedTags: [],
2752
- firstDomain: null,
2753
- searchMap: {},
2754
- filterBy: [],
2755
- groupBy: []
2756
- };
2757
- var searchSlice = createSlice10({
2758
- name: "search",
2759
- initialState: initialState9,
2760
- reducers: {
2761
- setGroupByDomain: (state, action) => {
2762
- state.groupByDomain = action.payload;
2763
- },
2764
- setSearchBy: (state, action) => {
2765
- state.searchBy = action.payload;
2766
- },
2767
- setSearchString: (state, action) => {
2768
- state.searchString = action.payload;
2769
- },
2770
- setHoveredIndexSearchList: (state, action) => {
2771
- state.hoveredIndexSearchList = action.payload;
2772
- },
2773
- setSelectedTags: (state, action) => {
2774
- state.selectedTags = action.payload;
2775
- },
2776
- setFirstDomain: (state, action) => {
2777
- state.firstDomain = action.payload;
2778
- },
2779
- setFilterBy: (state, action) => {
2780
- state.filterBy = action.payload;
2781
- },
2782
- setGroupBy: (state, action) => {
2783
- state.groupBy = action.payload;
2784
- },
2785
- setSearchMap: (state, action) => {
2786
- state.searchMap = action.payload;
2787
- },
2788
- updateSearchMap: (state, action) => {
2789
- if (!state.searchMap[action.payload.key]) {
2790
- state.searchMap[action.payload.key] = [];
2791
- }
2792
- state.searchMap[action.payload.key].push(action.payload.value);
2793
- },
2794
- removeKeyFromSearchMap: (state, action) => {
2795
- const { key, item } = action.payload;
2796
- const values = state.searchMap[key];
2797
- if (!values) return;
2798
- if (item) {
2799
- const filtered = values.filter((value) => value.name !== item.name);
2800
- if (filtered.length > 0) {
2801
- state.searchMap[key] = filtered;
2802
- } else {
2803
- delete state.searchMap[key];
2804
- }
2805
- } else {
2806
- delete state.searchMap[key];
2807
- }
2808
- },
2809
- clearSearchMap: (state) => {
2810
- state.searchMap = {};
2811
- }
2812
- }
2813
- });
2814
- var {
2815
- setGroupByDomain,
2816
- setSelectedTags,
2817
- setSearchString,
2818
- setHoveredIndexSearchList,
2819
- setFirstDomain,
2820
- setSearchBy,
2821
- setFilterBy,
2822
- setSearchMap,
2823
- updateSearchMap,
2824
- removeKeyFromSearchMap,
2825
- setGroupBy,
2826
- clearSearchMap
2827
- } = searchSlice.actions;
2828
- var search_slice_default = searchSlice.reducer;
2829
-
2830
- // src/store/store.ts
2831
- import { configureStore } from "@reduxjs/toolkit";
2832
-
2833
- // node_modules/redux/dist/redux.mjs
2834
- function formatProdErrorMessage(code) {
2835
- 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. `;
2836
- }
2837
- var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
2838
- var ActionTypes = {
2839
- INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
2840
- REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
2841
- PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
2842
- };
2843
- var actionTypes_default = ActionTypes;
2844
- function isPlainObject(obj) {
2845
- if (typeof obj !== "object" || obj === null)
2846
- return false;
2847
- let proto = obj;
2848
- while (Object.getPrototypeOf(proto) !== null) {
2849
- proto = Object.getPrototypeOf(proto);
2850
- }
2851
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
2852
- }
2853
- function miniKindOf(val) {
2854
- if (val === void 0)
2855
- return "undefined";
2856
- if (val === null)
2857
- return "null";
2858
- const type = typeof val;
2859
- switch (type) {
2860
- case "boolean":
2861
- case "string":
2862
- case "number":
2863
- case "symbol":
2864
- case "function": {
2865
- return type;
2866
- }
2867
- }
2868
- if (Array.isArray(val))
2869
- return "array";
2870
- if (isDate(val))
2871
- return "date";
2872
- if (isError(val))
2873
- return "error";
2874
- const constructorName = ctorName(val);
2875
- switch (constructorName) {
2876
- case "Symbol":
2877
- case "Promise":
2878
- case "WeakMap":
2879
- case "WeakSet":
2880
- case "Map":
2881
- case "Set":
2882
- return constructorName;
2883
- }
2884
- return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
2885
- }
2886
- function ctorName(val) {
2887
- return typeof val.constructor === "function" ? val.constructor.name : null;
2888
- }
2889
- function isError(val) {
2890
- return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
2891
- }
2892
- function isDate(val) {
2893
- if (val instanceof Date)
2894
- return true;
2895
- return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
2896
- }
2897
- function kindOf(val) {
2898
- let typeOfVal = typeof val;
2899
- if (process.env.NODE_ENV !== "production") {
2900
- typeOfVal = miniKindOf(val);
2901
- }
2902
- return typeOfVal;
2903
- }
2904
- function warning(message) {
2905
- if (typeof console !== "undefined" && typeof console.error === "function") {
2906
- console.error(message);
2907
- }
2908
- try {
2909
- throw new Error(message);
2910
- } catch (e) {
2911
- }
2912
- }
2913
- function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
2914
- const reducerKeys = Object.keys(reducers);
2915
- const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
2916
- if (reducerKeys.length === 0) {
2917
- return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
2918
- }
2919
- if (!isPlainObject(inputState)) {
2920
- return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
2921
- }
2922
- const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
2923
- unexpectedKeys.forEach((key) => {
2924
- unexpectedKeyCache[key] = true;
2925
- });
2926
- if (action && action.type === actionTypes_default.REPLACE)
2927
- return;
2928
- if (unexpectedKeys.length > 0) {
2929
- 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.`;
2930
- }
2931
- }
2932
- function assertReducerShape(reducers) {
2933
- Object.keys(reducers).forEach((key) => {
2934
- const reducer = reducers[key];
2935
- const initialState10 = reducer(void 0, {
2936
- type: actionTypes_default.INIT
2937
- });
2938
- if (typeof initialState10 === "undefined") {
2939
- 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.`);
2940
- }
2941
- if (typeof reducer(void 0, {
2942
- type: actionTypes_default.PROBE_UNKNOWN_ACTION()
2943
- }) === "undefined") {
2944
- 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.`);
2945
- }
2946
- });
2947
- }
2948
- function combineReducers(reducers) {
2949
- const reducerKeys = Object.keys(reducers);
2950
- const finalReducers = {};
2951
- for (let i = 0; i < reducerKeys.length; i++) {
2952
- const key = reducerKeys[i];
2953
- if (process.env.NODE_ENV !== "production") {
2954
- if (typeof reducers[key] === "undefined") {
2955
- warning(`No reducer provided for key "${key}"`);
2956
- }
2957
- }
2958
- if (typeof reducers[key] === "function") {
2959
- finalReducers[key] = reducers[key];
2960
- }
2961
- }
2962
- const finalReducerKeys = Object.keys(finalReducers);
2963
- let unexpectedKeyCache;
2964
- if (process.env.NODE_ENV !== "production") {
2965
- unexpectedKeyCache = {};
2966
- }
2967
- let shapeAssertionError;
2968
- try {
2969
- assertReducerShape(finalReducers);
2970
- } catch (e) {
2971
- shapeAssertionError = e;
2972
- }
2973
- return function combination(state = {}, action) {
2974
- if (shapeAssertionError) {
2975
- throw shapeAssertionError;
2976
- }
2977
- if (process.env.NODE_ENV !== "production") {
2978
- const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
2979
- if (warningMessage) {
2980
- warning(warningMessage);
2981
- }
2982
- }
2983
- let hasChanged = false;
2984
- const nextState = {};
2985
- for (let i = 0; i < finalReducerKeys.length; i++) {
2986
- const key = finalReducerKeys[i];
2987
- const reducer = finalReducers[key];
2988
- const previousStateForKey = state[key];
2989
- const nextStateForKey = reducer(previousStateForKey, action);
2990
- if (typeof nextStateForKey === "undefined") {
2991
- const actionType = action && action.type;
2992
- 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.`);
2993
- }
2994
- nextState[key] = nextStateForKey;
2995
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
2996
- }
2997
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
2998
- return hasChanged ? nextState : state;
2999
- };
3000
- }
3001
-
3002
- // src/store/store.ts
3003
- var rootReducer = combineReducers({
3004
- env: env_slice_default,
3005
- header: header_slice_default,
3006
- navbar: navbar_slice_default,
3007
- list: list_slice_default,
3008
- search: search_slice_default,
3009
- form: form_slice_default,
3010
- breadcrumbs: breadcrums_slice_default,
3011
- login: login_slice_default,
3012
- excel: excel_slice_default,
3013
- profile: profile_slice_default
3014
- });
3015
- var envStore = configureStore({
3016
- reducer: rootReducer,
3017
- middleware: (getDefaultMiddleware) => getDefaultMiddleware({
3018
- serializableCheck: false
3019
- })
3020
- });
3021
-
3022
2408
  // src/environment/EnvStore.ts
3023
2409
  var EnvStore = class _EnvStore {
3024
2410
  static instance = null;
3025
- envStore;
3026
- baseUrl;
3027
- requests;
3028
- context;
3029
- defaultCompany;
3030
- config;
3031
- companies;
3032
- user;
3033
- db;
2411
+ state = {};
3034
2412
  localStorageUtils;
3035
2413
  sessionStorageUtils;
3036
- refreshTokenEndpoint;
3037
- constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
3038
- this.envStore = envStore2;
2414
+ constructor(localStorageUtils2, sessionStorageUtils2) {
3039
2415
  this.localStorageUtils = localStorageUtils2;
3040
2416
  this.sessionStorageUtils = sessionStorageUtils2;
3041
- this.setup();
3042
2417
  }
3043
- static getInstance(envStore2, localStorageUtils2, sessionStorageUtils2) {
2418
+ static getInstance(localStorageUtils2, sessionStorageUtils2) {
3044
2419
  if (!_EnvStore.instance) {
3045
- _EnvStore.instance = new _EnvStore(
3046
- envStore2,
3047
- localStorageUtils2,
3048
- sessionStorageUtils2
3049
- );
2420
+ console.log("Creating new EnvStore instance");
2421
+ _EnvStore.instance = new _EnvStore(localStorageUtils2, sessionStorageUtils2);
2422
+ } else {
2423
+ console.log("Returning existing EnvStore instance");
3050
2424
  }
3051
2425
  return _EnvStore.instance;
3052
2426
  }
3053
- setup() {
3054
- const env = this.envStore.getState().env;
3055
- this.baseUrl = env?.baseUrl;
3056
- this.requests = env?.requests;
3057
- this.context = env?.context;
3058
- this.defaultCompany = env?.defaultCompany;
3059
- this.config = env?.config;
3060
- this.companies = env?.companies || [];
3061
- this.user = env?.user;
3062
- this.db = env?.db;
3063
- this.refreshTokenEndpoint = env?.refreshTokenEndpoint;
3064
- console.log("Env setup:", this);
3065
- }
3066
2427
  setupEnv(envConfig) {
3067
- const dispatch = this.envStore.dispatch;
3068
- const env = {
2428
+ this.state = {
2429
+ ...this.state,
3069
2430
  ...envConfig,
3070
2431
  localStorageUtils: this.localStorageUtils,
3071
2432
  sessionStorageUtils: this.sessionStorageUtils
3072
2433
  };
3073
- const requests = axiosClient.init(env);
3074
- dispatch(setEnv({ ...env, requests }));
3075
- this.setup();
2434
+ console.log("Setting up env with config:", envConfig);
2435
+ this.state.requests = axiosClient.init(this.state);
2436
+ console.log("axiosClient.init result:", this.state.requests);
3076
2437
  }
3077
2438
  setUid(uid) {
3078
- const dispatch = this.envStore.dispatch;
3079
- dispatch(setUid(uid));
3080
- this.setup();
2439
+ this.state.uid = uid;
3081
2440
  }
3082
2441
  setLang(lang) {
3083
- const dispatch = this.envStore.dispatch;
3084
- dispatch(setLang(lang));
3085
- this.setup();
2442
+ this.state.lang = lang;
3086
2443
  }
3087
2444
  setAllowCompanies(allowCompanies) {
3088
- const dispatch = this.envStore.dispatch;
3089
- dispatch(setAllowCompanies(allowCompanies));
3090
- this.setup();
2445
+ this.state.allowCompanies = allowCompanies;
3091
2446
  }
3092
2447
  setCompanies(companies) {
3093
- const dispatch = this.envStore.dispatch;
3094
- dispatch(setCompanies(companies));
3095
- this.setup();
2448
+ this.state.companies = companies;
3096
2449
  }
3097
2450
  setDefaultCompany(company) {
3098
- const dispatch = this.envStore.dispatch;
3099
- dispatch(setDefaultCompany(company));
3100
- this.setup();
2451
+ this.state.defaultCompany = company;
3101
2452
  }
3102
2453
  setUserInfo(userInfo) {
3103
- const dispatch = this.envStore.dispatch;
3104
- dispatch(setUser(userInfo));
3105
- this.setup();
2454
+ this.state.user = userInfo;
2455
+ }
2456
+ // Getters để truy cập trạng thái
2457
+ get baseUrl() {
2458
+ return this.state.baseUrl;
2459
+ }
2460
+ get requests() {
2461
+ return this.state.requests;
2462
+ }
2463
+ get context() {
2464
+ return this.state.context;
2465
+ }
2466
+ get defaultCompany() {
2467
+ return this.state.defaultCompany;
2468
+ }
2469
+ get config() {
2470
+ return this.state.config;
2471
+ }
2472
+ get companies() {
2473
+ return this.state.companies;
2474
+ }
2475
+ get user() {
2476
+ return this.state.user;
2477
+ }
2478
+ get db() {
2479
+ return this.state.db;
2480
+ }
2481
+ get refreshTokenEndpoint() {
2482
+ return this.state.refreshTokenEndpoint;
2483
+ }
2484
+ get uid() {
2485
+ return this.state.uid;
2486
+ }
2487
+ get lang() {
2488
+ return this.state.lang;
2489
+ }
2490
+ get allowCompanies() {
2491
+ return this.state.allowCompanies;
3106
2492
  }
3107
2493
  };
3108
2494
  function getEnv() {
3109
- const instance = EnvStore.getInstance(envStore);
2495
+ const instance = EnvStore.getInstance();
3110
2496
  if (!instance) {
3111
2497
  throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
3112
2498
  }