@fctc/interface-logic 1.9.0 → 1.9.2

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