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