varminer-app-header 2.1.2 → 2.1.3
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/AppHeader.d.ts.map +1 -1
- package/dist/index.esm.js +339 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +339 -21
- package/dist/index.js.map +1 -1
- package/dist/utils/localStorage.d.ts +6 -0
- package/dist/utils/localStorage.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -201,6 +201,145 @@ const setI18nLocaleToStorage = (locale) => {
|
|
|
201
201
|
console.error("Error setting i18n locale to localStorage:", err);
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
|
+
/**
|
|
205
|
+
* Decodes a JWT token and returns its payload
|
|
206
|
+
* @param token - JWT token string
|
|
207
|
+
* @returns Decoded payload object or null if decoding fails
|
|
208
|
+
*/
|
|
209
|
+
const decodeJWT = (token) => {
|
|
210
|
+
try {
|
|
211
|
+
if (!token)
|
|
212
|
+
return null;
|
|
213
|
+
// JWT format: header.payload.signature
|
|
214
|
+
const parts = token.split('.');
|
|
215
|
+
if (parts.length !== 3)
|
|
216
|
+
return null;
|
|
217
|
+
// Decode the payload (second part)
|
|
218
|
+
const payload = parts[1];
|
|
219
|
+
// Base64 decode and parse JSON
|
|
220
|
+
// Replace URL-safe base64 characters and add padding if needed
|
|
221
|
+
const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');
|
|
222
|
+
const padded = base64 + '='.repeat((4 - (base64.length % 4)) % 4);
|
|
223
|
+
const decoded = atob(padded);
|
|
224
|
+
return JSON.parse(decoded);
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
console.error("Error decoding JWT token:", err);
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Get all data from localStorage (persist:userdb) including decoded accessToken
|
|
233
|
+
* This function reads all available data without hardcoding and doesn't require any parameters
|
|
234
|
+
* @returns Comprehensive object containing all available data from localStorage and decoded JWT payload
|
|
235
|
+
*/
|
|
236
|
+
const getAllDataFromStorage = () => {
|
|
237
|
+
const userDbString = localStorage.getItem("persist:userdb");
|
|
238
|
+
if (!userDbString) {
|
|
239
|
+
return {
|
|
240
|
+
auth: null,
|
|
241
|
+
user: null,
|
|
242
|
+
authDetails: null,
|
|
243
|
+
userDetails: null,
|
|
244
|
+
profile: null,
|
|
245
|
+
notifications: null,
|
|
246
|
+
messages: null,
|
|
247
|
+
app: null,
|
|
248
|
+
decodedToken: null,
|
|
249
|
+
rawData: null,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
try {
|
|
253
|
+
const parsedOuter = JSON.parse(userDbString);
|
|
254
|
+
// Helper function to parse nested JSON strings
|
|
255
|
+
const parseNested = (value) => {
|
|
256
|
+
if (typeof value === 'string') {
|
|
257
|
+
try {
|
|
258
|
+
return JSON.parse(value);
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
return value;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return value;
|
|
265
|
+
};
|
|
266
|
+
// Parse all top-level keys dynamically (no hardcoding)
|
|
267
|
+
const parsedData = {};
|
|
268
|
+
let authData = null;
|
|
269
|
+
// Helper to recursively find auth data (contains accessToken or refreshToken)
|
|
270
|
+
const findAuthData = (obj) => {
|
|
271
|
+
if (!obj || typeof obj !== 'object')
|
|
272
|
+
return null;
|
|
273
|
+
// Check if this object itself is auth data
|
|
274
|
+
if (obj.accessToken || obj.refreshToken) {
|
|
275
|
+
return obj;
|
|
276
|
+
}
|
|
277
|
+
// Recursively search in nested objects
|
|
278
|
+
for (const key in obj) {
|
|
279
|
+
if (obj.hasOwnProperty(key)) {
|
|
280
|
+
const nested = findAuthData(obj[key]);
|
|
281
|
+
if (nested)
|
|
282
|
+
return nested;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
};
|
|
287
|
+
// Parse all keys in parsedOuter dynamically
|
|
288
|
+
Object.keys(parsedOuter).forEach((key) => {
|
|
289
|
+
parsedData[key] = parseNested(parsedOuter[key]);
|
|
290
|
+
// Dynamically find auth data in any structure
|
|
291
|
+
const foundAuth = findAuthData(parsedData[key]);
|
|
292
|
+
if (foundAuth && !authData) {
|
|
293
|
+
authData = foundAuth;
|
|
294
|
+
parsedData.auth = authData;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
// Get accessToken and decode it
|
|
298
|
+
let decodedToken = null;
|
|
299
|
+
const accessToken = authData?.accessToken || parsedData.auth?.accessToken || parsedData.authDetails?.accessToken;
|
|
300
|
+
if (accessToken) {
|
|
301
|
+
decodedToken = decodeJWT(accessToken);
|
|
302
|
+
}
|
|
303
|
+
// Extract all auth-related fields from authData dynamically (no hardcoding)
|
|
304
|
+
const authFields = authData ? Object.keys(authData).reduce((acc, key) => {
|
|
305
|
+
acc[key] = authData[key] !== undefined ? authData[key] : null;
|
|
306
|
+
return acc;
|
|
307
|
+
}, {}) : null;
|
|
308
|
+
// Build return object dynamically with all parsed data
|
|
309
|
+
const result = {
|
|
310
|
+
...Object.keys(parsedData).reduce((acc, key) => {
|
|
311
|
+
acc[key] = parsedData[key] !== undefined ? parsedData[key] : null;
|
|
312
|
+
return acc;
|
|
313
|
+
}, {}),
|
|
314
|
+
decodedToken: decodedToken ? Object.keys(decodedToken).reduce((acc, key) => {
|
|
315
|
+
acc[key] = decodedToken[key] !== undefined ? decodedToken[key] : null;
|
|
316
|
+
return acc;
|
|
317
|
+
}, {}) : null,
|
|
318
|
+
rawData: parsedOuter, // Include raw parsed data for any other fields
|
|
319
|
+
};
|
|
320
|
+
// Add auth field if we have authData
|
|
321
|
+
if (authFields) {
|
|
322
|
+
result.auth = authFields;
|
|
323
|
+
}
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
326
|
+
catch (err) {
|
|
327
|
+
console.error("Error parsing all data from localStorage:", err);
|
|
328
|
+
return {
|
|
329
|
+
auth: null,
|
|
330
|
+
user: null,
|
|
331
|
+
authDetails: null,
|
|
332
|
+
userDetails: null,
|
|
333
|
+
profile: null,
|
|
334
|
+
notifications: null,
|
|
335
|
+
messages: null,
|
|
336
|
+
app: null,
|
|
337
|
+
decodedToken: null,
|
|
338
|
+
rawData: null,
|
|
339
|
+
error: err instanceof Error ? err.message : 'Unknown error',
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
};
|
|
204
343
|
|
|
205
344
|
const translations = {
|
|
206
345
|
en: {
|
|
@@ -310,8 +449,8 @@ const LanguageSelector = ({ currentLanguage, onLanguageChange, }) => {
|
|
|
310
449
|
|
|
311
450
|
const DEFAULT_ROUTES = {
|
|
312
451
|
settings: "/account/overview",
|
|
313
|
-
profile: "/profile",
|
|
314
|
-
logout: "/logout",
|
|
452
|
+
profile: "/user/profile",
|
|
453
|
+
logout: "/user/logout",
|
|
315
454
|
};
|
|
316
455
|
const AppHeader = ({ language: languageProp }) => {
|
|
317
456
|
// Get initial language from props, URL, localStorage, or default to 'en'
|
|
@@ -344,14 +483,61 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
344
483
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
345
484
|
const [mobileMoreAnchorEl, setMobileMoreAnchorEl] = React.useState(null);
|
|
346
485
|
const [user, setUser] = React.useState(() => {
|
|
486
|
+
const allData = getAllDataFromStorage();
|
|
487
|
+
// Try to get user data from various sources
|
|
488
|
+
let userName = "";
|
|
489
|
+
let userEmail = "";
|
|
490
|
+
let userRole = "";
|
|
491
|
+
// Priority 1: From decoded token
|
|
492
|
+
if (allData.decodedToken) {
|
|
493
|
+
userName = allData.decodedToken.sub || allData.decodedToken.email || "";
|
|
494
|
+
userEmail = allData.decodedToken.sub || allData.decodedToken.email || "";
|
|
495
|
+
userRole = allData.decodedToken.role || "";
|
|
496
|
+
}
|
|
497
|
+
// Priority 2: From auth data
|
|
498
|
+
if (allData.auth) {
|
|
499
|
+
userName = userName || allData.auth.name || allData.auth.email || "";
|
|
500
|
+
userEmail = userEmail || allData.auth.email || allData.auth.sub || "";
|
|
501
|
+
userRole = userRole || allData.auth.role || allData.auth.activeRole || "";
|
|
502
|
+
}
|
|
503
|
+
// Priority 3: From userDetails/user/profile
|
|
347
504
|
const storedUser = getUserDataFromStorage();
|
|
348
|
-
if (storedUser
|
|
349
|
-
|
|
505
|
+
if (storedUser) {
|
|
506
|
+
userName = userName || storedUser.name || "";
|
|
507
|
+
userEmail = userEmail || storedUser.email || "";
|
|
508
|
+
userRole = userRole || storedUser.role || "";
|
|
509
|
+
}
|
|
510
|
+
// Priority 4: From other parsed data
|
|
511
|
+
if (allData.userDetails) {
|
|
512
|
+
const userDetails = allData.userDetails.user || allData.userDetails.data || allData.userDetails;
|
|
513
|
+
if (userDetails) {
|
|
514
|
+
userName = userName || userDetails.name || userDetails.fullName || "";
|
|
515
|
+
userEmail = userEmail || userDetails.email || userDetails.emailAddress || "";
|
|
516
|
+
userRole = userRole || userDetails.role || userDetails.userRole || "";
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (allData.user) {
|
|
520
|
+
const userData = allData.user.user || allData.user.data || allData.user.currentUser || allData.user;
|
|
521
|
+
if (userData) {
|
|
522
|
+
userName = userName || userData.name || userData.fullName || "";
|
|
523
|
+
userEmail = userEmail || userData.email || userData.emailAddress || "";
|
|
524
|
+
userRole = userRole || userData.role || userData.userRole || "";
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (allData.profile) {
|
|
528
|
+
const profileData = allData.profile.user || allData.profile.data || allData.profile;
|
|
529
|
+
if (profileData) {
|
|
530
|
+
userName = userName || profileData.name || profileData.fullName || "";
|
|
531
|
+
userEmail = userEmail || profileData.email || profileData.emailAddress || "";
|
|
532
|
+
userRole = userRole || profileData.role || profileData.userRole || "";
|
|
533
|
+
}
|
|
350
534
|
}
|
|
351
535
|
return {
|
|
352
|
-
name: "
|
|
353
|
-
email: "
|
|
354
|
-
role:
|
|
536
|
+
name: userName || "",
|
|
537
|
+
email: userEmail || "",
|
|
538
|
+
role: userRole || "",
|
|
539
|
+
avatar: storedUser?.avatar || allData.auth?.avatar || allData.profile?.avatar || undefined,
|
|
540
|
+
initials: storedUser?.initials || allData.auth?.initials || allData.profile?.initials || undefined,
|
|
355
541
|
};
|
|
356
542
|
});
|
|
357
543
|
const [notificationCount, setNotificationCount] = React.useState(() => {
|
|
@@ -362,16 +548,86 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
362
548
|
return getMessageCountFromStorage() ?? undefined;
|
|
363
549
|
});
|
|
364
550
|
React.useEffect(() => {
|
|
551
|
+
const allData = getAllDataFromStorage();
|
|
552
|
+
// Try to get user data from various sources
|
|
553
|
+
let userName = "";
|
|
554
|
+
let userEmail = "";
|
|
555
|
+
let userRole = "";
|
|
556
|
+
let userAvatar = undefined;
|
|
557
|
+
let userInitials = undefined;
|
|
558
|
+
// Priority 1: From decoded token
|
|
559
|
+
if (allData.decodedToken) {
|
|
560
|
+
userName = allData.decodedToken.sub || allData.decodedToken.email || "";
|
|
561
|
+
userEmail = allData.decodedToken.sub || allData.decodedToken.email || "";
|
|
562
|
+
userRole = allData.decodedToken.role || "";
|
|
563
|
+
}
|
|
564
|
+
// Priority 2: From auth data
|
|
565
|
+
if (allData.auth) {
|
|
566
|
+
userName = userName || allData.auth.name || allData.auth.email || "";
|
|
567
|
+
userEmail = userEmail || allData.auth.email || allData.auth.sub || "";
|
|
568
|
+
userRole = userRole || allData.auth.role || allData.auth.activeRole || "";
|
|
569
|
+
userAvatar = userAvatar || allData.auth.avatar || undefined;
|
|
570
|
+
userInitials = userInitials || allData.auth.initials || undefined;
|
|
571
|
+
}
|
|
572
|
+
// Priority 3: From userDetails/user/profile
|
|
365
573
|
const storedUser = getUserDataFromStorage();
|
|
366
|
-
if (storedUser
|
|
367
|
-
|
|
574
|
+
if (storedUser) {
|
|
575
|
+
userName = userName || storedUser.name || "";
|
|
576
|
+
userEmail = userEmail || storedUser.email || "";
|
|
577
|
+
userRole = userRole || storedUser.role || "";
|
|
578
|
+
userAvatar = userAvatar || storedUser.avatar || undefined;
|
|
579
|
+
userInitials = userInitials || storedUser.initials || undefined;
|
|
580
|
+
}
|
|
581
|
+
// Priority 4: From other parsed data
|
|
582
|
+
if (allData.userDetails) {
|
|
583
|
+
const userDetails = allData.userDetails.user || allData.userDetails.data || allData.userDetails;
|
|
584
|
+
if (userDetails) {
|
|
585
|
+
userName = userName || userDetails.name || userDetails.fullName || "";
|
|
586
|
+
userEmail = userEmail || userDetails.email || userDetails.emailAddress || "";
|
|
587
|
+
userRole = userRole || userDetails.role || userDetails.userRole || "";
|
|
588
|
+
userAvatar = userAvatar || userDetails.avatar || userDetails.profilePicture || undefined;
|
|
589
|
+
userInitials = userInitials || userDetails.initials || undefined;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (allData.user) {
|
|
593
|
+
const userData = allData.user.user || allData.user.data || allData.user.currentUser || allData.user;
|
|
594
|
+
if (userData) {
|
|
595
|
+
userName = userName || userData.name || userData.fullName || "";
|
|
596
|
+
userEmail = userEmail || userData.email || userData.emailAddress || "";
|
|
597
|
+
userRole = userRole || userData.role || userData.userRole || "";
|
|
598
|
+
userAvatar = userAvatar || userData.avatar || userData.profilePicture || undefined;
|
|
599
|
+
userInitials = userInitials || userData.initials || undefined;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
if (allData.profile) {
|
|
603
|
+
const profileData = allData.profile.user || allData.profile.data || allData.profile;
|
|
604
|
+
if (profileData) {
|
|
605
|
+
userName = userName || profileData.name || profileData.fullName || "";
|
|
606
|
+
userEmail = userEmail || profileData.email || profileData.emailAddress || "";
|
|
607
|
+
userRole = userRole || profileData.role || profileData.userRole || "";
|
|
608
|
+
userAvatar = userAvatar || profileData.avatar || profileData.profilePicture || undefined;
|
|
609
|
+
userInitials = userInitials || profileData.initials || undefined;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
setUser({
|
|
613
|
+
name: userName || "",
|
|
614
|
+
email: userEmail || "",
|
|
615
|
+
role: userRole || "",
|
|
616
|
+
avatar: userAvatar,
|
|
617
|
+
initials: userInitials,
|
|
618
|
+
});
|
|
619
|
+
// Update online status
|
|
620
|
+
if (allData.auth?.isOnline !== undefined) {
|
|
621
|
+
setIsOnlineStatus(allData.auth.isOnline);
|
|
368
622
|
}
|
|
369
|
-
else {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
623
|
+
else if (allData.userDetails?.isOnline !== undefined) {
|
|
624
|
+
setIsOnlineStatus(allData.userDetails.isOnline);
|
|
625
|
+
}
|
|
626
|
+
else if (allData.user?.isOnline !== undefined) {
|
|
627
|
+
setIsOnlineStatus(allData.user.isOnline);
|
|
628
|
+
}
|
|
629
|
+
else if (allData.profile?.isOnline !== undefined) {
|
|
630
|
+
setIsOnlineStatus(allData.profile.isOnline);
|
|
375
631
|
}
|
|
376
632
|
const notifCount = getNotificationCountFromStorage();
|
|
377
633
|
setNotificationCount(notifCount !== null && notifCount !== undefined ? notifCount : 0);
|
|
@@ -384,6 +640,24 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
384
640
|
}
|
|
385
641
|
}, [languageProp]);
|
|
386
642
|
const finalRoutes = DEFAULT_ROUTES;
|
|
643
|
+
// Get online status from localStorage dynamically
|
|
644
|
+
const [isOnlineStatus, setIsOnlineStatus] = React.useState(() => {
|
|
645
|
+
const allData = getAllDataFromStorage();
|
|
646
|
+
if (allData.auth?.isOnline !== undefined) {
|
|
647
|
+
return allData.auth.isOnline;
|
|
648
|
+
}
|
|
649
|
+
if (allData.userDetails?.isOnline !== undefined) {
|
|
650
|
+
return allData.userDetails.isOnline;
|
|
651
|
+
}
|
|
652
|
+
if (allData.user?.isOnline !== undefined) {
|
|
653
|
+
return allData.user.isOnline;
|
|
654
|
+
}
|
|
655
|
+
if (allData.profile?.isOnline !== undefined) {
|
|
656
|
+
return allData.profile.isOnline;
|
|
657
|
+
}
|
|
658
|
+
// Default to true if not specified (for backward compatibility)
|
|
659
|
+
return true;
|
|
660
|
+
});
|
|
387
661
|
const notificationCountValue = notificationCount;
|
|
388
662
|
const isMobileMenuOpen = Boolean(mobileMoreAnchorEl);
|
|
389
663
|
const OnlineBadge = material.styled(material.Badge)(({ theme }) => ({
|
|
@@ -396,7 +670,7 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
396
670
|
borderRadius: "50%",
|
|
397
671
|
},
|
|
398
672
|
}));
|
|
399
|
-
material.styled(material.Badge)(({ theme }) => ({
|
|
673
|
+
const OfflineBadge = material.styled(material.Badge)(({ theme }) => ({
|
|
400
674
|
"& .MuiBadge-badge": {
|
|
401
675
|
backgroundColor: "gray",
|
|
402
676
|
color: "gray",
|
|
@@ -452,11 +726,50 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
452
726
|
.toUpperCase()
|
|
453
727
|
.slice(0, 2);
|
|
454
728
|
};
|
|
729
|
+
// Check if user has permission to see settings (Account Owner, Account Admin, or Global Admin)
|
|
730
|
+
const canViewSettings = React.useMemo(() => {
|
|
731
|
+
const allData = getAllDataFromStorage();
|
|
732
|
+
let userRole = "";
|
|
733
|
+
// Get role from decoded token
|
|
734
|
+
if (allData.decodedToken?.role) {
|
|
735
|
+
userRole = allData.decodedToken.role;
|
|
736
|
+
}
|
|
737
|
+
// Get role from auth data
|
|
738
|
+
else if (allData.auth?.role) {
|
|
739
|
+
userRole = allData.auth.role;
|
|
740
|
+
}
|
|
741
|
+
// Get role from user data
|
|
742
|
+
else if (user.role) {
|
|
743
|
+
userRole = user.role;
|
|
744
|
+
}
|
|
745
|
+
// Get role from userDetails
|
|
746
|
+
else if (allData.userDetails) {
|
|
747
|
+
const userDetails = allData.userDetails.user || allData.userDetails.data || allData.userDetails;
|
|
748
|
+
userRole = userDetails?.role || userDetails?.userRole || "";
|
|
749
|
+
}
|
|
750
|
+
// Get role from user
|
|
751
|
+
else if (allData.user) {
|
|
752
|
+
const userData = allData.user.user || allData.user.data || allData.user.currentUser || allData.user;
|
|
753
|
+
userRole = userData?.role || userData?.userRole || "";
|
|
754
|
+
}
|
|
755
|
+
// Normalize role for comparison (case-insensitive, handle spaces/underscores/hyphens)
|
|
756
|
+
const normalizedRole = userRole.toLowerCase().trim().replace(/[_\s-]+/g, " ");
|
|
757
|
+
const allowedRoles = [
|
|
758
|
+
"account owner",
|
|
759
|
+
"account admin",
|
|
760
|
+
"global admin"
|
|
761
|
+
];
|
|
762
|
+
// Check for exact match or if role starts with allowed role
|
|
763
|
+
// This handles variations like "Account Owner", "ACCOUNT_OWNER", "Account-Owner", "Account Owner - Manager"
|
|
764
|
+
return allowedRoles.some(allowedRole => {
|
|
765
|
+
return normalizedRole === allowedRole || normalizedRole.startsWith(allowedRole + " ");
|
|
766
|
+
});
|
|
767
|
+
}, [user.role]);
|
|
455
768
|
const profileList = (jsxRuntime.jsx(material.List, { className: "profile-menu-section", sx: {
|
|
456
769
|
width: "100%",
|
|
457
770
|
maxWidth: 360,
|
|
458
771
|
pointerEvents: "none",
|
|
459
|
-
}, component: "div", "aria-hidden": "true", tabIndex: -1, children: jsxRuntime.jsxs(material.ListItem, { alignItems: "flex-start", className: "profile-menu-item", children: [jsxRuntime.jsx(material.ListItemAvatar, { children: (jsxRuntime.jsx(OnlineBadge, { overlap: "circular", anchorOrigin: { vertical: "bottom", horizontal: "right" }, variant: "dot", title: t.online, "aria-label": `${t.online} status badge`, "data-testid": "online-badge", children: jsxRuntime.jsx(material.Avatar, { sx: { bgcolor: colors.deepOrange[500] }, alt: user.name, title: user.name, src: user.avatar, children: getInitials() }) }))
|
|
772
|
+
}, component: "div", "aria-hidden": "true", tabIndex: -1, children: jsxRuntime.jsxs(material.ListItem, { alignItems: "flex-start", className: "profile-menu-item", children: [jsxRuntime.jsx(material.ListItemAvatar, { children: isOnlineStatus ? (jsxRuntime.jsx(OnlineBadge, { overlap: "circular", anchorOrigin: { vertical: "bottom", horizontal: "right" }, variant: "dot", title: t.online, "aria-label": `${t.online} status badge`, "data-testid": "online-badge", children: jsxRuntime.jsx(material.Avatar, { sx: { bgcolor: colors.deepOrange[500] }, alt: user.name, title: user.name, src: user.avatar, children: getInitials() }) })) : (jsxRuntime.jsx(OfflineBadge, { overlap: "circular", anchorOrigin: { vertical: "bottom", horizontal: "right" }, variant: "dot", title: t.offline, "aria-label": `${t.offline} status badge`, "data-testid": "offline-badge", children: jsxRuntime.jsx(material.Avatar, { sx: { bgcolor: colors.deepOrange[500] }, alt: user.name, title: user.name, src: user.avatar, children: getInitials() }) })) }), jsxRuntime.jsx(material.ListItemText, { secondary: jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(material.Typography, { className: "profile-name", component: "p", children: user.name }), jsxRuntime.jsx(material.Typography, { className: "profile-email", component: "p", children: user.email }), jsxRuntime.jsxs(material.Typography, { className: "profile-role", component: "p", children: [t.role, ": ", user.role] })] }) })] }) }));
|
|
460
773
|
const renderMenu = (jsxRuntime.jsxs(material.Menu, { anchorEl: anchorEl, id: "account-menu", open: open, onClose: handleClose, onClick: handleClose, slotProps: {
|
|
461
774
|
paper: {
|
|
462
775
|
elevation: 0,
|
|
@@ -484,7 +797,7 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
484
797
|
},
|
|
485
798
|
},
|
|
486
799
|
},
|
|
487
|
-
}, transformOrigin: { horizontal: "right", vertical: "top" }, anchorOrigin: { horizontal: "right", vertical: "bottom" }, children: [profileList, jsxRuntime.jsx(material.Divider, {}), jsxRuntime.jsxs(material.MenuItem, { onClick:
|
|
800
|
+
}, transformOrigin: { horizontal: "right", vertical: "top" }, anchorOrigin: { horizontal: "right", vertical: "bottom" }, children: [profileList, jsxRuntime.jsx(material.Divider, {}), jsxRuntime.jsxs(material.MenuItem, { onClick: handleProfileClick, children: [jsxRuntime.jsx(material.ListItemIcon, { children: jsxRuntime.jsx(PersonOutlineOutlinedIcon, { fontSize: "small" }) }), t.profile] }), canViewSettings && (jsxRuntime.jsxs(material.MenuItem, { onClick: handleSettingsClick, children: [jsxRuntime.jsx(material.ListItemIcon, { children: jsxRuntime.jsx(SettingsOutlinedIcon, { fontSize: "small" }) }), t.accountSettings] })), jsxRuntime.jsxs(material.MenuItem, { onClick: handleSignOutClick, children: [jsxRuntime.jsx(material.ListItemIcon, { children: jsxRuntime.jsx(LogoutOutlinedIcon, { fontSize: "small" }) }), t.signOut] })] }));
|
|
488
801
|
const mobileMenuId = "primary-account-menu-mobile";
|
|
489
802
|
const renderMobileMenu = (jsxRuntime.jsxs(material.Menu, { anchorEl: mobileMoreAnchorEl, anchorOrigin: {
|
|
490
803
|
vertical: "top",
|
|
@@ -492,7 +805,7 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
492
805
|
}, id: mobileMenuId, keepMounted: true, transformOrigin: {
|
|
493
806
|
vertical: "top",
|
|
494
807
|
horizontal: "right",
|
|
495
|
-
}, open: isMobileMenuOpen, onClose: handleMobileMenuClose, children: [messageCount !== undefined && (jsxRuntime.jsxs(material.MenuItem, { children: [jsxRuntime.jsx(material.IconButton, { size: "large", "aria-label": `show ${messageCount} new mails`, sx: { color: '#1e2f97' }, children: jsxRuntime.jsx(material.Badge, { badgeContent: messageCount, color: "error", children: jsxRuntime.jsx(MailIcon, {}) }) }), jsxRuntime.jsx("p", { children: t.messages })] })), notificationCountValue > 0 && (jsxRuntime.jsxs(material.MenuItem, { children: [jsxRuntime.jsx(material.IconButton, { size: "large", "aria-label": `show ${notificationCountValue} new notifications`, sx: { color: '#1e2f97' }, children: jsxRuntime.jsx(material.Badge, { badgeContent: notificationCount, color: "error", children: jsxRuntime.jsx(NotificationsActiveOutlined, {}) }) }), jsxRuntime.jsx("p", { children: t.notifications })] })), jsxRuntime.jsxs(material.MenuItem, { onClick: handleProfileMenuOpen, children: [jsxRuntime.jsx(material.IconButton, { size: "large", "aria-label": "account of current user", "aria-controls": "primary-account-menu", "aria-haspopup": "true", sx: { color: '#1e2f97' }, children: (jsxRuntime.jsx(OnlineBadge, { overlap: "circular", anchorOrigin: { vertical: "bottom", horizontal: "right" }, variant: "dot", title: t.online, "aria-label": `${t.online} status badge`, "data-testid": "online-badge", children: jsxRuntime.jsx(AccountCircle, { titleAccess: user.name, "aria-label": "User avatar" }) }))
|
|
808
|
+
}, open: isMobileMenuOpen, onClose: handleMobileMenuClose, children: [messageCount !== undefined && (jsxRuntime.jsxs(material.MenuItem, { children: [jsxRuntime.jsx(material.IconButton, { size: "large", "aria-label": `show ${messageCount} new mails`, sx: { color: '#1e2f97' }, children: jsxRuntime.jsx(material.Badge, { badgeContent: messageCount, color: "error", children: jsxRuntime.jsx(MailIcon, {}) }) }), jsxRuntime.jsx("p", { children: t.messages })] })), notificationCountValue > 0 && (jsxRuntime.jsxs(material.MenuItem, { children: [jsxRuntime.jsx(material.IconButton, { size: "large", "aria-label": `show ${notificationCountValue} new notifications`, sx: { color: '#1e2f97' }, children: jsxRuntime.jsx(material.Badge, { badgeContent: notificationCount, color: "error", children: jsxRuntime.jsx(NotificationsActiveOutlined, {}) }) }), jsxRuntime.jsx("p", { children: t.notifications })] })), jsxRuntime.jsxs(material.MenuItem, { onClick: handleProfileMenuOpen, children: [jsxRuntime.jsx(material.IconButton, { size: "large", "aria-label": "account of current user", "aria-controls": "primary-account-menu", "aria-haspopup": "true", sx: { color: '#1e2f97' }, children: isOnlineStatus ? (jsxRuntime.jsx(OnlineBadge, { overlap: "circular", anchorOrigin: { vertical: "bottom", horizontal: "right" }, variant: "dot", title: t.online, "aria-label": `${t.online} status badge`, "data-testid": "online-badge", children: jsxRuntime.jsx(AccountCircle, { titleAccess: user.name, "aria-label": "User avatar" }) })) : (jsxRuntime.jsx(OfflineBadge, { overlap: "circular", anchorOrigin: { vertical: "bottom", horizontal: "right" }, variant: "dot", title: t.offline, "aria-label": `${t.offline} status badge`, "data-testid": "offline-badge", children: jsxRuntime.jsx(AccountCircle, { titleAccess: user.name, "aria-label": "User avatar" }) })) }), jsxRuntime.jsx("p", { children: t.profile })] })] }));
|
|
496
809
|
return (jsxRuntime.jsxs(material.Box, { sx: { flexGrow: 1 }, className: "app-header", children: [jsxRuntime.jsx(material.AppBar, { elevation: 0, sx: {
|
|
497
810
|
backgroundColor: "#ffffff",
|
|
498
811
|
boxShadow: 'none !important',
|
|
@@ -526,12 +839,17 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
526
839
|
'&:hover': {
|
|
527
840
|
backgroundColor: 'rgba(30, 47, 151, 0.04)',
|
|
528
841
|
}
|
|
529
|
-
}, children: (jsxRuntime.jsx(OnlineBadge, { overlap: "circular", anchorOrigin: { vertical: "bottom", horizontal: "right" }, variant: "dot", title:
|
|
842
|
+
}, children: isOnlineStatus ? (jsxRuntime.jsx(OnlineBadge, { overlap: "circular", anchorOrigin: { vertical: "bottom", horizontal: "right" }, variant: "dot", title: t.online, "aria-label": `${t.online} status badge`, "data-testid": "online-badge", children: jsxRuntime.jsx(material.Avatar, { sx: {
|
|
843
|
+
bgcolor: colors.deepOrange[500],
|
|
844
|
+
width: 20,
|
|
845
|
+
height: 20,
|
|
846
|
+
p: 1,
|
|
847
|
+
}, alt: user.name, title: user.name, src: user.avatar, sizes: "large", children: getInitials() }) })) : (jsxRuntime.jsx(OfflineBadge, { overlap: "circular", anchorOrigin: { vertical: "bottom", horizontal: "right" }, variant: "dot", title: t.offline, "aria-label": `${t.offline} status badge`, "data-testid": "offline-badge", children: jsxRuntime.jsx(material.Avatar, { sx: {
|
|
530
848
|
bgcolor: colors.deepOrange[500],
|
|
531
849
|
width: 20,
|
|
532
850
|
height: 20,
|
|
533
851
|
p: 1,
|
|
534
|
-
}, alt: user.name, title: user.name, src: user.avatar,
|
|
852
|
+
}, alt: user.name, title: user.name, src: user.avatar, children: getInitials() }) })) })] }), jsxRuntime.jsx(material.Box, { sx: { display: { xs: "flex", md: "none" } }, children: jsxRuntime.jsx(material.IconButton, { size: "large", "aria-label": "show more", "aria-controls": mobileMenuId, "aria-haspopup": "true", onClick: handleMobileMenuOpen, sx: {
|
|
535
853
|
color: '#1e2f97',
|
|
536
854
|
'&:hover': {
|
|
537
855
|
backgroundColor: 'rgba(30, 47, 151, 0.04)',
|