@fctc/interface-logic 1.9.4 → 1.9.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/hooks.mjs CHANGED
@@ -4119,10 +4119,890 @@ var use_isvalid_token_default = useIsValidToken;
4119
4119
 
4120
4120
  // src/hooks/auth/use-login-credential.ts
4121
4121
  import { useMutation as useMutation5 } from "@tanstack/react-query";
4122
+
4123
+ // src/services/auth-service/backup.ts
4124
+ import { useCallback as useCallback3 } from "react";
4125
+
4126
+ // src/provider/react-query-provider.tsx
4127
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4128
+ import { jsx } from "react/jsx-runtime";
4129
+
4130
+ // src/provider/redux-provider.tsx
4131
+ import { Provider } from "react-redux";
4132
+
4133
+ // src/store/index.ts
4134
+ import { useDispatch, useSelector } from "react-redux";
4135
+
4136
+ // src/store/reducers/breadcrums-slice/index.ts
4137
+ import { createSlice } from "@reduxjs/toolkit";
4138
+ var initialState = {
4139
+ breadCrumbs: []
4140
+ };
4141
+ var breadcrumbsSlice = createSlice({
4142
+ name: "breadcrumbs",
4143
+ initialState,
4144
+ reducers: {
4145
+ setBreadCrumbs: (state, action) => {
4146
+ state.breadCrumbs = [...state.breadCrumbs, action.payload];
4147
+ }
4148
+ }
4149
+ });
4150
+ var { setBreadCrumbs } = breadcrumbsSlice.actions;
4151
+ var breadcrums_slice_default = breadcrumbsSlice.reducer;
4152
+
4153
+ // src/store/reducers/env-slice/index.ts
4154
+ import { createSlice as createSlice2 } from "@reduxjs/toolkit";
4155
+ var initialState2 = {
4156
+ baseUrl: "",
4157
+ companies: [],
4158
+ user: {},
4159
+ db: "",
4160
+ refreshTokenEndpoint: "",
4161
+ config: null,
4162
+ envFile: null,
4163
+ requests: null,
4164
+ defaultCompany: {
4165
+ id: null,
4166
+ logo: "",
4167
+ secondary_color: "",
4168
+ primary_color: ""
4169
+ },
4170
+ context: {
4171
+ uid: null,
4172
+ allowed_company_ids: [],
4173
+ lang: "vi_VN",
4174
+ tz: "Asia/Saigon"
4175
+ }
4176
+ };
4177
+ var envSlice = createSlice2({
4178
+ name: "env",
4179
+ initialState: initialState2,
4180
+ reducers: {
4181
+ setEnv: (state, action) => {
4182
+ Object.assign(state, action.payload);
4183
+ },
4184
+ setUid: (state, action) => {
4185
+ state.context.uid = action.payload;
4186
+ },
4187
+ setAllowCompanies: (state, action) => {
4188
+ state.context.allowed_company_ids = action.payload;
4189
+ },
4190
+ setCompanies: (state, action) => {
4191
+ state.companies = action.payload;
4192
+ },
4193
+ setDefaultCompany: (state, action) => {
4194
+ state.defaultCompany = action.payload;
4195
+ },
4196
+ setLang: (state, action) => {
4197
+ state.context.lang = action.payload;
4198
+ },
4199
+ setUser: (state, action) => {
4200
+ state.user = action.payload;
4201
+ },
4202
+ setConfig: (state, action) => {
4203
+ state.config = action.payload;
4204
+ },
4205
+ setEnvFile: (state, action) => {
4206
+ state.envFile = action.payload;
4207
+ }
4208
+ }
4209
+ });
4210
+ var {
4211
+ setEnv,
4212
+ setUid,
4213
+ setLang,
4214
+ setAllowCompanies,
4215
+ setCompanies,
4216
+ setDefaultCompany,
4217
+ setUser,
4218
+ setConfig,
4219
+ setEnvFile
4220
+ } = envSlice.actions;
4221
+ var env_slice_default = envSlice.reducer;
4222
+
4223
+ // src/store/reducers/excel-slice/index.ts
4224
+ import { createSlice as createSlice3 } from "@reduxjs/toolkit";
4225
+ var initialState3 = {
4226
+ dataParse: null,
4227
+ idFile: null,
4228
+ isFileLoaded: false,
4229
+ loadingImport: false,
4230
+ selectedFile: null,
4231
+ errorData: null
4232
+ };
4233
+ var excelSlice = createSlice3({
4234
+ name: "excel",
4235
+ initialState: initialState3,
4236
+ reducers: {
4237
+ setDataParse: (state, action) => {
4238
+ state.dataParse = action.payload;
4239
+ },
4240
+ setIdFile: (state, action) => {
4241
+ state.idFile = action.payload;
4242
+ },
4243
+ setIsFileLoaded: (state, action) => {
4244
+ state.isFileLoaded = action.payload;
4245
+ },
4246
+ setLoadingImport: (state, action) => {
4247
+ state.loadingImport = action.payload;
4248
+ },
4249
+ setSelectedFile: (state, action) => {
4250
+ state.selectedFile = action.payload;
4251
+ },
4252
+ setErrorData: (state, action) => {
4253
+ state.errorData = action.payload;
4254
+ }
4255
+ }
4256
+ });
4257
+ var {
4258
+ setDataParse,
4259
+ setIdFile,
4260
+ setIsFileLoaded,
4261
+ setLoadingImport,
4262
+ setSelectedFile,
4263
+ setErrorData
4264
+ } = excelSlice.actions;
4265
+ var excel_slice_default = excelSlice.reducer;
4266
+
4267
+ // src/store/reducers/form-slice/index.ts
4268
+ import { createSlice as createSlice4 } from "@reduxjs/toolkit";
4269
+ var initialState4 = {
4270
+ viewDataStore: {},
4271
+ isShowingModalDetail: false,
4272
+ isShowModalTranslate: false,
4273
+ formSubmitComponent: {},
4274
+ fieldTranslation: null,
4275
+ listSubject: {},
4276
+ dataUser: {}
4277
+ };
4278
+ var formSlice = createSlice4({
4279
+ name: "form",
4280
+ initialState: initialState4,
4281
+ reducers: {
4282
+ setViewDataStore: (state, action) => {
4283
+ state.viewDataStore = action.payload;
4284
+ },
4285
+ setIsShowingModalDetail: (state, action) => {
4286
+ state.isShowingModalDetail = action.payload;
4287
+ },
4288
+ setIsShowModalTranslate: (state, action) => {
4289
+ state.isShowModalTranslate = action.payload;
4290
+ },
4291
+ setFormSubmitComponent: (state, action) => {
4292
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
4293
+ },
4294
+ setFieldTranslate: (state, action) => {
4295
+ state.fieldTranslation = action.payload;
4296
+ },
4297
+ setListSubject: (state, action) => {
4298
+ state.listSubject = action.payload;
4299
+ },
4300
+ setDataUser: (state, action) => {
4301
+ state.dataUser = action.payload;
4302
+ }
4303
+ }
4304
+ });
4305
+ var {
4306
+ setViewDataStore,
4307
+ setIsShowingModalDetail,
4308
+ setIsShowModalTranslate,
4309
+ setFormSubmitComponent,
4310
+ setFieldTranslate,
4311
+ setListSubject,
4312
+ setDataUser
4313
+ } = formSlice.actions;
4314
+ var form_slice_default = formSlice.reducer;
4315
+
4316
+ // src/store/reducers/header-slice/index.ts
4317
+ import { createSlice as createSlice5 } from "@reduxjs/toolkit";
4318
+ var headerSlice = createSlice5({
4319
+ name: "header",
4320
+ initialState: {
4321
+ value: { allowedCompanyIds: [] }
4322
+ },
4323
+ reducers: {
4324
+ setHeader: (state, action) => {
4325
+ state.value = { ...state.value, ...action.payload };
4326
+ },
4327
+ setAllowedCompanyIds: (state, action) => {
4328
+ state.value.allowedCompanyIds = action.payload;
4329
+ }
4330
+ }
4331
+ });
4332
+ var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
4333
+ var header_slice_default = headerSlice.reducer;
4334
+
4335
+ // src/store/reducers/list-slice/index.ts
4336
+ import { createSlice as createSlice6 } from "@reduxjs/toolkit";
4337
+ var initialState5 = {
4338
+ pageLimit: 10,
4339
+ fields: {},
4340
+ order: "",
4341
+ selectedRowKeys: [],
4342
+ selectedRadioKey: 0,
4343
+ indexRowTableModal: -2,
4344
+ isUpdateTableModal: false,
4345
+ footerGroupTable: {},
4346
+ transferDetail: null,
4347
+ page: 0,
4348
+ domainTable: []
4349
+ };
4350
+ var listSlice = createSlice6({
4351
+ name: "list",
4352
+ initialState: initialState5,
4353
+ reducers: {
4354
+ setPageLimit: (state, action) => {
4355
+ state.pageLimit = action.payload;
4356
+ },
4357
+ setFields: (state, action) => {
4358
+ state.fields = action.payload;
4359
+ },
4360
+ setOrder: (state, action) => {
4361
+ state.order = action.payload;
4362
+ },
4363
+ setSelectedRowKeys: (state, action) => {
4364
+ state.selectedRowKeys = action.payload;
4365
+ },
4366
+ setSelectedRadioKey: (state, action) => {
4367
+ state.selectedRadioKey = action.payload;
4368
+ },
4369
+ setIndexRowTableModal: (state, action) => {
4370
+ state.indexRowTableModal = action.payload;
4371
+ },
4372
+ setTransferDetail: (state, action) => {
4373
+ state.transferDetail = action.payload;
4374
+ },
4375
+ setIsUpdateTableModal: (state, action) => {
4376
+ state.isUpdateTableModal = action.payload;
4377
+ },
4378
+ setPage: (state, action) => {
4379
+ state.page = action.payload;
4380
+ },
4381
+ setDomainTable: (state, action) => {
4382
+ state.domainTable = action.payload;
4383
+ }
4384
+ }
4385
+ });
4386
+ var {
4387
+ setPageLimit,
4388
+ setFields,
4389
+ setOrder,
4390
+ setSelectedRowKeys,
4391
+ setIndexRowTableModal,
4392
+ setIsUpdateTableModal,
4393
+ setPage,
4394
+ setSelectedRadioKey,
4395
+ setTransferDetail,
4396
+ setDomainTable
4397
+ } = listSlice.actions;
4398
+ var list_slice_default = listSlice.reducer;
4399
+
4400
+ // src/store/reducers/login-slice/index.ts
4401
+ import { createSlice as createSlice7 } from "@reduxjs/toolkit";
4402
+ var initialState6 = {
4403
+ db: "",
4404
+ redirectTo: "/",
4405
+ forgotPasswordUrl: "/"
4406
+ };
4407
+ var loginSlice = createSlice7({
4408
+ name: "login",
4409
+ initialState: initialState6,
4410
+ reducers: {
4411
+ setDb: (state, action) => {
4412
+ state.db = action.payload;
4413
+ },
4414
+ setRedirectTo: (state, action) => {
4415
+ state.redirectTo = action.payload;
4416
+ },
4417
+ setForgotPasswordUrl: (state, action) => {
4418
+ state.forgotPasswordUrl = action.payload;
4419
+ }
4420
+ }
4421
+ });
4422
+ var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
4423
+ var login_slice_default = loginSlice.reducer;
4424
+
4425
+ // src/store/reducers/navbar-slice/index.ts
4426
+ import { createSlice as createSlice8 } from "@reduxjs/toolkit";
4427
+ var initialState7 = {
4428
+ menuFocus: {},
4429
+ menuAction: {},
4430
+ navbarWidth: 250,
4431
+ menuList: []
4432
+ };
4433
+ var navbarSlice = createSlice8({
4434
+ name: "navbar",
4435
+ initialState: initialState7,
4436
+ reducers: {
4437
+ setMenuFocus: (state, action) => {
4438
+ state.menuFocus = action.payload;
4439
+ },
4440
+ setMenuFocusAction: (state, action) => {
4441
+ state.menuAction = action.payload;
4442
+ },
4443
+ setNavbarWidth: (state, action) => {
4444
+ state.navbarWidth = action.payload;
4445
+ },
4446
+ setMenuList: (state, action) => {
4447
+ state.menuList = action.payload;
4448
+ }
4449
+ }
4450
+ });
4451
+ var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
4452
+ var navbar_slice_default = navbarSlice.reducer;
4453
+
4454
+ // src/store/reducers/profile-slice/index.ts
4455
+ import { createSlice as createSlice9 } from "@reduxjs/toolkit";
4456
+ var initialState8 = {
4457
+ profile: {}
4458
+ };
4459
+ var profileSlice = createSlice9({
4460
+ name: "profile",
4461
+ initialState: initialState8,
4462
+ reducers: {
4463
+ setProfile: (state, action) => {
4464
+ state.profile = action.payload;
4465
+ }
4466
+ }
4467
+ });
4468
+ var { setProfile } = profileSlice.actions;
4469
+ var profile_slice_default = profileSlice.reducer;
4470
+
4471
+ // src/store/reducers/search-slice/index.ts
4472
+ import { createSlice as createSlice10 } from "@reduxjs/toolkit";
4473
+ var initialState9 = {
4474
+ groupByDomain: null,
4475
+ searchBy: [],
4476
+ searchString: "",
4477
+ hoveredIndexSearchList: null,
4478
+ selectedTags: [],
4479
+ firstDomain: null,
4480
+ searchMap: {},
4481
+ filterBy: [],
4482
+ groupBy: []
4483
+ };
4484
+ var searchSlice = createSlice10({
4485
+ name: "search",
4486
+ initialState: initialState9,
4487
+ reducers: {
4488
+ setGroupByDomain: (state, action) => {
4489
+ state.groupByDomain = action.payload;
4490
+ },
4491
+ setSearchBy: (state, action) => {
4492
+ state.searchBy = action.payload;
4493
+ },
4494
+ setSearchString: (state, action) => {
4495
+ state.searchString = action.payload;
4496
+ },
4497
+ setHoveredIndexSearchList: (state, action) => {
4498
+ state.hoveredIndexSearchList = action.payload;
4499
+ },
4500
+ setSelectedTags: (state, action) => {
4501
+ state.selectedTags = action.payload;
4502
+ },
4503
+ setFirstDomain: (state, action) => {
4504
+ state.firstDomain = action.payload;
4505
+ },
4506
+ setFilterBy: (state, action) => {
4507
+ state.filterBy = action.payload;
4508
+ },
4509
+ setGroupBy: (state, action) => {
4510
+ state.groupBy = action.payload;
4511
+ },
4512
+ setSearchMap: (state, action) => {
4513
+ state.searchMap = action.payload;
4514
+ },
4515
+ updateSearchMap: (state, action) => {
4516
+ if (!state.searchMap[action.payload.key]) {
4517
+ state.searchMap[action.payload.key] = [];
4518
+ }
4519
+ state.searchMap[action.payload.key].push(action.payload.value);
4520
+ },
4521
+ removeKeyFromSearchMap: (state, action) => {
4522
+ const { key, item } = action.payload;
4523
+ const values = state.searchMap[key];
4524
+ if (!values) return;
4525
+ if (item) {
4526
+ const filtered = values.filter((value) => value.name !== item.name);
4527
+ if (filtered.length > 0) {
4528
+ state.searchMap[key] = filtered;
4529
+ } else {
4530
+ delete state.searchMap[key];
4531
+ }
4532
+ } else {
4533
+ delete state.searchMap[key];
4534
+ }
4535
+ },
4536
+ clearSearchMap: (state) => {
4537
+ state.searchMap = {};
4538
+ }
4539
+ }
4540
+ });
4541
+ var {
4542
+ setGroupByDomain,
4543
+ setSelectedTags,
4544
+ setSearchString,
4545
+ setHoveredIndexSearchList,
4546
+ setFirstDomain,
4547
+ setSearchBy,
4548
+ setFilterBy,
4549
+ setSearchMap,
4550
+ updateSearchMap,
4551
+ removeKeyFromSearchMap,
4552
+ setGroupBy,
4553
+ clearSearchMap
4554
+ } = searchSlice.actions;
4555
+ var search_slice_default = searchSlice.reducer;
4556
+
4557
+ // src/store/store.ts
4558
+ import { configureStore } from "@reduxjs/toolkit";
4559
+
4560
+ // node_modules/redux/dist/redux.mjs
4561
+ function formatProdErrorMessage(code) {
4562
+ 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. `;
4563
+ }
4564
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
4565
+ var ActionTypes = {
4566
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
4567
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
4568
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
4569
+ };
4570
+ var actionTypes_default = ActionTypes;
4571
+ function isPlainObject(obj) {
4572
+ if (typeof obj !== "object" || obj === null)
4573
+ return false;
4574
+ let proto = obj;
4575
+ while (Object.getPrototypeOf(proto) !== null) {
4576
+ proto = Object.getPrototypeOf(proto);
4577
+ }
4578
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
4579
+ }
4580
+ function miniKindOf(val) {
4581
+ if (val === void 0)
4582
+ return "undefined";
4583
+ if (val === null)
4584
+ return "null";
4585
+ const type = typeof val;
4586
+ switch (type) {
4587
+ case "boolean":
4588
+ case "string":
4589
+ case "number":
4590
+ case "symbol":
4591
+ case "function": {
4592
+ return type;
4593
+ }
4594
+ }
4595
+ if (Array.isArray(val))
4596
+ return "array";
4597
+ if (isDate(val))
4598
+ return "date";
4599
+ if (isError(val))
4600
+ return "error";
4601
+ const constructorName = ctorName(val);
4602
+ switch (constructorName) {
4603
+ case "Symbol":
4604
+ case "Promise":
4605
+ case "WeakMap":
4606
+ case "WeakSet":
4607
+ case "Map":
4608
+ case "Set":
4609
+ return constructorName;
4610
+ }
4611
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
4612
+ }
4613
+ function ctorName(val) {
4614
+ return typeof val.constructor === "function" ? val.constructor.name : null;
4615
+ }
4616
+ function isError(val) {
4617
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
4618
+ }
4619
+ function isDate(val) {
4620
+ if (val instanceof Date)
4621
+ return true;
4622
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
4623
+ }
4624
+ function kindOf(val) {
4625
+ let typeOfVal = typeof val;
4626
+ if (process.env.NODE_ENV !== "production") {
4627
+ typeOfVal = miniKindOf(val);
4628
+ }
4629
+ return typeOfVal;
4630
+ }
4631
+ function warning(message) {
4632
+ if (typeof console !== "undefined" && typeof console.error === "function") {
4633
+ console.error(message);
4634
+ }
4635
+ try {
4636
+ throw new Error(message);
4637
+ } catch (e) {
4638
+ }
4639
+ }
4640
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
4641
+ const reducerKeys = Object.keys(reducers);
4642
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
4643
+ if (reducerKeys.length === 0) {
4644
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
4645
+ }
4646
+ if (!isPlainObject(inputState)) {
4647
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
4648
+ }
4649
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
4650
+ unexpectedKeys.forEach((key) => {
4651
+ unexpectedKeyCache[key] = true;
4652
+ });
4653
+ if (action && action.type === actionTypes_default.REPLACE)
4654
+ return;
4655
+ if (unexpectedKeys.length > 0) {
4656
+ 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.`;
4657
+ }
4658
+ }
4659
+ function assertReducerShape(reducers) {
4660
+ Object.keys(reducers).forEach((key) => {
4661
+ const reducer = reducers[key];
4662
+ const initialState10 = reducer(void 0, {
4663
+ type: actionTypes_default.INIT
4664
+ });
4665
+ if (typeof initialState10 === "undefined") {
4666
+ 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.`);
4667
+ }
4668
+ if (typeof reducer(void 0, {
4669
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
4670
+ }) === "undefined") {
4671
+ 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.`);
4672
+ }
4673
+ });
4674
+ }
4675
+ function combineReducers(reducers) {
4676
+ const reducerKeys = Object.keys(reducers);
4677
+ const finalReducers = {};
4678
+ for (let i = 0; i < reducerKeys.length; i++) {
4679
+ const key = reducerKeys[i];
4680
+ if (process.env.NODE_ENV !== "production") {
4681
+ if (typeof reducers[key] === "undefined") {
4682
+ warning(`No reducer provided for key "${key}"`);
4683
+ }
4684
+ }
4685
+ if (typeof reducers[key] === "function") {
4686
+ finalReducers[key] = reducers[key];
4687
+ }
4688
+ }
4689
+ const finalReducerKeys = Object.keys(finalReducers);
4690
+ let unexpectedKeyCache;
4691
+ if (process.env.NODE_ENV !== "production") {
4692
+ unexpectedKeyCache = {};
4693
+ }
4694
+ let shapeAssertionError;
4695
+ try {
4696
+ assertReducerShape(finalReducers);
4697
+ } catch (e) {
4698
+ shapeAssertionError = e;
4699
+ }
4700
+ return function combination(state = {}, action) {
4701
+ if (shapeAssertionError) {
4702
+ throw shapeAssertionError;
4703
+ }
4704
+ if (process.env.NODE_ENV !== "production") {
4705
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
4706
+ if (warningMessage) {
4707
+ warning(warningMessage);
4708
+ }
4709
+ }
4710
+ let hasChanged = false;
4711
+ const nextState = {};
4712
+ for (let i = 0; i < finalReducerKeys.length; i++) {
4713
+ const key = finalReducerKeys[i];
4714
+ const reducer = finalReducers[key];
4715
+ const previousStateForKey = state[key];
4716
+ const nextStateForKey = reducer(previousStateForKey, action);
4717
+ if (typeof nextStateForKey === "undefined") {
4718
+ const actionType = action && action.type;
4719
+ 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.`);
4720
+ }
4721
+ nextState[key] = nextStateForKey;
4722
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
4723
+ }
4724
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
4725
+ return hasChanged ? nextState : state;
4726
+ };
4727
+ }
4728
+
4729
+ // src/store/store.ts
4730
+ var rootReducer = combineReducers({
4731
+ env: env_slice_default,
4732
+ header: header_slice_default,
4733
+ navbar: navbar_slice_default,
4734
+ list: list_slice_default,
4735
+ search: search_slice_default,
4736
+ form: form_slice_default,
4737
+ breadcrumbs: breadcrums_slice_default,
4738
+ login: login_slice_default,
4739
+ excel: excel_slice_default,
4740
+ profile: profile_slice_default
4741
+ });
4742
+ var envStore = configureStore({
4743
+ reducer: rootReducer,
4744
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
4745
+ serializableCheck: false
4746
+ })
4747
+ });
4748
+
4749
+ // src/provider/redux-provider.tsx
4750
+ import { jsx as jsx2 } from "react/jsx-runtime";
4751
+
4752
+ // src/provider/main-provider.tsx
4753
+ import { jsx as jsx3 } from "react/jsx-runtime";
4754
+
4755
+ // src/provider/version-gate-provider.tsx
4756
+ import { useEffect as useEffect2, useState as useState2 } from "react";
4757
+ import { useQueryClient } from "@tanstack/react-query";
4758
+
4759
+ // src/services/view-service/backup.ts
4760
+ import { useCallback } from "react";
4761
+
4762
+ // src/provider/version-gate-provider.tsx
4763
+ import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
4764
+
4765
+ // src/provider/env-provider.tsx
4766
+ import { createContext, useContext, useState as useState3, useCallback as useCallback2 } from "react";
4767
+ import { jsx as jsx5 } from "react/jsx-runtime";
4768
+ var EnvContext = createContext(null);
4769
+ function useEnv() {
4770
+ const context = useContext(EnvContext);
4771
+ if (!context) {
4772
+ throw new Error("useEnv must be used within an EnvProvider");
4773
+ }
4774
+ return context;
4775
+ }
4776
+
4777
+ // src/provider/env-share.tsx
4778
+ import { createContext as createContext2, useContext as useContext2 } from "react";
4779
+ import { jsx as jsx6 } from "react/jsx-runtime";
4780
+ var EnvShareContext = createContext2(null);
4781
+
4782
+ // src/services/auth-service/backup.ts
4783
+ function useAuthService() {
4784
+ const { env: env2 } = useEnv();
4785
+ const login = useCallback3(
4786
+ async (body) => {
4787
+ const payload = Object.fromEntries(
4788
+ Object.entries({
4789
+ username: body.email,
4790
+ password: body.password,
4791
+ grant_type: env2?.config?.grantType || "",
4792
+ client_id: env2?.config?.clientId || "",
4793
+ client_secret: env2?.config?.clientSecret || ""
4794
+ }).filter(([_, value]) => !!value)
4795
+ );
4796
+ const encodedData = new URLSearchParams(payload).toString();
4797
+ return env2?.requests?.post(body.path, encodedData, {
4798
+ headers: {
4799
+ "Content-Type": "application/x-www-form-urlencoded"
4800
+ }
4801
+ });
4802
+ },
4803
+ [env2]
4804
+ );
4805
+ const forgotPassword = useCallback3(
4806
+ async (email) => {
4807
+ const bodyData = {
4808
+ login: email,
4809
+ url: `${window.location.origin}/reset-password`
4810
+ };
4811
+ return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
4812
+ headers: {
4813
+ "Content-Type": "application/json"
4814
+ }
4815
+ });
4816
+ },
4817
+ [env2]
4818
+ );
4819
+ const forgotPasswordSSO = useCallback3(
4820
+ async ({
4821
+ email,
4822
+ with_context,
4823
+ method
4824
+ }) => {
4825
+ const body = {
4826
+ method,
4827
+ kwargs: {
4828
+ vals: {
4829
+ email
4830
+ }
4831
+ },
4832
+ with_context
4833
+ };
4834
+ return env2?.requests?.post("/call" /* CALL_PATH */, body, {
4835
+ headers: {
4836
+ "Content-Type": "application/json"
4837
+ }
4838
+ });
4839
+ },
4840
+ [env2]
4841
+ );
4842
+ const resetPassword = useCallback3(
4843
+ async (data, token) => {
4844
+ const bodyData = {
4845
+ token,
4846
+ password: data.password,
4847
+ new_password: data.confirmPassword
4848
+ };
4849
+ return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
4850
+ headers: {
4851
+ "Content-Type": "application/json"
4852
+ }
4853
+ });
4854
+ },
4855
+ [env2]
4856
+ );
4857
+ const resetPasswordSSO = useCallback3(
4858
+ async ({
4859
+ method,
4860
+ password,
4861
+ with_context
4862
+ }) => {
4863
+ const bodyData = {
4864
+ method,
4865
+ kwargs: {
4866
+ vals: {
4867
+ password
4868
+ }
4869
+ },
4870
+ with_context
4871
+ };
4872
+ return env2?.requests?.post("/call" /* CALL_PATH */, bodyData, {
4873
+ headers: {
4874
+ "Content-Type": "application/json"
4875
+ }
4876
+ });
4877
+ },
4878
+ [env2]
4879
+ );
4880
+ const updatePassword = useCallback3(
4881
+ async (data, token) => {
4882
+ const bodyData = {
4883
+ token,
4884
+ old_password: data.oldPassword,
4885
+ new_password: data.newPassword
4886
+ };
4887
+ return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
4888
+ headers: {
4889
+ "Content-Type": "application/json"
4890
+ }
4891
+ });
4892
+ },
4893
+ [env2]
4894
+ );
4895
+ const isValidToken = useCallback3(
4896
+ async (token) => {
4897
+ const bodyData = {
4898
+ token
4899
+ };
4900
+ return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
4901
+ headers: {
4902
+ "Content-Type": "application/json"
4903
+ }
4904
+ });
4905
+ },
4906
+ [env2]
4907
+ );
4908
+ const isValidActionToken = useCallback3(
4909
+ async (actionToken, path) => {
4910
+ return env2?.requests?.post(
4911
+ path,
4912
+ {},
4913
+ {
4914
+ headers: {
4915
+ "Content-Type": "application/json"
4916
+ },
4917
+ useActionToken: true,
4918
+ actionToken
4919
+ }
4920
+ );
4921
+ },
4922
+ [env2]
4923
+ );
4924
+ const loginSocial = useCallback3(
4925
+ async ({
4926
+ db,
4927
+ state,
4928
+ access_token
4929
+ }) => {
4930
+ return env2?.requests?.post(
4931
+ "/token/generate" /* GENTOKEN_SOCIAL */,
4932
+ { state, access_token },
4933
+ {
4934
+ headers: {
4935
+ "Content-Type": "application/json"
4936
+ }
4937
+ }
4938
+ );
4939
+ },
4940
+ [env2]
4941
+ );
4942
+ const getProviders = useCallback3(
4943
+ async (db) => {
4944
+ return env2?.requests?.get("/oauth/providers", { params: { db } });
4945
+ },
4946
+ [env2]
4947
+ );
4948
+ const getAccessByCode = useCallback3(
4949
+ async (code) => {
4950
+ const data = new URLSearchParams();
4951
+ data.append("code", code);
4952
+ data.append("grant_type", "authorization_code");
4953
+ data.append("client_id", env2?.config?.clientId || "");
4954
+ data.append("redirect_uri", env2?.config?.redirectUri || "");
4955
+ return env2?.requests?.post(
4956
+ `${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
4957
+ data,
4958
+ {
4959
+ headers: {
4960
+ "Content-Type": "application/x-www-form-urlencoded"
4961
+ }
4962
+ }
4963
+ );
4964
+ },
4965
+ [env2]
4966
+ );
4967
+ const logout = useCallback3(
4968
+ async (data) => {
4969
+ console.log(data);
4970
+ return env2?.requests?.post(
4971
+ "/logout" /* LOGOUT */,
4972
+ {},
4973
+ {
4974
+ headers: {
4975
+ "Content-Type": "application/json"
4976
+ },
4977
+ withCredentials: true,
4978
+ useRefreshToken: true
4979
+ }
4980
+ );
4981
+ },
4982
+ [env2]
4983
+ );
4984
+ return {
4985
+ login,
4986
+ forgotPassword,
4987
+ forgotPasswordSSO,
4988
+ resetPassword,
4989
+ resetPasswordSSO,
4990
+ updatePassword,
4991
+ isValidToken,
4992
+ isValidActionToken,
4993
+ loginSocial,
4994
+ getProviders,
4995
+ getAccessByCode,
4996
+ logout
4997
+ };
4998
+ }
4999
+
5000
+ // src/hooks/auth/use-login-credential.ts
4122
5001
  var useLoginCredential = () => {
5002
+ const { login } = useAuthService();
4123
5003
  return useMutation5({
4124
5004
  mutationFn: (data) => {
4125
- return auth_service_default.login(data);
5005
+ return login(data);
4126
5006
  }
4127
5007
  });
4128
5008
  };