varminer-app-header 2.1.2 → 2.1.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AppHeader.d.ts","sourceRoot":"","sources":["../src/AppHeader.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAe,MAAM,SAAS,CAAC;AAKtD,OAAO,sBAAsB,CAAC;AAQ9B,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAmiBvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"AppHeader.d.ts","sourceRoot":"","sources":["../src/AppHeader.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAe,MAAM,SAAS,CAAC;AAKtD,OAAO,sBAAsB,CAAC;AAQ9B,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAuuBvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
package/dist/index.esm.js CHANGED
@@ -181,6 +181,145 @@ const setI18nLocaleToStorage = (locale) => {
181
181
  console.error("Error setting i18n locale to localStorage:", err);
182
182
  }
183
183
  };
184
+ /**
185
+ * Decodes a JWT token and returns its payload
186
+ * @param token - JWT token string
187
+ * @returns Decoded payload object or null if decoding fails
188
+ */
189
+ const decodeJWT = (token) => {
190
+ try {
191
+ if (!token)
192
+ return null;
193
+ // JWT format: header.payload.signature
194
+ const parts = token.split('.');
195
+ if (parts.length !== 3)
196
+ return null;
197
+ // Decode the payload (second part)
198
+ const payload = parts[1];
199
+ // Base64 decode and parse JSON
200
+ // Replace URL-safe base64 characters and add padding if needed
201
+ const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');
202
+ const padded = base64 + '='.repeat((4 - (base64.length % 4)) % 4);
203
+ const decoded = atob(padded);
204
+ return JSON.parse(decoded);
205
+ }
206
+ catch (err) {
207
+ console.error("Error decoding JWT token:", err);
208
+ return null;
209
+ }
210
+ };
211
+ /**
212
+ * Get all data from localStorage (persist:userdb) including decoded accessToken
213
+ * This function reads all available data without hardcoding and doesn't require any parameters
214
+ * @returns Comprehensive object containing all available data from localStorage and decoded JWT payload
215
+ */
216
+ const getAllDataFromStorage = () => {
217
+ const userDbString = localStorage.getItem("persist:userdb");
218
+ if (!userDbString) {
219
+ return {
220
+ auth: null,
221
+ user: null,
222
+ authDetails: null,
223
+ userDetails: null,
224
+ profile: null,
225
+ notifications: null,
226
+ messages: null,
227
+ app: null,
228
+ decodedToken: null,
229
+ rawData: null,
230
+ };
231
+ }
232
+ try {
233
+ const parsedOuter = JSON.parse(userDbString);
234
+ // Helper function to parse nested JSON strings
235
+ const parseNested = (value) => {
236
+ if (typeof value === 'string') {
237
+ try {
238
+ return JSON.parse(value);
239
+ }
240
+ catch {
241
+ return value;
242
+ }
243
+ }
244
+ return value;
245
+ };
246
+ // Parse all top-level keys dynamically (no hardcoding)
247
+ const parsedData = {};
248
+ let authData = null;
249
+ // Helper to recursively find auth data (contains accessToken or refreshToken)
250
+ const findAuthData = (obj) => {
251
+ if (!obj || typeof obj !== 'object')
252
+ return null;
253
+ // Check if this object itself is auth data
254
+ if (obj.accessToken || obj.refreshToken) {
255
+ return obj;
256
+ }
257
+ // Recursively search in nested objects
258
+ for (const key in obj) {
259
+ if (obj.hasOwnProperty(key)) {
260
+ const nested = findAuthData(obj[key]);
261
+ if (nested)
262
+ return nested;
263
+ }
264
+ }
265
+ return null;
266
+ };
267
+ // Parse all keys in parsedOuter dynamically
268
+ Object.keys(parsedOuter).forEach((key) => {
269
+ parsedData[key] = parseNested(parsedOuter[key]);
270
+ // Dynamically find auth data in any structure
271
+ const foundAuth = findAuthData(parsedData[key]);
272
+ if (foundAuth && !authData) {
273
+ authData = foundAuth;
274
+ parsedData.auth = authData;
275
+ }
276
+ });
277
+ // Get accessToken and decode it
278
+ let decodedToken = null;
279
+ const accessToken = authData?.accessToken || parsedData.auth?.accessToken || parsedData.authDetails?.accessToken;
280
+ if (accessToken) {
281
+ decodedToken = decodeJWT(accessToken);
282
+ }
283
+ // Extract all auth-related fields from authData dynamically (no hardcoding)
284
+ const authFields = authData ? Object.keys(authData).reduce((acc, key) => {
285
+ acc[key] = authData[key] !== undefined ? authData[key] : null;
286
+ return acc;
287
+ }, {}) : null;
288
+ // Build return object dynamically with all parsed data
289
+ const result = {
290
+ ...Object.keys(parsedData).reduce((acc, key) => {
291
+ acc[key] = parsedData[key] !== undefined ? parsedData[key] : null;
292
+ return acc;
293
+ }, {}),
294
+ decodedToken: decodedToken ? Object.keys(decodedToken).reduce((acc, key) => {
295
+ acc[key] = decodedToken[key] !== undefined ? decodedToken[key] : null;
296
+ return acc;
297
+ }, {}) : null,
298
+ rawData: parsedOuter, // Include raw parsed data for any other fields
299
+ };
300
+ // Add auth field if we have authData
301
+ if (authFields) {
302
+ result.auth = authFields;
303
+ }
304
+ return result;
305
+ }
306
+ catch (err) {
307
+ console.error("Error parsing all data from localStorage:", err);
308
+ return {
309
+ auth: null,
310
+ user: null,
311
+ authDetails: null,
312
+ userDetails: null,
313
+ profile: null,
314
+ notifications: null,
315
+ messages: null,
316
+ app: null,
317
+ decodedToken: null,
318
+ rawData: null,
319
+ error: err instanceof Error ? err.message : 'Unknown error',
320
+ };
321
+ }
322
+ };
184
323
 
