varminer-app-header 2.1.7 → 2.1.9

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,CA6wBvC,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,CA8yBvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
package/dist/index.esm.js CHANGED
@@ -703,51 +703,68 @@ const AppHeader = ({ language: languageProp }) => {
703
703
  const [mobileMoreAnchorEl, setMobileMoreAnchorEl] = React__default.useState(null);
704
704
  const [user, setUser] = React__default.useState(() => {
705
705
  const allData = getAllDataFromStorage();
706
- // Try to get user data from various sources
707
706
  let userName = "";
708
707
  let userEmail = "";
709
708
  let userRole = "";
710
- // Priority 1: From decoded token
711
- if (allData.decodedToken) {
712
- userName = allData.decodedToken.sub || allData.decodedToken.email || "";
713
- userEmail = allData.decodedToken.sub || allData.decodedToken.email || "";
714
- userRole = allData.decodedToken.role || "";
715
- }
716
- // Priority 2: From auth data
717
- if (allData.auth) {
718
- userName = userName || allData.auth.name || allData.auth.email || "";
719
- userEmail = userEmail || allData.auth.email || allData.auth.sub || "";
720
- userRole = userRole || allData.auth.role || allData.auth.activeRole || "";
721
- }
722
- // Priority 3: From userDetails/user/profile
709
+ const buildNameFromFirstLast = (obj) => {
710
+ if (!obj || typeof obj !== "object")
711
+ return "";
712
+ const first = (obj.firstName ?? obj.given_name ?? obj.first_name);
713
+ const last = (obj.lastName ?? obj.family_name ?? obj.last_name);
714
+ return [first, last].filter(Boolean).join(" ").trim();
715
+ };
716
+ // Prefer getUserDataFromStorage first (IAM firstName+lastName or persist:userdb name)
723
717
  const storedUser = getUserDataFromStorage();
724
718
  if (storedUser) {
725
- userName = userName || storedUser.name || "";
719
+ userName = storedUser.name || "";
726
720
  userEmail = userEmail || storedUser.email || "";
727
721
  userRole = userRole || storedUser.role || "";
728
722
  }
729
- // Priority 4: From other parsed data
723
+ // Then enrich from decoded token (email from sub; name only if token has name/given_name/family_name, never use sub as name)
724
+ if (allData.decodedToken) {
725
+ const token = allData.decodedToken;
726
+ userEmail = userEmail || token.sub || token.email || "";
727
+ const tokenName = token.name || buildNameFromFirstLast(token);
728
+ userName = userName || (tokenName || "");
729
+ userRole = userRole || token.role || "";
730
+ }
731
+ if (allData.auth) {
732
+ const auth = allData.auth;
733
+ userEmail = userEmail || auth.email || auth.sub || "";
734
+ userName = userName || auth.name || buildNameFromFirstLast(auth) || "";
735
+ userRole = userRole || auth.role || auth.activeRole || "";
736
+ }
730
737
  if (allData.userDetails) {
731
- const userDetails = allData.userDetails.user || allData.userDetails.data || allData.userDetails;
732
- if (userDetails) {
733
- userName = userName || userDetails.name || userDetails.fullName || "";
734
- userEmail = userEmail || userDetails.email || userDetails.emailAddress || "";
735
- userRole = userRole || userDetails.role || userDetails.userRole || "";
738
+ const userDetails = allData.userDetails.user
739
+ || allData.userDetails.data
740
+ || allData.userDetails;
741
+ const details = userDetails;
742
+ if (details) {
743
+ userEmail = userEmail || details.email || details.emailAddress || "";
744
+ userName = userName || details.name || details.fullName || buildNameFromFirstLast(details) || "";
745
+ userRole = userRole || details.role || details.userRole || "";
736
746
  }
737
747
  }
738
748
  if (allData.user) {
739
- const userData = allData.user.user || allData.user.data || allData.user.currentUser || allData.user;
749
+ const u = allData.user.user
750
+ || allData.user.data
751
+ || allData.user.currentUser
752
+ || allData.user;
753
+ const userData = u;
740
754
  if (userData) {
741
- userName = userName || userData.name || userData.fullName || "";
742
755
  userEmail = userEmail || userData.email || userData.emailAddress || "";
756
+ userName = userName || userData.name || userData.fullName || buildNameFromFirstLast(userData) || "";
743
757
  userRole = userRole || userData.role || userData.userRole || "";
744
758
  }
745
759
  }
746
760
  if (allData.profile) {
747
- const profileData = allData.profile.user || allData.profile.data || allData.profile;
761
+ const p = allData.profile.user
762
+ || allData.profile.data
763
+ || allData.profile;
764
+ const profileData = p;
748
765
  if (profileData) {
749
- userName = userName || profileData.name || profileData.fullName || "";
750
766
  userEmail = userEmail || profileData.email || profileData.emailAddress || "";
767
+ userName = userName || profileData.name || profileData.fullName || buildNameFromFirstLast(profileData) || "";
751
768
  userRole = userRole || profileData.role || profileData.userRole || "";
752
769
  }
753
770
  }
@@ -796,67 +813,81 @@ const AppHeader = ({ language: languageProp }) => {
796
813
  }, []); // Only run once on mount - fetch when component loads
797
814
  React__default.useEffect(() => {
798
815
  const allData = getAllDataFromStorage();
799
- // Try to get user data from various sources
800
816
  let userName = "";
801
817
  let userEmail = "";
802
818
  let userRole = "";
803
- let userAvatar = undefined;
804
- let userInitials = undefined;
805
- // Priority 1: From decoded token
806
- if (allData.decodedToken) {
807
- userName = allData.decodedToken.sub || allData.decodedToken.email || "";
808
- userEmail = allData.decodedToken.sub || allData.decodedToken.email || "";
809
- userRole = allData.decodedToken.role || "";
810
- }
811
- // Priority 2: From auth data
812
- if (allData.auth) {
813
- userName = userName || allData.auth.name || allData.auth.email || "";
814
- userEmail = userEmail || allData.auth.email || allData.auth.sub || "";
815
- userRole = userRole || allData.auth.role || allData.auth.activeRole || "";
816
- userAvatar = userAvatar || allData.auth.avatar || undefined;
817
- userInitials = userInitials || allData.auth.initials || undefined;
818
- }
819
- // Priority 3: From userDetails/user/profile
819
+ let userAvatar;
820
+ let userInitials;
821
+ const buildNameFromFirstLast = (obj) => {
822
+ if (!obj || typeof obj !== "object")
823
+ return "";
824
+ const first = (obj.firstName ?? obj.given_name ?? obj.first_name);
825
+ const last = (obj.lastName ?? obj.family_name ?? obj.last_name);
826
+ return [first, last].filter(Boolean).join(" ").trim();
827
+ };
820
828
  const storedUser = getUserDataFromStorage();
821
829
  if (storedUser) {
822
- userName = userName || storedUser.name || "";
830
+ userName = storedUser.name || "";
823
831
  userEmail = userEmail || storedUser.email || "";
824
832
  userRole = userRole || storedUser.role || "";
825
- userAvatar = userAvatar || storedUser.avatar || undefined;
826
- userInitials = userInitials || storedUser.initials || undefined;
833
+ userAvatar = storedUser.avatar;
834
+ userInitials = storedUser.initials;
835
+ }
836
+ if (allData.decodedToken) {
837
+ const token = allData.decodedToken;
838
+ userEmail = userEmail || token.sub || token.email || "";
839
+ const tokenName = token.name || buildNameFromFirstLast(token);
840
+ userName = userName || (tokenName || "");
841
+ userRole = userRole || token.role || "";
842
+ }
843
+ if (allData.auth) {
844
+ const auth = allData.auth;
845
+ userEmail = userEmail || auth.email || auth.sub || "";
846
+ userName = userName || auth.name || buildNameFromFirstLast(auth) || "";
847
+ userRole = userRole || auth.role || auth.activeRole || "";
848
+ userAvatar = userAvatar || auth.avatar || undefined;
849
+ userInitials = userInitials || auth.initials || undefined;
827
850
  }
828
- // Priority 4: From other parsed data
829
851
  if (allData.userDetails) {
830
- const userDetails = allData.userDetails.user || allData.userDetails.data || allData.userDetails;
831
- if (userDetails) {
832
- userName = userName || userDetails.name || userDetails.fullName || "";
833
- userEmail = userEmail || userDetails.email || userDetails.emailAddress || "";
834
- userRole = userRole || userDetails.role || userDetails.userRole || "";
835
- userAvatar = userAvatar || userDetails.avatar || userDetails.profilePicture || undefined;
836
- userInitials = userInitials || userDetails.initials || undefined;
852
+ const userDetails = allData.userDetails.user
853
+ || allData.userDetails.data
854
+ || allData.userDetails;
855
+ const details = userDetails;
856
+ if (details) {
857
+ userEmail = userEmail || details.email || details.emailAddress || "";
858
+ userName = userName || details.name || details.fullName || buildNameFromFirstLast(details) || "";
859
+ userRole = userRole || details.role || details.userRole || "";
860
+ userAvatar = userAvatar || details.avatar || details.profilePicture || undefined;
861
+ userInitials = userInitials || details.initials || undefined;
837
862
  }
838
863
  }
839
864
  if (allData.user) {
840
- const userData = allData.user.user || allData.user.data || allData.user.currentUser || allData.user;
865
+ const u = allData.user.user
866
+ || allData.user.data
867
+ || allData.user.currentUser
868
+ || allData.user;
869
+ const userData = u;
841
870
  if (userData) {
842
- userName = userName || userData.name || userData.fullName || "";
843
871
  userEmail = userEmail || userData.email || userData.emailAddress || "";
872
+ userName = userName || userData.name || userData.fullName || buildNameFromFirstLast(userData) || "";
844
873
  userRole = userRole || userData.role || userData.userRole || "";
845
874
  userAvatar = userAvatar || userData.avatar || userData.profilePicture || undefined;
846
875
  userInitials = userInitials || userData.initials || undefined;
847
876
  }
848
877
  }
849
878
  if (allData.profile) {
850
- const profileData = allData.profile.user || allData.profile.data || allData.profile;
879
+ const p = allData.profile.user
880
+ || allData.profile.data
881
+ || allData.profile;
882
+ const profileData = p;
851
883
  if (profileData) {
852
- userName = userName || profileData.name || profileData.fullName || "";
853
884
  userEmail = userEmail || profileData.email || profileData.emailAddress || "";
885
+ userName = userName || profileData.name || profileData.fullName || buildNameFromFirstLast(profileData) || "";
854
886
  userRole = userRole || profileData.role || profileData.userRole || "";
855
887
  userAvatar = userAvatar || profileData.avatar || profileData.profilePicture || undefined;
856
888
  userInitials = userInitials || profileData.initials || undefined;
857
889
  }
858
890
  }
859
- // Use fetched blob URL if available, otherwise fall back to other sources
860
891
  setUser({
861
892
  name: userName || "",
862
893
  email: userEmail || "",
@@ -1023,7 +1054,7 @@ const AppHeader = ({ language: languageProp }) => {
1023
1054
  width: "100%",
1024
1055
  maxWidth: 360,
1025
1056
  pointerEvents: "none",
1026
- }, 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] })] }) })] }) }));
1057
+ }, 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, { primary: jsx(Typography, { className: "profile-name", component: "span", children: user.name || user.email }), secondary: jsxs(React__default.Fragment, { children: [user.name && user.email ? (jsx(Typography, { className: "profile-email", component: "p", children: user.email })) : null, jsxs(Typography, { className: "profile-role", component: "p", children: [t.role, ": ", user.role] })] }) })] }) }));
1027
1058
  const renderMenu = (jsxs(Menu, { anchorEl: anchorEl, id: "account-menu", open: open, onClose: handleClose, onClick: handleClose, slotProps: {
1028
1059
  paper: {
1029
1060
  elevation: 0,