@ordentco/addons-auth-provider 0.9.135 → 0.9.136-mfe

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.
Files changed (45) hide show
  1. package/config.ts +1 -1
  2. package/dist/config.js +2 -2
  3. package/dist/config.js.map +1 -1
  4. package/dist/services/auth.d.ts +15 -15
  5. package/dist/services/auth.js +2 -2
  6. package/dist/services/auth.js.map +1 -1
  7. package/dist/services/custom-axios.js +6 -5
  8. package/dist/services/custom-axios.js.map +1 -1
  9. package/dist/services/system.d.ts +1 -1
  10. package/dist/services/user.d.ts +2 -2
  11. package/dist/src/auth.d.ts +12 -3
  12. package/dist/src/auth.js +393 -269
  13. package/dist/src/auth.js.map +1 -1
  14. package/dist/src/index.d.ts +2 -2
  15. package/dist/src/index.js +8 -16
  16. package/dist/src/index.js.map +1 -1
  17. package/dist/src/types/onboarding.d.ts +11 -0
  18. package/dist/src/types/onboarding.js +14 -0
  19. package/dist/src/types/onboarding.js.map +1 -0
  20. package/dist/src/types/router.d.ts +10 -0
  21. package/dist/src/types/router.js +3 -0
  22. package/dist/src/types/router.js.map +1 -0
  23. package/dist/types/product.d.ts +8 -3
  24. package/dist/types/product.js +5 -0
  25. package/dist/types/product.js.map +1 -1
  26. package/dist/types/user.d.ts +1 -1
  27. package/dist/types/workflow.d.ts +1 -1
  28. package/dist/utils/auth.d.ts +2 -2
  29. package/dist/utils/auth.js.map +1 -1
  30. package/dist/utils/env.d.ts +1 -0
  31. package/dist/utils/env.js +55 -0
  32. package/dist/utils/env.js.map +1 -0
  33. package/package.json +4 -4
  34. package/services/auth.ts +4 -4
  35. package/services/custom-axios.ts +8 -8
  36. package/src/auth.tsx +509 -255
  37. package/src/index.ts +2 -2
  38. package/src/types/onboarding.ts +14 -0
  39. package/src/types/router.ts +10 -0
  40. package/types/product.ts +9 -4
  41. package/types/user.ts +1 -1
  42. package/types/workflow.ts +1 -1
  43. package/utils/auth.ts +109 -110
  44. package/utils/config.ts +0 -63
  45. package/utils/env.ts +63 -0
package/src/auth.tsx CHANGED
@@ -1,32 +1,40 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import {createContext, useCallback, useContext, useMemo, useState, SetStateAction, useEffect, useRef} from "react";
3
- import { useRouter } from "next/router";
4
- import {AuthService} from "../services";
5
- // import { message } from "antd";
1
+ import concat from "lodash/concat";
2
+ import get from "lodash/get";
3
+ import mergeWith from "lodash/mergeWith";
4
+ import snakeCase from "lodash/snakeCase";
5
+ import {
6
+ createContext,
7
+ useCallback,
8
+ useContext,
9
+ useEffect,
10
+ useMemo,
11
+ useRef,
12
+ useState,
13
+ } from "react";
6
14
  import { IdleTimerProvider } from "react-idle-timer";
7
- import { createProductAuthorities } from "../utils/auth";
15
+ import { AuthService } from "../services";
8
16
  import {
9
17
  AuthorityLevelEnum,
10
18
  ChangePasswordType,
11
19
  ForgotPasswordType,
20
+ MultipaymentAuthorityEnum,
12
21
  ProductAuthoritiesType,
13
22
  ProductAuthorityType,
14
- VerifyUserQuestion,
15
23
  ProductTypeEnum,
16
- TransactionWorkflow,
17
- MultipaymentAuthorityEnum,
24
+ StepType,
18
25
  TaskStatus,
19
- StepType
26
+ TransactionWorkflow,
27
+ VerifyUserQuestion,
20
28
  } from "../types";
21
- // import { ArgsProps } from "antd/lib/message";
22
- import mergeWith from "lodash/mergeWith";
23
- import concat from "lodash/concat";
24
- import get from "lodash/get";
25
- import snakeCase from "lodash/snakeCase";
29
+ import type { AuthRouter } from "./types/router";
30
+ import { createProductAuthorities } from "../utils/auth";
26
31
  import { isEmpty } from "../utils/is-empty";
27
- // import {AxiosInstance} from "axios";
32
+ import { OnboardingTourStatus } from "./types/onboarding";
28
33
 
29
34
  const FIFTEEN_MINUTES = 15 * 60 * 1000;
35
+ const SESSION_VALIDITY_MS = 5 * 60 * 1000; // 5 minutes
36
+
37
+ const initialProductAuthorities = createProductAuthorities();
30
38
 
