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