185
324
  const translations = {
186
325
  en: {
@@ -290,8 +429,8 @@ const LanguageSelector = ({ currentLanguage, onLanguageChange, }) => {
290
429
 
291
430
  const DEFAULT_ROUTES = {
292
431
  settings: "/account/overview",
293
- profile: "/profile",
294
- logout: "/logout",
432
+ profile: "/user/profile",
433
+ logout: "/user/login",
295
434
  };
296
435
  const AppHeader = ({ language: languageProp }) => {
297
436
  // Get initial language from props, URL, localStorage, or default to 'en'
@@ -324,14 +463,61 @@ const AppHeader = ({ language: languageProp }) => {
324
463
  const [anchorEl, setAnchorEl] = React__default.useState(null);
325
464
  const [mobileMoreAnchorEl, setMobileMoreAnchorEl] = React__default.useState(null);
326
465
  const [user, setUser] = React__default.useState(() => {
466
+ const allData = getAllDataFromStorage();
467
+ // Try to get user data from various sources
468
+ let userName = "";
469
+ let userEmail = "";
470
+ let userRole = "";
471
+ // Priority 1: From decoded token
472
+ if (allData.decodedToken) {
473
+ userName = allData.decodedToken.sub || allData.decodedToken.email || "";
474
+ userEmail = allData.decodedToken.sub || allData.decodedToken.email || "";
475
+ userRole = allData.decodedToken.role || "";
476
+ }
477
+ // Priority 2: From auth data
478
+ if (allData.auth) {
479
+ userName = userName || allData.auth.name || allData.auth.email || "";
480
+ userEmail = userEmail || allData.auth.email || allData.auth.sub || "";
481
+ userRole = userRole || allData.auth.role || allData.auth.activeRole || "";
482
+ }
483
+ // Priority 3: From userDetails/user/profile
327
484
  const storedUser = getUserDataFromStorage();
328
- if (storedUser && storedUser.name && storedUser.email) {
329
- return storedUser;
485
+ if (storedUser) {
486
+ userName = userName || storedUser.name || "";
487
+ userEmail = userEmail || storedUser.email || "";
488
+ userRole = userRole || storedUser.role || "";
489
+ }
490
+ // Priority 4: From other parsed data
491
+ if (allData.userDetails) {
492
+ const userDetails = allData.userDetails.user || allData.userDetails.data || allData.userDetails;
493
+ if (userDetails) {
494
+ userName = userName || userDetails.name || userDetails.fullName || "";
495
+ userEmail = userEmail || userDetails.email || userDetails.emailAddress || "";
496
+ userRole = userRole || userDetails.role || userDetails.userRole || "";
497
+ }
498
+ }
499
+ if (allData.user) {
500
+ const userData = allData.user.user || allData.user.data || allData.user.currentUser || allData.user;
501
+ if (userData) {
502
+ userName = userName || userData.name || userData.fullName || "";
503
+ userEmail = userEmail || userData.email || userData.emailAddress || "";
504
+ userRole = userRole || userData.role || userData.userRole || "";
505
+ }
506
+ }
507
+ if (allData.profile) {
508
+ const profileData = allData.profile.user || allData.profile.data || allData.profile;
509
+ if (profileData) {
510
+ userName = userName || profileData.name || profileData.fullName || "";
511
+ userEmail = userEmail || profileData.email || profileData.emailAddress || "";
512
+ userRole = userRole || profileData.role || profileData.userRole || "";
513
+ }
330
514
  }
331
515
  return {
332
- name: "Naveen",
333
- email: "naveen@varminer.com",
334
- role: "Account Owner",
516
+ name: userName || "",
517
+ email: userEmail || "",
518
+ role: userRole || "",
519
+ avatar: storedUser?.avatar || allData.auth?.avatar || allData.profile?.avatar || undefined,
520
+ initials: storedUser?.initials || allData.auth?.initials || allData.profile?.initials || undefined,
335
521
  };
336
522
  });
337
523
  const [notificationCount, setNotificationCount] = React__default.useState(() => {
@@ -342,16 +528,86 @@ const AppHeader = ({ language: languageProp }) => {
342
528
  return getMessageCountFromStorage() ?? undefined;
343
529
  });
344
530
  React__default.useEffect(() => {
531
+ const allData = getAllDataFromStorage();
532
+ // Try to get user data from various sources
533
+ let userName = "";
534
+ let userEmail = "";
535
+ let userRole = "";
536
+ let userAvatar = undefined;
537
+ let userInitials = undefined;
538
+ // Priority 1: From decoded token
539
+ if (allData.decodedToken) {
540
+ userName = allData.decodedToken.sub || allData.decodedToken.email || "";
541
+ userEmail = allData.decodedToken.sub || allData.decodedToken.email || "";
542
+ userRole = allData.decodedToken.role || "";
543
+ }
544
+ // Priority 2: From auth data
545
+ if (allData.auth) {
546
+ userName = userName || allData.auth.name || allData.auth.email || "";
547
+ userEmail = userEmail || allData.auth.email || allData.auth.sub || "";
548
+ userRole = userRole || allData.auth.role || allData.auth.activeRole || "";
549
+ userAvatar = userAvatar || allData.auth.avatar || undefined;
550
+ userInitials = userInitials || allData.auth.initials || undefined;
551
+ }
552
+ // Priority 3: From userDetails/user/profile
345
553
  const storedUser = getUserDataFromStorage();
346
- if (storedUser && storedUser.name && storedUser.email) {
347
- setUser(storedUser);
554
+ if (storedUser) {
555
+ userName = userName || storedUser.name || "";
556
+ userEmail = userEmail || storedUser.email || "";
557
+ userRole = userRole || storedUser.role || "";
558
+ userAvatar = userAvatar || storedUser.avatar || undefined;
559
+ userInitials = userInitials || storedUser.initials || undefined;
560
+ }
561
+ // Priority 4: From other parsed data
562
+ if (allData.userDetails) {
563
+ const userDetails = allData.userDetails.user || allData.userDetails.data || allData.userDetails;
564
+ if (userDetails) {
565
+ userName = userName || userDetails.name || userDetails.fullName || "";
566
+ userEmail = userEmail || userDetails.email || userDetails.emailAddress || "";
567
+ userRole = userRole || userDetails.role || userDetails.userRole || "";
568
+ userAvatar = userAvatar || userDetails.avatar || userDetails.profilePicture || undefined;
569
+ userInitials = userInitials || userDetails.initials || undefined;
570
+ }
571
+ }
572
+ if (allData.user) {
573
+ const userData = allData.user.user || allData.user.data || allData.user.currentUser || allData.user;
574
+ if (userData) {
575
+ userName = userName || userData.name || userData.fullName || "";
576
+ userEmail = userEmail || userData.email || userData.emailAddress || "";
577
+ userRole = userRole || userData.role || userData.userRole || "";
578
+ userAvatar = userAvatar || userData.avatar || userData.profilePicture || undefined;
579
+ userInitials = userInitials || userData.initials || undefined;
580
+ }
581
+ }
582
+ if (allData.profile) {
583
+ const profileData = allData.profile.user || allData.profile.data || allData.profile;
584
+ if (profileData) {
585
+ userName = userName || profileData.name || profileData.fullName || "";
586
+ userEmail = userEmail || profileData.email || profileData.emailAddress || "";
587
+ userRole = userRole || profileData.role || profileData.userRole || "";
588
+ userAvatar = userAvatar || profileData.avatar || profileData.profilePicture || undefined;
589
+ userInitials = userInitials || profileData.initials || undefined;
590
+ }
591
+ }
592
+ setUser({
593
+ name: userName || "",
594
+ email: userEmail || "",
595
+ role: userRole || "",
596
+ avatar: userAvatar,
597
+ initials: userInitials,
598
+ });
599
+ // Update online status
600
+ if (allData.auth?.isOnline !== undefined) {
601
+ setIsOnlineStatus(allData.auth.isOnline);
348
602
  }
349
- else {
350
- setUser({
351
- name: "Naveen",
352
- email: "naveen@varminer.com",
353
- role: "Account Owner",
354
- });
603
+ else if (allData.userDetails?.isOnline !== undefined) {
604
+ setIsOnlineStatus(allData.userDetails.isOnline);
605
+ }
606
+ else if (allData.user?.isOnline !== undefined) {
607
+ setIsOnlineStatus(allData.user.isOnline);
608
+ }
609
+ else if (allData.profile?.isOnline !== undefined) {
610
+ setIsOnlineStatus(allData.profile.isOnline);
355
611
  }
356
612
  const notifCount = getNotificationCountFromStorage();
357
613
  setNotificationCount(notifCount !== null && notifCount !== undefined ? notifCount : 0);
@@ -364,6 +620,24 @@ const AppHeader = ({ language: languageProp }) => {
364
620
  }
365
621
  }, [languageProp]);
366
622
  const finalRoutes = DEFAULT_ROUTES;
623
+ // Get online status from localStorage dynamically
624
+ const [isOnlineStatus, setIsOnlineStatus] = React__default.useState(() => {
625
+ const allData = getAllDataFromStorage();
626
+ if (allData.auth?.isOnline !== undefined) {
627
+ return allData.auth.isOnline;
628
+ }
629
+ if (allData.userDetails?.isOnline !== undefined) {
630
+ return allData.userDetails.isOnline;
631
+ }
632
+ if (allData.user?.isOnline !== undefined) {
633
+ return allData.user.isOnline;
634
+ }
635
+ if (allData.profile?.isOnline !== undefined) {
636
+ return allData.profile.isOnline;
637
+ }
638
+ // Default to true if not specified (for backward compatibility)
639
+ return true;
640
+ });
367
641
  const notificationCountValue = notificationCount;
368
642
  const isMobileMenuOpen = Boolean(mobileMoreAnchorEl);
369
643
  const OnlineBadge = styled(Badge)(({ theme }) => ({
@@ -376,7 +650,7 @@ const AppHeader = ({ language: languageProp }) => {
376
650
  borderRadius: "50%",
377
651
  },
378
652
  }));
379
- styled(Badge)(({ theme }) => ({
653
+ const OfflineBadge = styled(Badge)(({ theme }) => ({
380
654
  "& .MuiBadge-badge": {
381
655
  backgroundColor: "gray",
382
656
  color: "gray",
@@ -432,11 +706,50 @@ const AppHeader = ({ language: languageProp }) => {
432
706
  .toUpperCase()
433
707
  .slice(0, 2);
434
708
  };
709
+ // Check if user has permission to see settings (Account Owner, Account Admin, or Global Admin)
710
+ const canViewSettings = React__default.useMemo(() => {
711
+ const allData = getAllDataFromStorage();
712
+ let userRole = "";
713
+ // Get role from decoded token
714
+ if (allData.decodedToken?.role) {
715
+ userRole = allData.decodedToken.role;
716
+ }
717
+ // Get role from auth data
718
+ else if (allData.auth?.role) {
719
+ userRole = allData.auth.role;
720
+ }
721
+ // Get role from user data
722
+ else if (user.role) {
723
+ userRole = user.role;
724
+ }
725
+ // Get role from userDetails
726
+ else if (allData.userDetails) {
727
+ const userDetails = allData.userDetails.user || allData.userDetails.data || allData.userDetails;
728
+ userRole = userDetails?.role || userDetails?.userRole || "";
729
+ }
730
+ // Get role from user
731
+ else if (allData.user) {
732
+ const userData = allData.user.user || allData.user.data || allData.user.currentUser || allData.user;
733
+ userRole = userData?.role || userData?.userRole || "";
734
+ }
735
+ // Normalize role for comparison (case-insensitive, handle spaces/underscores/hyphens)
736
+ const normalizedRole = userRole.toLowerCase().trim().replace(/[_\s-]+/g, " ");
737
+ const allowedRoles = [
738
+ "account owner",
739
+ "account admin",
740
+ "global admin"
741
+ ];
742
+ // Check for exact match or if role starts with allowed role
743
+ // This handles variations like "Account Owner", "ACCOUNT_OWNER", "Account-Owner", "Account Owner - Manager"
744
+ return allowedRoles.some(allowedRole => {
745
+ return normalizedRole === allowedRole || normalizedRole.startsWith(allowedRole + " ");
746
+ });
747
+ }, [user.role]);
435
748
  const profileList = (jsx(List, { className: "profile-menu-section", sx: {
436
749
  width: "100%",
437
750
  maxWidth: 360,
438
751
  pointerEvents: "none",
439
- }, component: "div", "aria-hidden": "true", tabIndex: -1, children: jsxs(ListItem, { alignItems: "flex-start", className: "profile-menu-item", children: [jsx(ListItemAvatar, { children: (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: jsx(Avatar, { sx: { bgcolor: deepOrange[500] }, alt: user.name, title: user.name, src: user.avatar, children: getInitials() }) })) }), jsx(ListItemText, { secondary: jsxs(React__default.Fragment, { children: [jsx(Typography, { className: "profile-name", component: "p", children: user.name }), jsx(Typography, { className: "profile-email", component: "p", children: user.email }), jsxs(Typography, { className: "profile-role", component: "p", children: [t.role, ": ", user.role] })] }) })] }) }));
752
+ }, component: "div", "aria-hidden": "true", tabIndex: -1, children: jsxs(ListItem, { alignItems: "flex-start", className: "profile-menu-item", children: [jsx(ListItemAvatar, { children: isOnlineStatus ? (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: jsx(Avatar, { sx: { bgcolor: deepOrange[500] }, alt: user.name, title: user.name, src: user.avatar, children: getInitials() }) })) : (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: jsx(Avatar, { sx: { bgcolor: deepOrange[500] }, alt: user.name, title: user.name, src: user.avatar, children: getInitials() }) })) }), jsx(ListItemText, { secondary: jsxs(React__default.Fragment, { children: [jsx(Typography, { className: "profile-name", component: "p", children: user.name }), jsx(Typography, { className: "profile-email", component: "p", children: user.email }), jsxs(Typography, { className: "profile-role", component: "p", children: [t.role, ": ", user.role] })] }) })] }) }));
440
753
  const renderMenu = (jsxs(Menu, { anchorEl: anchorEl, id: "account-menu", open: open, onClose: handleClose, onClick: handleClose, slotProps: {
441
754
  paper: {
442
755
  elevation: 0,
@@ -464,7 +777,7 @@ const AppHeader = ({ language: languageProp }) => {
464
777
  },
465
778
  },
466
779
  },
467
- }, transformOrigin: { horizontal: "right", vertical: "top" }, anchorOrigin: { horizontal: "right", vertical: "bottom" }, children: [profileList, jsx(Divider, {}), jsxs(MenuItem, { onClick: handleSettingsClick, children: [jsx(ListItemIcon, { children: jsx(SettingsOutlinedIcon, { fontSize: "small" }) }), t.accountSettings] }), jsxs(MenuItem, { onClick: handleProfileClick, children: [jsx(ListItemIcon, { children: jsx(PersonOutlineOutlinedIcon, { fontSize: "small" }) }), t.profile] }), jsxs(MenuItem, { onClick: handleSignOutClick, children: [jsx(ListItemIcon, { children: jsx(LogoutOutlinedIcon, { fontSize: "small" }) }), t.signOut] })] }));
780
+ }, transformOrigin: { horizontal: "right", vertical: "top" }, anchorOrigin: { horizontal: "right", vertical: "bottom" }, children: [profileList, jsx(Divider, {}), jsxs(MenuItem, { onClick: handleProfileClick, children: [jsx(ListItemIcon, { children: jsx(PersonOutlineOutlinedIcon, { fontSize: "small" }) }), t.profile] }), canViewSettings && (jsxs(MenuItem, { onClick: handleSettingsClick, children: [jsx(ListItemIcon, { children: jsx(SettingsOutlinedIcon, { fontSize: "small" }) }), t.accountSettings] })), jsxs(MenuItem, { onClick: handleSignOutClick, children: [jsx(ListItemIcon, { children: jsx(LogoutOutlinedIcon, { fontSize: "small" }) }), t.signOut] })] }));
468
781
  const mobileMenuId = "primary-account-menu-mobile";
469
782
  const renderMobileMenu = (jsxs(Menu, { anchorEl: mobileMoreAnchorEl, anchorOrigin: {
470
783
  vertical: "top",
@@ -472,7 +785,7 @@ const AppHeader = ({ language: languageProp }) => {
472
785
  }, id: mobileMenuId, keepMounted: true, transformOrigin: {
473
786
  vertical: "top",
474
787
  horizontal: "right",
475
- }, open: isMobileMenuOpen, onClose: handleMobileMenuClose, children: [messageCount !== undefined && (jsxs(MenuItem, { children: [jsx(IconButton, { size: "large", "aria-label": `show ${messageCount} new mails`, sx: { color: '#1e2f97' }, children: jsx(Badge, { badgeContent: messageCount, color: "error", children: jsx(MailIcon, {}) }) }), jsx("p", { children: t.messages })] })), notificationCountValue > 0 && (jsxs(MenuItem, { children: [jsx(IconButton, { size: "large", "aria-label": `show ${notificationCountValue} new notifications`, sx: { color: '#1e2f97' }, children: jsx(Badge, { badgeContent: notificationCount, color: "error", children: jsx(NotificationsActiveOutlined, {}) }) }), jsx("p", { children: t.notifications })] })), jsxs(MenuItem, { onClick: handleProfileMenuOpen, children: [jsx(IconButton, { size: "large", "aria-label": "account of current user", "aria-controls": "primary-account-menu", "aria-haspopup": "true", sx: { color: '#1e2f97' }, children: (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: jsx(AccountCircle, { titleAccess: user.name, "aria-label": "User avatar" }) })) }), jsx("p", { children: t.profile })] })] }));
788
+ }, open: isMobileMenuOpen, onClose: handleMobileMenuClose, children: [messageCount !== undefined && (jsxs(MenuItem, { children: [jsx(IconButton, { size: "large", "aria-label": `show ${messageCount} new mails`, sx: { color: '#1e2f97' }, children: jsx(Badge, { badgeContent: messageCount, color: "error", children: jsx(MailIcon, {}) }) }), jsx("p", { children: t.messages })] })), notificationCountValue > 0 && (jsxs(MenuItem, { children: [jsx(IconButton, { size: "large", "aria-label": `show ${notificationCountValue} new notifications`, sx: { color: '#1e2f97' }, children: jsx(Badge, { badgeContent: notificationCount, color: "error", children: jsx(NotificationsActiveOutlined, {}) }) }), jsx("p", { children: t.notifications })] })), jsxs(MenuItem, { onClick: handleProfileMenuOpen, children: [jsx(IconButton, { size: "large", "aria-label": "account of current user", "aria-controls": "primary-account-menu", "aria-haspopup": "true", sx: { color: '#1e2f97' }, children: isOnlineStatus ? (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: jsx(AccountCircle, { titleAccess: user.name, "aria-label": "User avatar" }) })) : (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: jsx(AccountCircle, { titleAccess: user.name, "aria-label": "User avatar" }) })) }), jsx("p", { children: t.profile })] })] }));
476
789
  return (jsxs(Box, { sx: { flexGrow: 1 }, className: "app-header", children: [jsx(AppBar, { elevation: 0, sx: {
477
790
  backgroundColor: "#ffffff",
478
791
  boxShadow: 'none !important',
@@ -506,12 +819,17 @@ const AppHeader = ({ language: languageProp }) => {
506
819
  '&:hover': {
507
820
  backgroundColor: 'rgba(30, 47, 151, 0.04)',
508
821
  }
509
- }, children: (jsx(OnlineBadge, { overlap: "circular", anchorOrigin: { vertical: "bottom", horizontal: "right" }, variant: "dot", title: "Online", "aria-label": "Online status badge", "data-testid": "online-badge", children: jsx(Avatar, { sx: {
822
+ }, children: isOnlineStatus ? (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: jsx(Avatar, { sx: {
823
+ bgcolor: deepOrange[500],
824
+ width: 20,
825
+ height: 20,
826
+ p: 1,
827
+ }, alt: user.name, title: user.name, src: user.avatar, sizes: "large", children: getInitials() }) })) : (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: jsx(Avatar, { sx: {
510
828
  bgcolor: deepOrange[500],
511
829
  width: 20,
512
830
  height: 20,
513
831
  p: 1,
514
- }, alt: user.name, title: user.name, src: user.avatar, sizes: "large", children: getInitials() }) })) })] }), jsx(Box, { sx: { display: { xs: "flex", md: "none" } }, children: jsx(IconButton, { size: "large", "aria-label": "show more", "aria-controls": mobileMenuId, "aria-haspopup": "true", onClick: handleMobileMenuOpen, sx: {
832
+ }, alt: user.name, title: user.name, src: user.avatar, children: getInitials() }) })) })] }), jsx(Box, { sx: { display: { xs: "flex", md: "none" } }, children: jsx(IconButton, { size: "large", "aria-label": "show more", "aria-controls": mobileMenuId, "aria-haspopup": "true", onClick: handleMobileMenuOpen, sx: {
515
833
  color: '#1e2f97',
516
834
  '&:hover': {
517
835
  backgroundColor: 'rgba(30, 47, 151, 0.04)',