varminer-app-header 2.1.6 → 2.1.8
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.d.ts +85 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +46 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +55 -3
- package/dist/index.js.map +1 -1
- package/dist/utils/localStorage.d.ts +39 -0
- package/dist/utils/localStorage.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -55,7 +55,42 @@ const DrawerProvider = ({ children }) => {
|
|
|
55
55
|
};
|
|
56
56
|
const useDrawer = () => React__namespace.useContext(DrawerContext);
|
|
57
57
|
|
|
58
|
+
// --- IAM app user details (shared from IAM after verify-OTP, same origin) ---
|
|
59
|
+
/** localStorage key used by IAM app for user details (GET /v1/userManagement/userDetails response). */
|
|
60
|
+
const USER_DETAILS_STORAGE_KEY = "linn-i-am-userDetails";
|
|
61
|
+
/**
|
|
62
|
+
* Read user details from IAM app localStorage (set after verify-OTP on same origin).
|
|
63
|
+
* Does not write or overwrite this key; IAM app is the source of truth.
|
|
64
|
+
*/
|
|
65
|
+
function getStoredUserDetails() {
|
|
66
|
+
try {
|
|
67
|
+
const raw = localStorage.getItem(USER_DETAILS_STORAGE_KEY);
|
|
68
|
+
if (!raw)
|
|
69
|
+
return null;
|
|
70
|
+
const parsed = JSON.parse(raw);
|
|
71
|
+
if (parsed.status !== "SUCCESS" || !parsed.data?.usersDetails?.length) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return parsed.data.usersDetails[0];
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
58
80
|
const getUserDataFromStorage = () => {
|
|
81
|
+
// Prefer IAM user details when available (same origin, after verify-OTP)
|
|
82
|
+
const iamUser = getStoredUserDetails();
|
|
83
|
+
if (iamUser) {
|
|
84
|
+
const name = [iamUser.firstName, iamUser.lastName].filter(Boolean).join(" ").trim();
|
|
85
|
+
const role = iamUser.roles?.length ? iamUser.roles[0] : iamUser.workInfo?.jobTitle ?? "";
|
|
86
|
+
return {
|
|
87
|
+
name: name || "",
|
|
88
|
+
email: iamUser.email || "",
|
|
89
|
+
role: role || "",
|
|
90
|
+
avatar: undefined,
|
|
91
|
+
initials: name ? name.split(/\s+/).map((s) => s[0]).join("").slice(0, 2).toUpperCase() : undefined,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
59
94
|
const userDbString = localStorage.getItem("persist:userdb");
|
|
60
95
|
if (userDbString) {
|
|
61
96
|
try {
|
|
@@ -580,7 +615,8 @@ const languages = [
|
|
|
580
615
|
{ code: "en", name: "English", flag: GBFlag },
|
|
581
616
|
{ code: "es", name: "Spanish", flag: ESFlag },
|
|
582
617
|
];
|
|
583
|
-
const LanguageSelector = ({ currentLanguage, onLanguageChange,
|
|
618
|
+
const LanguageSelector = ({ currentLanguage, onLanguageChange: _onLanguageChange, // reserved for parent callback; we reload the page on select
|
|
619
|
+
}) => {
|
|
584
620
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
585
621
|
const open = Boolean(anchorEl);
|
|
586
622
|
const currentLang = languages.find((lang) => lang.code === currentLanguage) || languages[0];
|
|
@@ -941,7 +977,13 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
941
977
|
};
|
|
942
978
|
const handleSignOutClick = () => {
|
|
943
979
|
handleClose();
|
|
944
|
-
|
|
980
|
+
try {
|
|
981
|
+
localStorage.clear();
|
|
982
|
+
sessionStorage.clear();
|
|
983
|
+
}
|
|
984
|
+
catch (e) {
|
|
985
|
+
console.warn("Clear storage on logout:", e);
|
|
986
|
+
}
|
|
945
987
|
const path = finalRoutes.logout.startsWith('/')
|
|
946
988
|
? finalRoutes.logout
|
|
947
989
|
: `/${finalRoutes.logout}`;
|
|
@@ -1001,7 +1043,7 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
1001
1043
|
width: "100%",
|
|
1002
1044
|
maxWidth: 360,
|
|
1003
1045
|
pointerEvents: "none",
|
|
1004
|
-
}, 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, {
|
|
1046
|
+
}, 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, { primary: jsxRuntime.jsx(material.Typography, { className: "profile-name", component: "span", children: user.name || user.email }), secondary: jsxRuntime.jsxs(React.Fragment, { children: [user.name && user.email ? (jsxRuntime.jsx(material.Typography, { className: "profile-email", component: "p", children: user.email })) : null, jsxRuntime.jsxs(material.Typography, { className: "profile-role", component: "p", children: [t.role, ": ", user.role] })] }) })] }) }));
|
|
1005
1047
|
const renderMenu = (jsxRuntime.jsxs(material.Menu, { anchorEl: anchorEl, id: "account-menu", open: open, onClose: handleClose, onClick: handleClose, slotProps: {
|
|
1006
1048
|
paper: {
|
|
1007
1049
|
elevation: 0,
|
|
@@ -1091,7 +1133,17 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
1091
1133
|
|
|
1092
1134
|
exports.AppHeader = AppHeader;
|
|
1093
1135
|
exports.DrawerProvider = DrawerProvider;
|
|
1136
|
+
exports.USER_DETAILS_STORAGE_KEY = USER_DETAILS_STORAGE_KEY;
|
|
1137
|
+
exports.fetchProfilePictureAsBlobUrl = fetchProfilePictureAsBlobUrl;
|
|
1138
|
+
exports.getAllDataFromStorage = getAllDataFromStorage;
|
|
1139
|
+
exports.getI18nLocaleFromStorage = getI18nLocaleFromStorage;
|
|
1140
|
+
exports.getMessageCountFromStorage = getMessageCountFromStorage;
|
|
1141
|
+
exports.getNotificationCountFromStorage = getNotificationCountFromStorage;
|
|
1142
|
+
exports.getProfilePictureUrl = getProfilePictureUrl;
|
|
1143
|
+
exports.getStoredUserDetails = getStoredUserDetails;
|
|
1094
1144
|
exports.getTranslations = getTranslations;
|
|
1145
|
+
exports.getUserDataFromStorage = getUserDataFromStorage;
|
|
1146
|
+
exports.setI18nLocaleToStorage = setI18nLocaleToStorage;
|
|
1095
1147
|
exports.translations = translations;
|
|
1096
1148
|
exports.useDrawer = useDrawer;
|
|
1097
1149
|
//# sourceMappingURL=index.js.map
|