varminer-app-header 1.0.5 → 1.0.7
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/README.md +17 -11
- package/dist/AppHeader.d.ts.map +1 -1
- package/dist/index.d.ts +0 -74
- package/dist/index.esm.js +193 -62
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +193 -62
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +0 -74
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/localStorage.d.ts +2 -7
- package/dist/utils/localStorage.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,9 +31,9 @@ npm install react react-dom react-router-dom @mui/material @mui/icons-material @
|
|
|
31
31
|
|
|
32
32
|
## Usage
|
|
33
33
|
|
|
34
|
-
###
|
|
34
|
+
### Plug-and-Play (Zero Configuration)
|
|
35
35
|
|
|
36
|
-
The package
|
|
36
|
+
The package is **100% plug-and-play** - no props needed! It automatically loads everything from localStorage and handles all interactions internally:
|
|
37
37
|
|
|
38
38
|
```tsx
|
|
39
39
|
import React from 'react';
|
|
@@ -43,20 +43,26 @@ import 'varminer-app-header/dist/index.css'; // Don't forget the CSS!
|
|
|
43
43
|
function App() {
|
|
44
44
|
return (
|
|
45
45
|
<DrawerProvider>
|
|
46
|
-
<AppHeader
|
|
47
|
-
user={{
|
|
48
|
-
name: "John Doe",
|
|
49
|
-
email: "john@example.com",
|
|
50
|
-
role: "Administrator",
|
|
51
|
-
initials: "JD"
|
|
52
|
-
}}
|
|
53
|
-
notificationCount={5}
|
|
54
|
-
/>
|
|
46
|
+
<AppHeader />
|
|
55
47
|
</DrawerProvider>
|
|
56
48
|
);
|
|
57
49
|
}
|
|
58
50
|
```
|
|
59
51
|
|
|
52
|
+
**That's it!** The component automatically:
|
|
53
|
+
- ✅ Loads user data from `localStorage` (`persist:userdb`)
|
|
54
|
+
- ✅ Loads notification count from `localStorage`
|
|
55
|
+
- ✅ Loads message count from `localStorage`
|
|
56
|
+
- ✅ Handles hamburger menu toggle internally
|
|
57
|
+
- ✅ Uses default logo ("VAR" and "MINER")
|
|
58
|
+
- ✅ Uses default routes: `/account/overview`, `/profile`, `/logout`
|
|
59
|
+
- ✅ Handles all navigation internally
|
|
60
|
+
- ✅ Shows online status badge
|
|
61
|
+
|
|
62
|
+
### Zero Configuration
|
|
63
|
+
|
|
64
|
+
The component requires **no props at all** - it's completely plug-and-play!
|
|
65
|
+
|
|
60
66
|
**Defaults:**
|
|
61
67
|
- Logo: "VAR" and "MINER"
|
|
62
68
|
- Routes: `/account/overview` (settings), `/profile` (profile), `/logout` (logout)
|
package/dist/AppHeader.d.ts.map
CHANGED
|
@@ -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,
|
|
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;AAEtD,OAAO,sBAAsB,CAAC;AAa9B,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAqfvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,80 +10,6 @@ interface UserProfile {
|
|
|
10
10
|
initials?: string;
|
|
11
11
|
}
|
|
12
12
|
interface AppHeaderProps {
|
|
13
|
-
/**
|
|
14
|
-
* User profile information
|
|
15
|
-
*/
|
|
16
|
-
user?: UserProfile;
|
|
17
|
-
/**
|
|
18
|
-
* Whether the user is online
|
|
19
|
-
* @default true
|
|
20
|
-
*/
|
|
21
|
-
isOnline?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* App logo/brand name (optional - defaults to "VAR" and "MINER")
|
|
24
|
-
*/
|
|
25
|
-
logo?: {
|
|
26
|
-
first: string;
|
|
27
|
-
second: string;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Notification count (shown in desktop and mobile menu)
|
|
31
|
-
* @default 0
|
|
32
|
-
*/
|
|
33
|
-
notificationCount?: number;
|
|
34
|
-
/**
|
|
35
|
-
* Message count (shown only in mobile menu, optional)
|
|
36
|
-
* @default undefined (not shown if not provided)
|
|
37
|
-
*/
|
|
38
|
-
messageCount?: number;
|
|
39
|
-
/**
|
|
40
|
-
* Callback when drawer toggle is clicked
|
|
41
|
-
*/
|
|
42
|
-
onDrawerToggle?: () => void;
|
|
43
|
-
/**
|
|
44
|
-
* Whether drawer is open
|
|
45
|
-
* @default false
|
|
46
|
-
*/
|
|
47
|
-
isDrawerOpen?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Route paths for navigation (optional - defaults are used if not provided)
|
|
50
|
-
* All routes are absolute paths from root (e.g., "/account/overview")
|
|
51
|
-
* @default "/account/overview", "/profile", "/logout"
|
|
52
|
-
*/
|
|
53
|
-
routes?: {
|
|
54
|
-
/**
|
|
55
|
-
* Settings route path
|
|
56
|
-
* @default "/account/overview"
|
|
57
|
-
*/
|
|
58
|
-
settings?: string;
|
|
59
|
-
/**
|
|
60
|
-
* Profile route path
|
|
61
|
-
* @default "/profile"
|
|
62
|
-
*/
|
|
63
|
-
profile?: string;
|
|
64
|
-
/**
|
|
65
|
-
* Logout route path
|
|
66
|
-
* @default "/logout"
|
|
67
|
-
*/
|
|
68
|
-
logout?: string;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Callback when settings is clicked (overrides default navigation)
|
|
72
|
-
*/
|
|
73
|
-
onSettingsClick?: () => void;
|
|
74
|
-
/**
|
|
75
|
-
* Callback when profile is clicked (overrides default navigation)
|
|
76
|
-
*/
|
|
77
|
-
onProfileClick?: () => void;
|
|
78
|
-
/**
|
|
79
|
-
* Callback when sign out is clicked (overrides default navigation)
|
|
80
|
-
* If not provided, will clear localStorage and navigate to logout route
|
|
81
|
-
*/
|
|
82
|
-
onSignOutClick?: () => void;
|
|
83
|
-
/**
|
|
84
|
-
* Custom CSS class name
|
|
85
|
-
*/
|
|
86
|
-
className?: string;
|
|
87
13
|
}
|
|
88
14
|
|
|
89
15
|
declare const AppHeader: React__default.FC<AppHeaderProps>;
|
package/dist/index.esm.js
CHANGED
|
@@ -34,35 +34,188 @@ const DrawerProvider = ({ children }) => {
|
|
|
34
34
|
};
|
|
35
35
|
const useDrawer = () => React.useContext(DrawerContext);
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
const getUserDataFromStorage = () => {
|
|
38
|
+
const userDbString = localStorage.getItem("persist:userdb");
|
|
39
|
+
if (userDbString) {
|
|
40
|
+
try {
|
|
41
|
+
const parsedOuter = JSON.parse(userDbString);
|
|
42
|
+
const parseNested = (value) => {
|
|
43
|
+
if (typeof value === 'string') {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(value);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
};
|
|
53
|
+
let userData = null;
|
|
54
|
+
if (parsedOuter.userDetails) {
|
|
55
|
+
const parsedUserDetails = parseNested(parsedOuter.userDetails);
|
|
56
|
+
userData = parsedUserDetails.user || parsedUserDetails.data || parsedUserDetails;
|
|
57
|
+
}
|
|
58
|
+
if (!userData && parsedOuter.user) {
|
|
59
|
+
const parsedUser = parseNested(parsedOuter.user);
|
|
60
|
+
userData = parsedUser.user || parsedUser.data || parsedUser.currentUser || parsedUser;
|
|
61
|
+
}
|
|
62
|
+
if (!userData && parsedOuter.authDetails) {
|
|
63
|
+
const parsedAuthDetails = parseNested(parsedOuter.authDetails);
|
|
64
|
+
if (parsedAuthDetails.auth) {
|
|
65
|
+
userData = parsedAuthDetails.auth.user || parsedAuthDetails.auth.userData;
|
|
66
|
+
}
|
|
67
|
+
if (!userData) {
|
|
68
|
+
userData = parsedAuthDetails.user || parsedAuthDetails.userData || parsedAuthDetails.currentUser;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!userData && parsedOuter.profile) {
|
|
72
|
+
const parsedProfile = parseNested(parsedOuter.profile);
|
|
73
|
+
userData = parsedProfile.user || parsedProfile.data || parsedProfile;
|
|
74
|
+
}
|
|
75
|
+
if (userData) {
|
|
76
|
+
let name = userData.name || userData.fullName || userData.userName || "";
|
|
77
|
+
if (!name && (userData.firstName || userData.lastName)) {
|
|
78
|
+
name = [userData.firstName, userData.lastName].filter(Boolean).join(' ');
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
name: name || "",
|
|
82
|
+
email: userData.email || userData.emailAddress || "",
|
|
83
|
+
role: userData.role || userData.userRole || userData.designation || userData.title || "",
|
|
84
|
+
avatar: userData.avatar || userData.profilePicture || userData.imageUrl || userData.profileImage,
|
|
85
|
+
initials: userData.initials,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
console.error("Error parsing user data from localStorage:", err);
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
};
|
|
96
|
+
const getNotificationCountFromStorage = () => {
|
|
97
|
+
const userDbString = localStorage.getItem("persist:userdb");
|
|
98
|
+
if (userDbString) {
|
|
99
|
+
try {
|
|
100
|
+
const parsedOuter = JSON.parse(userDbString);
|
|
101
|
+
const parseNested = (value) => {
|
|
102
|
+
if (typeof value === 'string') {
|
|
103
|
+
try {
|
|
104
|
+
return JSON.parse(value);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
};
|
|
112
|
+
if (parsedOuter.notifications) {
|
|
113
|
+
const parsedNotifications = parseNested(parsedOuter.notifications);
|
|
114
|
+
const count = parsedNotifications.count || parsedNotifications.unreadCount || parsedNotifications.total;
|
|
115
|
+
if (typeof count === 'number')
|
|
116
|
+
return count;
|
|
117
|
+
}
|
|
118
|
+
if (parsedOuter.app) {
|
|
119
|
+
const parsedApp = parseNested(parsedOuter.app);
|
|
120
|
+
if (parsedApp.notificationCount !== undefined) {
|
|
121
|
+
return parsedApp.notificationCount;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
console.error("Error parsing notification count from localStorage:", err);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return 0;
|
|
130
|
+
};
|
|
131
|
+
const getMessageCountFromStorage = () => {
|
|
132
|
+
const userDbString = localStorage.getItem("persist:userdb");
|
|
133
|
+
if (userDbString) {
|
|
134
|
+
try {
|
|
135
|
+
const parsedOuter = JSON.parse(userDbString);
|
|
136
|
+
const parseNested = (value) => {
|
|
137
|
+
if (typeof value === 'string') {
|
|
138
|
+
try {
|
|
139
|
+
return JSON.parse(value);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return value;
|
|
146
|
+
};
|
|
147
|
+
if (parsedOuter.messages) {
|
|
148
|
+
const parsedMessages = parseNested(parsedOuter.messages);
|
|
149
|
+
const count = parsedMessages.count || parsedMessages.unreadCount || parsedMessages.total;
|
|
150
|
+
if (typeof count === 'number')
|
|
151
|
+
return count;
|
|
152
|
+
}
|
|
153
|
+
if (parsedOuter.app) {
|
|
154
|
+
const parsedApp = parseNested(parsedOuter.app);
|
|
155
|
+
if (parsedApp.messageCount !== undefined) {
|
|
156
|
+
return parsedApp.messageCount;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
console.error("Error parsing message count from localStorage:", err);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return undefined;
|
|
165
|
+
};
|
|
166
|
+
|
|
38
167
|
const DEFAULT_ROUTES = {
|
|
39
168
|
settings: "/account/overview",
|
|
40
169
|
profile: "/profile",
|
|
41
170
|
logout: "/logout",
|
|
42
171
|
};
|
|
43
|
-
// Default logo - can be overridden via props
|
|
44
172
|
const DEFAULT_LOGO = {
|
|
45
173
|
first: "VAR",
|
|
46
174
|
second: "MINER",
|
|
47
175
|
};
|
|
48
|
-
const AppHeader = (
|
|
49
|
-
|
|
50
|
-
email: "shivam@redcliffelabs.com",
|
|
51
|
-
role: "Lab Technician",
|
|
52
|
-
initials: "SK",
|
|
53
|
-
}, isOnline = true, logo, notificationCount = 0, messageCount, onDrawerToggle, routes, onSettingsClick, onProfileClick, onSignOutClick, className, }) => {
|
|
54
|
-
// Use provided logo or default
|
|
55
|
-
const finalLogo = logo ?? DEFAULT_LOGO;
|
|
176
|
+
const AppHeader = () => {
|
|
177
|
+
const finalLogo = DEFAULT_LOGO;
|
|
56
178
|
const { isDrawerOpen, toggleDrawer } = useDrawer();
|
|
57
179
|
const [anchorEl, setAnchorEl] = React__default.useState(null);
|
|
58
180
|
const [mobileMoreAnchorEl, setMobileMoreAnchorEl] = React__default.useState(null);
|
|
181
|
+
const [user, setUser] = React__default.useState(() => {
|
|
182
|
+
const storedUser = getUserDataFromStorage();
|
|
183
|
+
if (storedUser && storedUser.name && storedUser.email) {
|
|
184
|
+
return storedUser;
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
name: "Naveen",
|
|
188
|
+
email: "naveen@varminer.com",
|
|
189
|
+
role: "Account Owner",
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
const [notificationCount, setNotificationCount] = React__default.useState(() => {
|
|
193
|
+
const count = getNotificationCountFromStorage();
|
|
194
|
+
return count !== null && count !== undefined ? count : 0;
|
|
195
|
+
});
|
|
196
|
+
const [messageCount, setMessageCount] = React__default.useState(() => {
|
|
197
|
+
return getMessageCountFromStorage() ?? undefined;
|
|
198
|
+
});
|
|
199
|
+
React__default.useEffect(() => {
|
|
200
|
+
const storedUser = getUserDataFromStorage();
|
|
201
|
+
if (storedUser && storedUser.name && storedUser.email) {
|
|
202
|
+
setUser(storedUser);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
setUser({
|
|
206
|
+
name: "Naveen",
|
|
207
|
+
email: "naveen@varminer.com",
|
|
208
|
+
role: "Account Owner",
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
const notifCount = getNotificationCountFromStorage();
|
|
212
|
+
setNotificationCount(notifCount !== null && notifCount !== undefined ? notifCount : 0);
|
|
213
|
+
const msgCount = getMessageCountFromStorage();
|
|
214
|
+
setMessageCount(msgCount ?? undefined);
|
|
215
|
+
}, []);
|
|
216
|
+
const finalRoutes = DEFAULT_ROUTES;
|
|
217
|
+
const notificationCountValue = notificationCount;
|
|
59
218
|
const isMobileMenuOpen = Boolean(mobileMoreAnchorEl);
|
|
60
|
-
// Merge provided routes with defaults - all routes are absolute from root
|
|
61
|
-
const finalRoutes = {
|
|
62
|
-
settings: routes?.settings ?? DEFAULT_ROUTES.settings,
|
|
63
|
-
profile: routes?.profile ?? DEFAULT_ROUTES.profile,
|
|
64
|
-
logout: routes?.logout ?? DEFAULT_ROUTES.logout,
|
|
65
|
-
};
|
|
66
219
|
const OnlineBadge = styled(Badge)(({ theme }) => ({
|
|
67
220
|
"& .MuiBadge-badge": {
|
|
68
221
|
backgroundColor: "#44b700",
|
|
@@ -73,7 +226,7 @@ const AppHeader = ({ user = {
|
|
|
73
226
|
borderRadius: "50%",
|
|
74
227
|
},
|
|
75
228
|
}));
|
|
76
|
-
|
|
229
|
+
styled(Badge)(({ theme }) => ({
|
|
77
230
|
"& .MuiBadge-badge": {
|
|
78
231
|
backgroundColor: "gray",
|
|
79
232
|
color: "gray",
|
|
@@ -83,9 +236,10 @@ const AppHeader = ({ user = {
|
|
|
83
236
|
borderRadius: "50%",
|
|
84
237
|
},
|
|
85
238
|
}));
|
|
86
|
-
const handleDrawerToggle = () => {
|
|
239
|
+
const handleDrawerToggle = (event) => {
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
event.stopPropagation();
|
|
87
242
|
toggleDrawer();
|
|
88
|
-
onDrawerToggle?.();
|
|
89
243
|
};
|
|
90
244
|
const handleProfileMenuOpen = (event) => {
|
|
91
245
|
setAnchorEl(event.currentTarget);
|
|
@@ -102,43 +256,25 @@ const AppHeader = ({ user = {
|
|
|
102
256
|
};
|
|
103
257
|
const handleSettingsClick = () => {
|
|
104
258
|
handleClose();
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// Use window.location to navigate to absolute path, bypassing React Router basename
|
|
110
|
-
const path = finalRoutes.settings.startsWith('/')
|
|
111
|
-
? finalRoutes.settings
|
|
112
|
-
: `/${finalRoutes.settings}`;
|
|
113
|
-
window.location.href = path;
|
|
114
|
-
}
|
|
259
|
+
const path = finalRoutes.settings.startsWith('/')
|
|
260
|
+
? finalRoutes.settings
|
|
261
|
+
: `/${finalRoutes.settings}`;
|
|
262
|
+
window.location.href = path;
|
|
115
263
|
};
|
|
116
264
|
const handleProfileClick = () => {
|
|
117
265
|
handleClose();
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// Use window.location to navigate to absolute path, bypassing React Router basename
|
|
123
|
-
const path = finalRoutes.profile.startsWith('/')
|
|
124
|
-
? finalRoutes.profile
|
|
125
|
-
: `/${finalRoutes.profile}`;
|
|
126
|
-
window.location.href = path;
|
|
127
|
-
}
|
|
266
|
+
const path = finalRoutes.profile.startsWith('/')
|
|
267
|
+
? finalRoutes.profile
|
|
268
|
+
: `/${finalRoutes.profile}`;
|
|
269
|
+
window.location.href = path;
|
|
128
270
|
};
|
|
129
271
|
const handleSignOutClick = () => {
|
|
130
272
|
handleClose();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// Use window.location to navigate to absolute path, bypassing React Router basename
|
|
137
|
-
const path = finalRoutes.logout.startsWith('/')
|
|
138
|
-
? finalRoutes.logout
|
|
139
|
-
: `/${finalRoutes.logout}`;
|
|
140
|
-
window.location.href = path;
|
|
141
|
-
}
|
|
273
|
+
localStorage.clear();
|
|
274
|
+
const path = finalRoutes.logout.startsWith('/')
|
|
275
|
+
? finalRoutes.logout
|
|
276
|
+
: `/${finalRoutes.logout}`;
|
|
277
|
+
window.location.href = path;
|
|
142
278
|
};
|
|
143
279
|
const menuId = "primary-account-menu";
|
|
144
280
|
const getInitials = () => {
|
|
@@ -155,7 +291,7 @@ const AppHeader = ({ user = {
|
|
|
155
291
|
width: "100%",
|
|
156
292
|
maxWidth: 360,
|
|
157
293
|
pointerEvents: "none",
|
|
158
|
-
}, component: "div", "aria-hidden": "true", tabIndex: -1, children: jsxs(ListItem, { alignItems: "flex-start", className: "profile-menu-item", children: [jsx(ListItemAvatar, { children:
|
|
294
|
+
}, 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: "Online", "aria-label": "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: ["Role: ", user.role] })] }) })] }) }));
|
|
159
295
|
const renderMenu = (jsxs(Menu, { anchorEl: anchorEl, id: "account-menu", open: open, onClose: handleClose, onClick: handleClose, slotProps: {
|
|
160
296
|
paper: {
|
|
161
297
|
elevation: 0,
|
|
@@ -191,8 +327,8 @@ const AppHeader = ({ user = {
|
|
|
191
327
|
}, id: mobileMenuId, keepMounted: true, transformOrigin: {
|
|
192
328
|
vertical: "top",
|
|
193
329
|
horizontal: "right",
|
|
194
|
-
}, 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: "Messages" })] })),
|
|
195
|
-
return (jsxs(Box, { sx: { flexGrow: 1 }, className:
|
|
330
|
+
}, 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: "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: "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: "Online", "aria-label": "Online status badge", "data-testid": "online-badge", children: jsx(AccountCircle, { titleAccess: user.name, "aria-label": "User avatar" }) })) }), jsx("p", { children: "Profile" })] })] }));
|
|
331
|
+
return (jsxs(Box, { sx: { flexGrow: 1 }, className: "app-header", children: [jsx(AppBar, { sx: {
|
|
196
332
|
position: "fixed",
|
|
197
333
|
top: 0,
|
|
198
334
|
backgroundColor: "#ffffff",
|
|
@@ -202,27 +338,22 @@ const AppHeader = ({ user = {
|
|
|
202
338
|
'&:hover': {
|
|
203
339
|
backgroundColor: 'rgba(30, 47, 151, 0.04)',
|
|
204
340
|
}
|
|
205
|
-
}, onClick: handleDrawerToggle, children: isDrawerOpen ? (jsx(MenuOpenIcon, { fontSize: "large" })) : (jsx(MenuIcon, { fontSize: "large" })) }), jsxs(Typography, { variant: "h6", noWrap: true, component: "div", sx: { display: { xs: "none", sm: "block" } }, "data-testid": "var-miner-wrapper", children: [jsx("span", { className: "var", children: finalLogo.first }), jsx("span", { className: "miner", children: finalLogo.second })] }), jsx(Box, { sx: { flexGrow: 1 } }), jsxs(Box, { sx: { display: { xs: "none", md: "flex" } }, children: [
|
|
341
|
+
}, onClick: handleDrawerToggle, children: isDrawerOpen ? (jsx(MenuOpenIcon, { fontSize: "large" })) : (jsx(MenuIcon, { fontSize: "large" })) }), jsxs(Typography, { variant: "h6", noWrap: true, component: "div", sx: { display: { xs: "none", sm: "block" } }, "data-testid": "var-miner-wrapper", children: [jsx("span", { className: "var", children: finalLogo.first }), jsx("span", { className: "miner", children: finalLogo.second })] }), jsx(Box, { sx: { flexGrow: 1 } }), jsxs(Box, { sx: { display: { xs: "none", md: "flex" } }, children: [notificationCountValue > 0 && (jsx(IconButton, { size: "large", "aria-label": `show ${notificationCountValue} new notifications`, sx: {
|
|
206
342
|
color: '#1e2f97',
|
|
207
343
|
'&:hover': {
|
|
208
344
|
backgroundColor: 'rgba(30, 47, 151, 0.04)',
|
|
209
345
|
}
|
|
210
|
-
}, children: jsx(Badge, { badgeContent:
|
|
346
|
+
}, children: jsx(Badge, { badgeContent: notificationCountValue, color: "error", children: jsx(NotificationsActiveOutlined, {}) }) })), jsx(IconButton, { size: "large", edge: "end", "aria-label": "account of current user", "aria-controls": menuId, "aria-haspopup": "true", onClick: handleProfileMenuOpen, sx: {
|
|
211
347
|
color: '#1e2f97',
|
|
212
348
|
'&:hover': {
|
|
213
349
|
backgroundColor: 'rgba(30, 47, 151, 0.04)',
|
|
214
350
|
}
|
|
215
|
-
}, children:
|
|
216
|
-
bgcolor: deepOrange[500],
|
|
217
|
-
width: 20,
|
|
218
|
-
height: 20,
|
|
219
|
-
p: 1,
|
|
220
|
-
}, 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: "Offline", "aria-label": "Offline status badge", "data-testid": "offline-badge", children: jsx(Avatar, { sx: {
|
|
351
|
+
}, 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: {
|
|
221
352
|
bgcolor: deepOrange[500],
|
|
222
353
|
width: 20,
|
|
223
354
|
height: 20,
|
|
224
355
|
p: 1,
|
|
225
|
-
}, alt: user.name, title: user.name, src: user.avatar, children: getInitials() }) }))
|
|
356
|
+
}, 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: {
|
|
226
357
|
color: '#1e2f97',
|
|
227
358
|
'&:hover': {
|
|
228
359
|
backgroundColor: 'rgba(30, 47, 151, 0.04)',
|