31
39
  export enum UserType {
32
40
  BankAdmin = "bank-admin",
@@ -34,8 +42,6 @@ export enum UserType {
34
42
  CustomerUser = "customer-user",
35
43
  }
36
44
 
37
- const initialProductAuthorities = createProductAuthorities();
38
-
39
45
  interface AuthContextProps {
40
46
  token: string | null;
41
47
  authorities: Map<string, string[]>;
@@ -50,43 +56,74 @@ interface AuthContextProps {
50
56
  companyName: string;
51
57
  userMode: string;
52
58
  companyLevel: string;
59
+ isIntraday: boolean;
53
60
  userID: string | null;
54
61
  roleID: string | null;
55
62
  roleIDs: string[] | null;
56
63
  holdingID: string | null;
57
64
  isLoading: boolean | null;
65
+ onboardingTourStatus: OnboardingTourStatus;
58
66
  guard: () => void;
59
- passwordLogin: (username: string, password: string, tokenFCM: string) => Promise<void>;
67
+ passwordLogin: (
68
+ username: string,
69
+ password: string,
70
+ tokenFCM: string
71
+ ) => Promise<void>;
60
72
  ssoLogin: (
61
73
  userId: string,
62
74
  sessionId: string,
63
75
  dtTime: string,
64
76
  onError?: (errorMessage: string) => void
65
77
  ) => Promise<void>;
66
- logout: (type?:string) => Promise<void>;
67
- canIApprove: (workflow: TransactionWorkflow.Root, status?:TaskStatus) => boolean;
78
+ logout: (type?: string) => Promise<void>;
79
+ canIApprove: (
80
+ workflow: TransactionWorkflow.Root,
81
+ status?: TaskStatus
82
+ ) => boolean;
68
83
  canIDelete: (product: string, status: TaskStatus) => boolean;
69
- canIEdit: (workflow: TransactionWorkflow.Root, product : string, status: TaskStatus) => boolean;
84
+ canIEdit: (
85
+ workflow: TransactionWorkflow.Root,
86
+ product: string,
87
+ status: TaskStatus
88
+ ) => boolean;
70
89
  menuData: any[];
71
- ssoQlolaLogin: (
72
- request: string
73
- ) => Promise<void>;
90
+ ssoQlolaLogin: (request: string) => Promise<void>;
74
91
  verifyUserQuestion: (payload: VerifyUserQuestion) => Promise<void>;
75
92
  verifyChangePasswordToken: (token: string) => Promise<void>;
76
93
  forgotPassword: (payload: ForgotPasswordType) => Promise<void>;
77
- login: (username: string, password: string, branchCode: string, type?:string) => Promise<void>;
78
- checkToChangePassword: (username: string, password: string, tokenFCM: string, branchCode: string) => Promise<void>;
79
- passwordLoginWithCheck: (username: string, password: string, tokenFCM: string, branchCode: string) => Promise<void>;
94
+ login: (
95
+ username: string,
96
+ password: string,
97
+ branchCode: string,
98
+ type?: string
99
+ ) => Promise<void>;
100
+ checkToChangePassword: (
101
+ username: string,
102
+ password: string,
103
+ tokenFCM: string,
104
+ branchCode: string
105
+ ) => Promise<void>;
106
+ passwordLoginWithCheck: (
107
+ username: string,
108
+ password: string,
109
+ tokenFCM: string,
110
+ branchCode: string
111
+ ) => Promise<void>;
80
112
  requestChangePassword: (payload: ChangePasswordType) => Promise<void>;
81
- action : any;
82
- onLeaveAction : any;
83
- setOnLeaveAction : any;
84
- countryCode:string;
85
- setToken: (value: (((prevState: (string | null)) => (string | null)) | string | null)) => void;
86
- setIsLoading: (value: (((prevState: boolean) => boolean) | boolean)) => void;
87
- companyCode : string;
88
- region : string;
89
- checkToken : () => Promise<void>;
113
+ action: any;
114
+ onLeaveAction: any;
115
+ setOnLeaveAction: any;
116
+ countryCode: string;
117
+ setToken: (
118
+ value: ((prevState: string | null) => string | null) | string | null
119
+ ) => void;
120
+ setUserType: (
121
+ value: ((prevState: string | null) => string | null) | string | null
122
+ ) => void;
123
+ setIsLoading: (value: ((prevState: boolean) => boolean) | boolean) => void;
124
+ companyCode: string;
125
+ region: string;
126
+ checkToken: () => Promise<void>;
90
127
  }
91
128
 
92
129
  const AUTH_INITIAL_VALUES: AuthContextProps = {
@@ -101,74 +138,80 @@ const AUTH_INITIAL_VALUES: AuthContextProps = {
101
138
  companyName: "",
102
139
  userMode: "",
103
140
  companyLevel: "",
141
+ onboardingTourStatus: OnboardingTourStatus.Done,
104
142
  userID: null,
105
143
  roleID: null,
106
144
  roleIDs: null,
107
145
  holdingID: null,
108
146
  isLoading: false,
147
+ isIntraday: false,
109
148
  menus: [],
110
149
  loggedIn: false,
111
- guard: function (): void {
150
+ guard: () => {
151
+ throw new Error("Function not implemented.");
152
+ },
153
+ passwordLogin: async () => {
112
154
  throw new Error("Function not implemented.");
113
155
  },
114
- passwordLogin: function (_: string, __: string, ___: string): Promise<void> {
156
+ ssoLogin: async () => {
115
157
  throw new Error("Function not implemented.");
116
158
  },
117
- ssoLogin: function (_: string, __: string, ___: string): Promise<void> {
159
+ logout: async () => {
118
160
  throw new Error("Function not implemented.");
119
161
  },
120
- logout: function (_:string): Promise<void> {
162
+ canIApprove: () => {
121
163
  throw new Error("Function not implemented.");
122
164
  },
123
- canIApprove: function (_workflow : TransactionWorkflow.Root, _status?:TaskStatus): boolean {
165
+ canIDelete: () => {
166
+ throw new Error("Function not implemented.");
167
+ },
168
+ canIEdit: () => {
124
169
  throw new Error("Function not implemented.");
125
170
  },
126
171
  menuData: [],
127
- verifyUserQuestion: function (_payloa: VerifyUserQuestion): Promise<void> {
172
+ ssoQlolaLogin: async () => {
128
173
  throw new Error("Function not implemented.");
129
174
  },
130
- verifyChangePasswordToken: function (_token: string): Promise<void> {
175
+ verifyUserQuestion: async () => {
131
176
  throw new Error("Function not implemented.");
132
177
  },
133
- ssoQlolaLogin: function (_: string): Promise<void> {
178
+ verifyChangePasswordToken: async () => {
134
179
  throw new Error("Function not implemented.");
135
180
  },
136
- login: function (_: string, __: string, ___: string, ____:string): Promise<void> {
181
+ forgotPassword: async () => {
137
182
  throw new Error("Function not implemented.");
138
183
  },
139
- forgotPassword: function (_payload: ForgotPasswordType): Promise<void> {
184
+ login: async () => {
140
185
  throw new Error("Function not implemented.");
141
186
  },
142
- checkToChangePassword: function (_: string, __: string, ___: string, ____: string): Promise<void> {
187
+ checkToChangePassword: async () => {
143
188
  throw new Error("Function not implemented.");
144
189
  },
145
- passwordLoginWithCheck: function (_: string, __: string, ___: string, ____: string): Promise<void> {
190
+ passwordLoginWithCheck: async () => {
146
191
  throw new Error("Function not implemented.");
147
192
  },
148
- requestChangePassword: function (_payload: ChangePasswordType): Promise<void> {
193
+ requestChangePassword: async () => {
149
194
  throw new Error("Function not implemented.");
150
195
  },
151
- canIDelete: function (_product: string, _status: TaskStatus): boolean {
196
+ action: null,
197
+ onLeaveAction: null,
198
+ setOnLeaveAction: null,
199
+ countryCode: "",
200
+ setToken: () => {
152
201
  throw new Error("Function not implemented.");
153
202
  },
154
- canIEdit: function (_workflow: TransactionWorkflow.Root, _product:string, _status: TaskStatus): boolean {
203
+ setIsLoading: () => {
155
204
  throw new Error("Function not implemented.");
156
205
  },
157
- setIsLoading: function (_payload: SetStateAction<boolean>): Promise<void> {
206
+ setUserType: () => {
158
207
  throw new Error("Function not implemented.");
159
208
  },
160
- setToken: function (_payload: SetStateAction<string | null>): Promise<void> {
209
+ companyCode: "",
210
+ region: "",
211
+
212
+ checkToken: async () => {
161
213
  throw new Error("Function not implemented.");
162
214
  },
163
- action : null,
164
- onLeaveAction : null,
165
- setOnLeaveAction : null,
166
- countryCode : "",
167
- companyCode : "",
168
- region : "",
169
- checkToken : function () : Promise<void> {
170
- throw new Error("Function not implemented");
171
- }
172
215
  };
173
216
 
174
217
  // export const getStaticProps:GetStaticProps<{}> = async () => {
@@ -180,26 +223,49 @@ const AuthContext = createContext(AUTH_INITIAL_VALUES);
180
223
  export interface AuthProviderProps {
181
224
  children?: React.ReactNode;
182
225
  cookieName?: string;
183
- apiUrl : string
226
+ apiUrl: string;
227
+ router: AuthRouter;
228
+ loginRoute?: string;
229
+ baseRoute?: string;
184
230
  }
185
231
 
186
- export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl }) => {
187
- const router = useRouter();
232
+ export const noopRouter: AuthRouter = {
233
+ push: () => {},
234
+ replace: () => {},
235
+ basePath: "",
236
+ asPath: "",
237
+ events: {
238
+ on: () => {},
239
+ off: () => {},
240
+ },
241
+ };
242
+
243
+ export const AuthProvider: React.FC<AuthProviderProps> = ({
244
+ children,
245
+ apiUrl,
246
+ router = noopRouter,
247
+ loginRoute = "/main-page",
248
+ baseRoute = "/",
249
+ }) => {
188
250
  const [token, setToken] = useState<string | null>(() => {
189
251
  if (typeof window !== "undefined") {
190
- const t = localStorage.getItem("access-token");
191
- return t;
252
+ return localStorage.getItem("access-token");
192
253
  }
193
254
  return null;
194
255
  });
256
+
195
257
  const authService = useMemo(() => AuthService(), [apiUrl, token]);
196
- const [authorities, setAuthorities] = useState<Map<string, string[]>>(new Map());
258
+ const [authorities, setAuthorities] = useState<Map<string, string[]>>(
259
+ () => new Map()
260
+ );
197
261
  const [username, setUsername] = useState<string>("Guest");
198
262
  const [userType, setUserType] = useState<string | null>(null);
199
263
  const [companyID, setCompanyID] = useState<string | null>(null);
200
264
  const [companyName, setCompanyName] = useState("");
201
265
  const [userMode, setUserMode] = useState<string>("");
202
266
  const [companyLevel, setCompanyLevel] = useState<string>("");
267
+ const [onboardingTourStatus, setOnboardingTourStatus] =
268
+ useState<OnboardingTourStatus>(OnboardingTourStatus.Done);
203
269
  const [userID, setUserID] = useState<string | null>(null);
204
270
  const [roleID, setRoleID] = useState<string | null>(null);
205
271
  const [roleIDs, setRoleIDs] = useState<string[]>([]);
@@ -208,9 +274,14 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
208
274
  const [_openModal, setOpenModal] = useState<boolean>(false);
209
275
  const [menus, setMenus] = useState<string[]>([]);
210
276
  const [isMinutes, setIsMinutes] = useState<number>(FIFTEEN_MINUTES);
277
+ const [isIntraday, setIsIntraday] = useState<boolean>(false);
211
278
  const [isLoading, setIsLoading] = useState<boolean>(false);
212
- const [productAuthorities, setProductAuthorities] = useState<ProductAuthoritiesType>(initialProductAuthorities);
279
+ const [productAuthorities, setProductAuthorities] =
280
+ useState<ProductAuthoritiesType>(initialProductAuthorities);
213
281
  const [isAuthoritiesReady, setIsAuthoritiesReady] = useState(false);
282
+ const [sessionLastValidatedAt, setSessionLastValidatedAt] = useState<
283
+ number | null
284
+ >(null);
214
285
  const [menuData, setMenuData] = useState<any>([]);
215
286
  const [action, _setAction] = useState<any>({});
216
287
  const [onLeaveAction, setOnLeaveAction] = useState<any>({});
@@ -222,35 +293,60 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
222
293
  const loggedIn = useMemo(() => !!token, [token]);
223
294
 
224
295
  const guard = useCallback(async () => {
225
- if (token) {
296
+ // Session Freshness Check
297
+ if (
298
+ sessionLastValidatedAt &&
299
+ Date.now() - sessionLastValidatedAt < SESSION_VALIDITY_MS
300
+ ) {
301
+ // Ensure authorities are marked as ready if the router reset them
302
+ if (!isAuthoritiesReady) setIsAuthoritiesReady(true);
303
+ return; // The context is fresh, so we exit immediately.
304
+ }
305
+
306
+ // No Token Check
307
+ if (!token) {
308
+ router.push(loginRoute);
309
+ return;
310
+ }
311
+
312
+ // --- Start Validation Flow ---
226
313
  setIsAuthoritiesReady(false);
227
- let response:any;
314
+
315
+ let response: any;
316
+
228
317
  try {
229
318
  response = await authService.validateToken();
230
- }
231
- catch (error:any){
232
- const agent = typeof window !== "undefined" && localStorage.getItem("agent");
233
- if(agent === "qlola" && ![200].includes(error?.response?.data?.code || error?.response?.status)){
319
+ } catch (error: any) {
320
+ const agent =
321
+ typeof window !== "undefined" && localStorage.getItem("agent");
322
+ if (
323
+ agent === "qlola" &&
324
+ ![200].includes(error?.response?.data?.code || error?.response?.status)
325
+ ) {
234
326
  localStorage.removeItem("access-token");
235
327
  localStorage.removeItem("refresh-token");
236
328
 
237
329
  setToken(() => null);
330
+
331
+ setSessionLastValidatedAt(null);
238
332
  return window.close();
239
333
  }
240
334
  console.log({ error });
241
- response = error
335
+ response = error;
242
336
  }
243
337
  const menu = await authService.validateMenu(token);
244
338
 
245
339
  if (menu.data.code !== 200 || !menu) setAlertMenuError(true);
246
340
 
247
- const newMenuData = get(menu, 'data.data', [])
248
- const newMenus = newMenuData.filter((item: any) => item.productName !== "").map((item: any) => item.productName)
341
+ const newMenuData = get(menu, "data.data", []);
342
+ const newMenus = newMenuData
343
+ .filter((item: any) => item.productName !== "")
344
+ .map((item: any) => item.productName);
249
345
  setMenus(newMenus);
250
346
  setMenuData(newMenuData);
251
347
 
252
- if(response.status === 401) {
253
- if(typeof window !== "undefined") {
348
+ if (response.status === 401) {
349
+ if (typeof window !== "undefined") {
254
350
  const refreshToken = localStorage.getItem("refresh-token");
255
351
  if (refreshToken) {
256
352
  const refresh = await authService.refreshToken(refreshToken);
@@ -269,13 +365,18 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
269
365
 
270
366
  setToken(() => null);
271
367
 
272
- router.push("/main-page?logout=true");
368
+ setSessionLastValidatedAt(null);
369
+
370
+ router?.push(`${loginRoute}?logout=true`);
273
371
 
274
372
  return;
275
373
  }
276
- if(response?.data){
277
- const {username, companyCode, userID, companyID} = response.data
278
- localStorage.setItem("login", `${username}-${companyCode}-${userID}-${companyID}`);
374
+ if (response?.data) {
375
+ const { username, companyCode, userID, companyID } = response.data;
376
+ localStorage.setItem(
377
+ "login",
378
+ `${username}-${companyCode}-${userID}-${companyID}`
379
+ );
279
380
  }
280
381
  setRoleID(() => response.data.roleIDs[0]);
281
382
  setRoleIDs(() => response.data.roleIDs);
@@ -289,7 +390,11 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
289
390
  setCompanyCode(() => response?.data?.companyCode || "");
290
391
  setRegion(() => response.data.region || "");
291
392
  setUserMode(() => response.data?.userMode || "");
292
- setCompanyLevel(() => response?.data?.companyLevel || "")
393
+ setCompanyLevel(() => response?.data?.companyLevel || "");
394
+ setIsIntraday(() => response?.data?.isIntraday || false);
395
+ setOnboardingTourStatus(
396
+ () => response?.data?.onboardingTourStatus || OnboardingTourStatus.Done
397
+ );
293
398
 
294
399
  const a = new Map<string, Array<string>>();
295
400
  const productRoles = response.data?.productRoles || [];
@@ -304,8 +409,10 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
304
409
  const privilegesRecords = { ...productAuthorities } as any;
305
410
 
306
411
  // use dynamic product roles! do not use hardcode!
307
- const productTypeEnumValuesFromProductRoles = Array.from(a.keys())
308
- const productTypeEnumValuesFromHardcode = Array.from(Object.values(ProductTypeEnum))
412
+ const productTypeEnumValuesFromProductRoles = Array.from(a.keys());
413
+ const productTypeEnumValuesFromHardcode = Array.from(
414
+ Object.values(ProductTypeEnum)
415
+ );
309
416
  const remainingProductTypeEnum = [
310
417
  productTypeEnumValuesFromProductRoles,
311
418
  productTypeEnumValuesFromHardcode,
@@ -315,7 +422,10 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
315
422
  const productTypeEnumKeyFromProductRoles = remainingProductTypeEnum.map(
316
423
  (item) => [snakeCase(item).toUpperCase(), item]
317
424
  ); // from product roles that not define by hardcode
318
- const allProductTypeEnum = concat(productTypeEnumKeyFromHardcode, productTypeEnumKeyFromProductRoles);
425
+ const allProductTypeEnum = concat(
426
+ productTypeEnumKeyFromHardcode,
427
+ productTypeEnumKeyFromProductRoles
428
+ );
319
429
 
320
430
  // FIXME: delete this logic beacuse expose all product, need to get from variable productRoles / a!
321
431
  allProductTypeEnum.forEach(([productKey, productValue]) => {
@@ -328,50 +438,68 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
328
438
  });
329
439
 
330
440
  productAuthority["anyAuthority"] = productRole.length > 0;
331
- productAuthority["allAuthority"] = productRole.length >= Object.entries(AuthorityLevelEnum).length;
441
+ productAuthority["allAuthority"] =
442
+ productRole.length >= Object.entries(AuthorityLevelEnum).length;
332
443
 
333
- privilegesRecords[productKey] = productAuthority as ProductAuthorityType;
444
+ privilegesRecords[productKey] = productAuthority as ProductAuthorityType;
334
445
  });
446
+
335
447
  // Combine Authority All Product Multipayment
336
- if(!isEmpty(newMenuData.find((item:any)=> item.productName === MultipaymentAuthorityEnum['create']))){
448
+ if (
449
+ !isEmpty(
450
+ newMenuData.find(
451
+ (item: any) =>
452
+ item.productName === MultipaymentAuthorityEnum["create"]
453
+ )
454
+ )
455
+ ) {
337
456
  const menuDataMultipaymentCreate = newMenuData.find(
338
- (item: any) => item.productName === MultipaymentAuthorityEnum['create']
457
+ (item: any) => item.productName === MultipaymentAuthorityEnum["create"]
339
458
  );
340
459
  const menuDataMultipayment = newMenuData.filter(
341
460
  (item: any) => item.parentID === menuDataMultipaymentCreate.menuID
342
461
  );
343
- const multipaymentProducts = menuDataMultipayment.map((item: any) => item["name"])
462
+ const multipaymentProducts = menuDataMultipayment.map(
463
+ (item: any) => item["name"]
464
+ );
344
465
  multipaymentProducts.map((item: any) => {
345
- privilegesRecords['MULTIPAYMENT'] = mergeWith(
346
- privilegesRecords['MULTIPAYMENT'],
466
+ privilegesRecords["MULTIPAYMENT"] = mergeWith(
467
+ privilegesRecords["MULTIPAYMENT"],
347
468
  privilegesRecords[snakeCase(item).toUpperCase()],
348
469
  (objValue, srcValue) => objValue || srcValue
349
- )
350
- })
470
+ );
471
+ });
351
472
  }
352
473
 
353
474
  setProductAuthorities(privilegesRecords);
354
475
  setIsAuthoritiesReady(true);
355
476
 
356
- return;
357
- }
358
-
359
- router.push("/main-page");
477
+ setSessionLastValidatedAt(Date.now());
360
478
  }, [token, authService]);
361
479
 
362
- const canIApprove = (workflow: TransactionWorkflow.Root, status?: TaskStatus) => {
480
+ const canIApprove = (
481
+ workflow: TransactionWorkflow.Root,
482
+ status?: TaskStatus
483
+ ) => {
363
484
  if (!workflow?.workflow) return false;
364
485
 
365
- const { header, currentStep, records, currentRoleIDs = [], createdBy, participantUserIDs } = workflow.workflow;
486
+ const {
487
+ header,
488
+ currentStep,
489
+ records,
490
+ currentRoleIDs = [],
491
+ createdBy,
492
+ participantUserIDs,
493
+ } = workflow.workflow;
366
494
 
367
- const isMaker = createdBy.userID == userID
495
+ const isMaker = createdBy.userID == userID;
368
496
  const product = header?.productName as unknown as ProductTypeEnum;
369
497
  if (!product) return false;
370
498
 
371
499
  const productKey = snakeCase(product).toUpperCase();
372
500
  if (!productKey) return false;
373
501
 
374
- // @ts-ignore
502
+ // @ts-expect-error product authorities key is a enum keyof
375
503
  const authority = productAuthorities[productKey];
376
504
  if (!authority) return false;
377
505
 
@@ -396,23 +524,39 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
396
524
  ];
397
525
 
398
526
  const participant = participants.find(
399
- (p) => roleIDs.includes(`${p.roleID}`) && p.step === currentStep && p.userName === username
527
+ (p) =>
528
+ roleIDs.includes(`${p.roleID}`) &&
529
+ p.step === currentStep &&
530
+ p.userName === username
400
531
  );
401
532
 
402
533
  alreadyApprove = !!participant?.approvedAt;
403
534
  }
404
535
 
405
- if (participantUserIDs && participantUserIDs?.includes(userID as string)) return false;
536
+ if (participantUserIDs?.includes(userID as string)) return false;
406
537
 
407
- if (Number(userID) === Number(createdBy.userID) && currentStep !== "releaser") return false;
538
+ if (
539
+ Number(userID) === Number(createdBy.userID) &&
540
+ currentStep !== "releaser"
541
+ )
542
+ return false;
408
543
 
409
544
  const isCanIApprove =
410
- (approve && currentStep === StepType.Signer && roleAllowed && !alreadyApprove && !isMaker) ||
545
+ (approve &&
546
+ currentStep === StepType.Signer &&
547
+ roleAllowed &&
548
+ !alreadyApprove &&
549
+ !isMaker) ||
411
550
  (verify &&
412
- (currentStep === StepType.Verifier || currentStep === StepType.Checker) &&
551
+ (currentStep === StepType.Verifier ||
552
+ currentStep === StepType.Checker) &&
413
553
  roleAllowed &&
414
- !alreadyApprove && !isMaker) ||
415
- (release && currentStep === StepType.Releaser && roleAllowed && !alreadyApprove);
554
+ !alreadyApprove &&
555
+ !isMaker) ||
556
+ (release &&
557
+ currentStep === StepType.Releaser &&
558
+ roleAllowed &&
559
+ !alreadyApprove);
416
560
 
417
561
  if (status) {
418
562
  return isCanIApprove && status === TaskStatus.Pending;
@@ -425,14 +569,18 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
425
569
  const productKey = snakeCase(product).toUpperCase();
426
570
  if (!productKey) return false;
427
571
 
428
- // @ts-ignore
572
+ // @ts-expect-error product authorities key is a enum keyof
429
573
  const authority = productAuthorities[productKey];
430
574
  if (!authority) return false;
431
575
 
432
576
  return status === TaskStatus.Draft && get(authority, "delete");
433
577
  };
434
578
 
435
- const canIEdit = (workflow: TransactionWorkflow.Root, product: string, status: TaskStatus) => {
579
+ const canIEdit = (
580
+ workflow: TransactionWorkflow.Root,
581
+ product: string,
582
+ status: TaskStatus
583
+ ) => {
436
584
  let newProduct = product;
437
585
 
438
586
  if (status === TaskStatus.Returned) {
@@ -447,27 +595,37 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
447
595
  const productKey = snakeCase(product).toUpperCase();
448
596
  if (!productKey) return false;
449
597
 
450
- // @ts-ignore
598
+ // @ts-expect-error product authorities key is a enum keyof
451
599
  const authority = productAuthorities[productKey];
452
600
  if (!authority) return false;
453
601
 
454
602
  const modify = get(authority, "modify");
455
603
 
456
- return (status === TaskStatus.Draft || status === TaskStatus.Returned) && modify;
604
+ return (
605
+ (status === TaskStatus.Draft || status === TaskStatus.Returned) && modify
606
+ );
457
607
  };
458
608
 
459
609
  const passwordLogin = useCallback(
460
- async (username: string, password: string, tokenFCM: string): Promise<void> => {
610
+ async (
611
+ username: string,
612
+ password: string,
613
+ tokenFCM: string
614
+ ): Promise<void> => {
461
615
  setIsLoading(true);
462
616
  try {
463
- const response = await authService.passwordLogin(username, password, tokenFCM);
617
+ const response = await authService.passwordLogin(
618
+ username,
619
+ password,
620
+ tokenFCM
621
+ );
464
622
 
465
623
  setToken(() => response.data.data.accessToken);
466
624
 
467
625
  localStorage.setItem("access-token", response.data.data.accessToken);
468
626
  localStorage.setItem("refresh-token", response.data.data.refreshToken);
469
627
 
470
- router.push("/");
628
+ router.push(baseRoute);
471
629
  } catch (error) {
472
630
  // if (error instanceof Error) message.error(error.message);
473
631
  } finally {
@@ -509,7 +667,9 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
509
667
  const response = await authService.ssoLogin(userId, sessionId, dtTime);
510
668
 
511
669
  if (response.status !== 200) {
512
- if (response.status === 409) setOpenModal(true);
670
+ if (response.status === 409) {
671
+ setOpenModal(true);
672
+ }
513
673
  return;
514
674
  }
515
675
 
@@ -518,7 +678,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
518
678
  localStorage.setItem("access-token", response.data.data.accessToken);
519
679
  localStorage.setItem("refresh-token", response.data.data.refreshToken);
520
680
 
521
- router.push("/");
681
+ router.push(baseRoute);
522
682
  } catch (error: any) {
523
683
  if (onError) {
524
684
  onError(error.message || "Login failed");
@@ -528,37 +688,50 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
528
688
  [authService, router]
529
689
  );
530
690
 
531
- const logout = useCallback(async (path = "/main-page?logout=true") => {
532
- try {
533
- // await authService.logout();
534
- // await authService.logoutSSO("CBM");
535
- } catch (error) {
536
- // Handle errors from logout if needed
537
- } finally {
538
- localStorage.removeItem("access-token");
539
- localStorage.removeItem("refresh-token");
540
- localStorage.removeItem("login");
541
- localStorage.removeItem("productMenu");
542
- localStorage.removeItem("validateMenu");
543
- document.cookie = "loggedIn=true; max-age=0";
544
- document.cookie = "accessToken=; max-age=0";
545
- sessionStorage.clear();
546
- router.push(path);
547
- setToken(() => null);
548
- setMenus(() => []);
549
- setMenuData(() => []);
550
- setAuthorities(() => new Map());
691
+ const logout = useCallback(
692
+ async (path = `${loginRoute}?logout=true`) => {
693
+ try {
694
+ // await authService.logout();
695
+ // await authService.logoutSSO("CBM");
696
+ } catch (error) {
697
+ // Handle errors from logout if needed
698
+ } finally {
699
+ localStorage.removeItem("access-token");
700
+ localStorage.removeItem("refresh-token");
701
+ localStorage.removeItem("login");
702
+ localStorage.removeItem("productMenu");
703
+ localStorage.removeItem("validateMenu");
704
+ document.cookie = "loggedIn=true; max-age=0";
705
+ document.cookie = "accessToken=; max-age=0";
706
+ sessionStorage.clear();
707
+ router.push(path);
708
+ setToken(() => null);
551
709
 
552
- }
553
- }, [authService, router]);
710
+ setSessionLastValidatedAt(null);
711
+ setMenus(() => []);
712
+ setMenuData(() => []);
713
+ setAuthorities(() => new Map());
714
+ }
715
+ },
716
+ [authService, router]
717
+ );
554
718
 
555
- const checkToChangePassword = async (username: string, password: string, tokenFCM: string, branchCode: string): Promise<void> => {
719
+ const checkToChangePassword = async (
720
+ username: string,
721
+ password: string,
722
+ tokenFCM: string,
723
+ branchCode: string
724
+ ): Promise<void> => {
556
725
  setIsLoading(true);
557
726
  try {
558
- const checks = await authService.checkToChangePasswordLogin(username, password, branchCode);
727
+ const checks = await authService.checkToChangePasswordLogin(
728
+ username,
729
+ password,
730
+ branchCode
731
+ );
559
732
  const result = checks?.data;
560
733
  if (result?.data?.IsRedirectToChangePassword) {
561
- router.replace(`/main-page/change-password?branch=${branchCode}`);
734
+ router?.replace?.(`/main-page/change-password?branch=${branchCode}`);
562
735
  } else {
563
736
  passwordLogin(username, password, tokenFCM);
564
737
  }
@@ -569,7 +742,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
569
742
  setIsLoading(false);
570
743
  }, 1000);
571
744
  }
572
- }
745
+ };
573
746
 
574
747
  const requestChangePassword = useCallback(
575
748
  async ({ ...payload }: ChangePasswordType): Promise<any> => {
@@ -578,7 +751,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
578
751
  const response = await authService.requestChangePassword(payload);
579
752
  if (payload.type !== "new-login") {
580
753
  // message.success(response.data.message);
581
- router.replace(`/main-page`);
754
+ router?.replace?.(`/main-page`);
582
755
  }
583
756
  return response;
584
757
  } catch (error) {
@@ -592,36 +765,40 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
592
765
  [authService, router]
593
766
  );
594
767
 
595
- const forgotPassword = async ({ ...payload }: ForgotPasswordType): Promise<any> => {
768
+ const forgotPassword = async ({
769
+ ...payload
770
+ }: ForgotPasswordType): Promise<any> => {
596
771
  setIsLoading(true);
597
772
  try {
598
773
  const response = await authService.forgotPassword(payload);
599
- if(payload.type === "new-login"){
774
+ if (payload.type === "new-login") {
600
775
  return response;
601
776
  }
602
777
  // message.success(response.data.message);
603
- return router.replace(`/main-page`);
778
+ return router?.replace?.(`/main-page`);
604
779
  } catch (error) {
605
- if(payload.type === "new-login"){
780
+ if (payload.type === "new-login") {
606
781
  return Promise.reject(error);
607
782
  }
608
783
  if (error instanceof Error) {
609
784
  // message.error(
610
785
  // "The information you have provided is incorrect, please try again."
611
786
  // );
612
- };
787
+ }
613
788
  } finally {
614
789
  setIsLoading(false);
615
790
  }
616
- }
791
+ };
617
792
 
618
- const verifyUserQuestion = async ({ ...payload }: VerifyUserQuestion): Promise<any> => {
793
+ const verifyUserQuestion = async ({
794
+ ...payload
795
+ }: VerifyUserQuestion): Promise<any> => {
619
796
  setIsLoading(true);
620
797
  try {
621
798
  const response = await authService.verifyUserQuestion(payload);
622
799
  return response;
623
800
  } catch (err: any) {
624
- if(payload.type === "new-login"){
801
+ if (payload.type === "new-login") {
625
802
  return Promise.reject(err);
626
803
  }
627
804
  if (err.response.data.code === 404) {
@@ -631,7 +808,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
631
808
  } finally {
632
809
  setIsLoading(false);
633
810
  }
634
- }
811
+ };
635
812
 
636
813
  const verifyChangePasswordToken = useCallback(
637
814
  async (token: string): Promise<any> => {
@@ -641,29 +818,45 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
641
818
  const response = await authService.verifyChangePasswordToken(payload);
642
819
  const { isValid } = response.data;
643
820
  if (!isValid) {
644
- router.push('/main-page');
645
- return
821
+ router.push(loginRoute);
822
+ return;
646
823
  }
647
824
  return response;
648
- } catch (error: any) {
825
+ } catch (error: unknown) {
826
+ if (error instanceof Error) {
827
+ console.error(error);
649
828
  // message.error(error.response.data.message);
650
- router.push('/main-page');
829
+ router.push(loginRoute);
830
+ }
651
831
  } finally {
652
832
  setIsLoading(false);
653
833
  }
654
834
  },
655
835
  [authService, router]
656
- )
836
+ );
657
837
 
658
- const passwordLoginWithCheck = async (username: string, password: string, tokenFCM: string, branchCode: string): Promise<any> => {
838
+ const passwordLoginWithCheck = async (
839
+ username: string,
840
+ password: string,
841
+ tokenFCM: string,
842
+ branchCode: string
843
+ ): Promise<any> => {
659
844
  setIsLoading(true);
660
845
  try {
661
- const response = await authService.passwordLogin(username, password, tokenFCM);
662
- const checksChangePassword = await authService.checkToChangePasswordLogin(username, password, branchCode);
846
+ const response = await authService.passwordLogin(
847
+ username,
848
+ password,
849
+ tokenFCM
850
+ );
851
+ const checksChangePassword = await authService.checkToChangePasswordLogin(
852
+ username,
853
+ password,
854
+ branchCode
855
+ );
663
856
  const resultChangePassword = checksChangePassword?.data;
664
857
 
665
858
  if (resultChangePassword?.data?.IsRedirectToChangePassword) {
666
- router.replace(`/main-page/change-password?branch=${branchCode}`);
859
+ router?.replace?.(`/main-page/change-password?branch=${branchCode}`);
667
860
  } else {
668
861
  setToken(() => response.data.data.accessToken);
669
862
 
@@ -671,14 +864,14 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
671
864
  localStorage.setItem("refresh-token", response.data.data.refreshToken);
672
865
  localStorage.setItem("locale", "id");
673
866
 
674
- router.push("/");
867
+ router.push(baseRoute);
675
868
  }
676
869
  } catch (error) {
677
870
  // if (error instanceof Error) message.error(error.message);
678
871
  } finally {
679
872
  setIsLoading(false);
680
873
  }
681
- }
874
+ };
682
875
 
683
876
  const ssoQlolaLogin = async (request: string) => {
684
877
  try {
@@ -689,14 +882,19 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
689
882
  localStorage.setItem("refresh-token", response.data.data.refreshToken);
690
883
  localStorage.setItem("agent", response.data.agent);
691
884
 
692
- router.push("/");
885
+ router.push(baseRoute);
693
886
  return;
694
887
  } catch (err: any) {
695
888
  return Promise.reject(err);
696
889
  }
697
- }
890
+ };
698
891
 
699
- const login = async (username: string, password: string, branchCode: string, type?:string): Promise<any> => {
892
+ const login = async (
893
+ username: string,
894
+ password: string,
895
+ branchCode: string,
896
+ type?: string
897
+ ): Promise<any> => {
700
898
  setIsLoading(true);
701
899
  try {
702
900
  const response = await authService.login(username, password, branchCode);
@@ -711,18 +909,18 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
711
909
 
712
910
  if (data.isRedirectToChangePassword) {
713
911
  const token = data.changePasswordToken;
714
- router.push(`/main-page/change-password?token=${token}`);
715
- return
912
+ router.push(`${loginRoute}/change-password?token=${token}`);
913
+ return;
716
914
  }
717
915
 
718
- if(type === "new-login"){
916
+ if (type === "new-login") {
719
917
  return response;
720
918
  }
721
919
 
722
- router.push("/");
723
- return
920
+ router.push(baseRoute);
921
+ return;
724
922
  } catch (error: any) {
725
- if(type === "new-login"){
923
+ if (type === "new-login") {
726
924
  return Promise.reject(error);
727
925
  }
728
926
 
@@ -740,120 +938,176 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children, apiUrl })
740
938
  } finally {
741
939
  setIsLoading(false);
742
940
  }
743
- }
941
+ };
744
942
 
745
- //@ts-ignore
746
- const checkToken : any = async () => {
943
+ const checkToken: any = async () => {
747
944
  setIsLoading(true);
748
945
  try {
749
- const token = localStorage.getItem("access-token")
946
+ const token = localStorage.getItem("access-token");
750
947
  const resp = await authService.validateTokenWithParam(token as string);
751
948
  setIsLoading(false);
752
949
  return Promise.resolve(resp);
753
- } catch (error:any){
754
- if([401].includes(error?.response?.data?.code || error?.response?.status || error.status)){
950
+ } catch (error: any) {
951
+ if (
952
+ [401].includes(
953
+ error?.response?.data?.code || error?.response?.status || error.status
954
+ )
955
+ ) {
755
956
  return refreshToken();
756
957
  }
757
- if([504].includes(error?.response?.data?.code || error?.response?.status || error.status)){
958
+ if (
959
+ [504].includes(
960
+ error?.response?.data?.code || error?.response?.status || error.status
961
+ )
962
+ ) {
758
963
  return checkToken();
759
964
  }
760
- return router.push("/main-page?logout=true")
965
+ return router.push(`${loginRoute}?logout=true`);
761
966
  }
762
- }
763
- //@ts-ignore
967
+ };
968
+
764
969
  const refreshToken = async () => {
765
970
  try {
766
- const refreshToken = localStorage.getItem("refresh-token")
971
+ const refreshToken = localStorage.getItem("refresh-token");
767
972
  const resp = await authService.refreshToken(refreshToken as string);
768
973
  localStorage.setItem("access-token", resp.data.data.accessToken);
769
974
  localStorage.setItem("refresh-token", resp.data.data.refreshToken);
770
975
  return Promise.resolve(resp);
771
- } catch (error:any){
772
- if([504].includes(error?.response?.data?.code || error?.response?.status || error.status)){
976
+ } catch (error: any) {
977
+ if (
978
+ [504].includes(
979
+ error?.response?.data?.code || error?.response?.status || error.status
980
+ )
981
+ ) {
773
982
  return refreshToken();
774
983
  }
775
984
  localStorage.removeItem("access-token");
776
985
  localStorage.removeItem("refresh-token");
777
986
  Promise.reject(error);
778
- return router.push("/main-page?logout=true")
987
+ return router.push(`${loginRoute}?logout=true`);
779
988
  } finally {
780
- return setIsLoading(false);
989
+ setIsLoading(false);
781
990
  }
782
- }
991
+ };
783
992
 
784
993
  useEffect(() => {
785
- if (router.basePath.includes("v2")) {
786
- prevPathnameRef.current = `${router.basePath}${router.asPath}`;
787
- } else {
788
- prevPathnameRef.current = router.asPath;
789
- }
790
-
994
+ prevPathnameRef.current = router.asPath || "";
791
995
  const handleRouteChangeStart = (url: any) => {
792
- const newPath = url.split("?")[0]; // Remove query parameters
996
+ const newPath = url.split("?")[0];
793
997
  const currentPath = prevPathnameRef.current.split("?")[0];
794
-
795
998
  if (newPath !== currentPath) {
796
- setIsAuthoritiesReady(false);
797
999
  prevPathnameRef.current = url;
798
1000
  }
799
1001
  };
800
-
801
- router.events.on("routeChangeStart", handleRouteChangeStart);
802
-
1002
+ router.events?.on?.("routeChangeStart", handleRouteChangeStart);
803
1003
  return () => {
804
- router.events.off("routeChangeStart", handleRouteChangeStart);
1004
+ router.events?.off?.("routeChangeStart", handleRouteChangeStart);
805
1005
  };
806
1006
  }, [router]);
807
1007
 
1008
+ const valueMemoized = useMemo(
1009
+ () => ({
1010
+ token,
1011
+ alertMenuError,
1012
+ authorities,
1013
+ isAuthoritiesReady,
1014
+ productAuthorities,
1015
+ username,
1016
+ userType,
1017
+ menus,
1018
+ loggedIn,
1019
+ companyID,
1020
+ companyName,
1021
+ userMode,
1022
+ companyLevel,
1023
+ roleID,
1024
+ holdingID,
1025
+ isLoading,
1026
+ isIntraday,
1027
+ onboardingTourStatus,
1028
+ userID,
1029
+ guard,
1030
+ passwordLogin,
1031
+ ssoLogin,
1032
+ logout,
1033
+ canIApprove,
1034
+ roleIDs,
1035
+ menuData,
1036
+ ssoQlolaLogin,
1037
+ login,
1038
+ forgotPassword,
1039
+ verifyUserQuestion,
1040
+ verifyChangePasswordToken,
1041
+ checkToChangePassword,
1042
+ passwordLoginWithCheck,
1043
+ requestChangePassword,
1044
+ canIDelete,
1045
+ canIEdit,
1046
+ action,
1047
+ onLeaveAction,
1048
+ setOnLeaveAction,
1049
+ countryCode,
1050
+ setIsLoading,
1051
+ setUserType,
1052
+ setToken,
1053
+ companyCode,
1054
+ region,
1055
+ checkToken,
1056
+ }),
1057
+ [
1058
+ token,
1059
+ alertMenuError,
1060
+ authorities,
1061
+ isAuthoritiesReady,
1062
+ productAuthorities,
1063
+ username,
1064
+ userType,
1065
+ menus,
1066
+ loggedIn,
1067
+ companyID,
1068
+ companyName,
1069
+ userMode,
1070
+ companyLevel,
1071
+ roleID,
1072
+ holdingID,
1073
+ isLoading,
1074
+ userID,
1075
+ guard,
1076
+ passwordLogin,
1077
+ ssoLogin,
1078
+ logout,
1079
+ canIApprove,
1080
+ roleIDs,
1081
+ menuData,
1082
+ ssoQlolaLogin,
1083
+ login,
1084
+ forgotPassword,
1085
+ verifyUserQuestion,
1086
+ verifyChangePasswordToken,
1087
+ checkToChangePassword,
1088
+ passwordLoginWithCheck,
1089
+ requestChangePassword,
1090
+ canIDelete,
1091
+ canIEdit,
1092
+ action,
1093
+ onLeaveAction,
1094
+ setOnLeaveAction,
1095
+ countryCode,
1096
+ setIsLoading,
1097
+ setUserType,
1098
+ setToken,
1099
+ companyCode,
1100
+ region,
1101
+ checkToken,
1102
+ onboardingTourStatus,
1103
+ ]
1104
+ );
1105
+
808
1106
  return (
809
- <IdleTimerProvider {...{ onPrompt, onIdle, onActive, onAction, timeout: isMinutes }}>
810
- <AuthContext.Provider
811
- value={{
812
- token,
813
- alertMenuError,
814
- authorities,
815
- isAuthoritiesReady,
816
- productAuthorities,
817
- username,
818
- userType,
819
- menus,
820
- loggedIn,
821
- companyID,
822
- companyName,
823
- userMode,
824
- companyLevel,
825
- roleID,
826
- holdingID,
827
- isLoading,
828
- userID,
829
- guard,
830
- passwordLogin,
831
- ssoLogin,
832
- logout,
833
- canIApprove,
834
- roleIDs,
835
- menuData,
836
- ssoQlolaLogin,
837
- login,
838
- forgotPassword,
839
- verifyUserQuestion,
840
- verifyChangePasswordToken,
841
- checkToChangePassword,
842
- passwordLoginWithCheck,
843
- requestChangePassword,
844
- canIDelete,
845
- canIEdit,
846
- action,
847
- onLeaveAction,
848
- setOnLeaveAction,
849
- countryCode,
850
- setIsLoading,
851
- setToken,
852
- companyCode,
853
- region,
854
- checkToken
855
- }}
856
- >
1107
+ <IdleTimerProvider
1108
+ {...{ onPrompt, onIdle, onActive, onAction, timeout: isMinutes }}
1109
+ >
1110
+ <AuthContext.Provider value={valueMemoized}>
857
1111
  {children}
858
1112
  </AuthContext.Provider>
859
1113
  </IdleTimerProvider>