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