varminer-app-header 2.1.8 → 2.2.0
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 +2 -2
- package/dist/index.esm.js +96 -80
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +96 -80
- package/dist/index.js.map +1 -1
- package/dist/utils/localStorage.d.ts +2 -2
- package/dist/utils/localStorage.d.ts.map +1 -1
- package/package.json +1 -1
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,EAAe,MAAM,SAAS,CAAC;AAKtD,OAAO,sBAAsB,CAAC;AAQ9B,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,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.d.ts
CHANGED
|
@@ -97,9 +97,9 @@ declare const setI18nLocaleToStorage: (locale: string) => void;
|
|
|
97
97
|
*/
|
|
98
98
|
declare const getAllDataFromStorage: () => any;
|
|
99
99
|
/**
|
|
100
|
-
* Get profile picture URL from object store API using
|
|
100
|
+
* Get profile picture URL from object store API using user_id.
|
|
101
101
|
* @param baseUrl - Base URL for the object store API (default: http://objectstore.impact0mics.local:9012)
|
|
102
|
-
* @returns Profile picture URL or null if
|
|
102
|
+
* @returns Profile picture URL or null if user_id is not available
|
|
103
103
|
*/
|
|
104
104
|
declare const getProfilePictureUrl: (baseUrl?: string) => string | null;
|
|
105
105
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -356,32 +356,17 @@ const getAllDataFromStorage = () => {
|
|
|
356
356
|
}
|
|
357
357
|
};
|
|
358
358
|
/**
|
|
359
|
-
* Get profile picture URL from object store API using
|
|
359
|
+
* Get profile picture URL from object store API using user_id.
|
|
360
360
|
* @param baseUrl - Base URL for the object store API (default: http://objectstore.impact0mics.local:9012)
|
|
361
|
-
* @returns Profile picture URL or null if
|
|
361
|
+
* @returns Profile picture URL or null if user_id is not available
|
|
362
362
|
*/
|
|
363
363
|
const getProfilePictureUrl = (baseUrl = "http://objectstore.impact0mics.local:9012") => {
|
|
364
364
|
try {
|
|
365
365
|
const allData = getAllDataFromStorage();
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
tenantId = allData.decodedToken.tenant_id || allData.decodedToken.tenant || null;
|
|
371
|
-
userId = allData.decodedToken.user_id || null;
|
|
372
|
-
}
|
|
373
|
-
// If not found in decoded token, try auth data
|
|
374
|
-
if ((!tenantId || !userId) && allData.auth) {
|
|
375
|
-
tenantId = tenantId || allData.auth.tenant_id || allData.auth.tenant || null;
|
|
376
|
-
userId = userId || allData.auth.user_id || null;
|
|
377
|
-
}
|
|
378
|
-
// Construct URL if we have both tenant_id and user_id
|
|
379
|
-
if (tenantId && userId) {
|
|
380
|
-
// Remove trailing slash from baseUrl if present
|
|
381
|
-
const cleanBaseUrl = baseUrl.replace(/\/$/, '');
|
|
382
|
-
return `${cleanBaseUrl}/v1/objectStore/profilePicture/path/${tenantId}/${userId}`;
|
|
383
|
-
}
|
|
384
|
-
return null;
|
|
366
|
+
const userId = allData.decodedToken?.user_id ?? allData.auth?.user_id ?? getStoredUserDetails()?.userId ?? null;
|
|
367
|
+
if (userId == null)
|
|
368
|
+
return null;
|
|
369
|
+
return `${baseUrl.replace(/\/$/, "")}/v1/objectStore/profilePicture/path/${userId}`;
|
|
385
370
|
}
|
|
386
371
|
catch (err) {
|
|
387
372
|
console.error("Error getting profile picture URL:", err);
|
|
@@ -703,51 +688,68 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
703
688
|
const [mobileMoreAnchorEl, setMobileMoreAnchorEl] = React__default.useState(null);
|
|
704
689
|
const [user, setUser] = React__default.useState(() => {
|
|
705
690
|
const allData = getAllDataFromStorage();
|
|
706
|
-
// Try to get user data from various sources
|
|
707
691
|
let userName = "";
|
|
708
692
|
let userEmail = "";
|
|
709
693
|
let userRole = "";
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
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
|
|
694
|
+
const buildNameFromFirstLast = (obj) => {
|
|
695
|
+
if (!obj || typeof obj !== "object")
|
|
696
|
+
return "";
|
|
697
|
+
const first = (obj.firstName ?? obj.given_name ?? obj.first_name);
|
|
698
|
+
const last = (obj.lastName ?? obj.family_name ?? obj.last_name);
|
|
699
|
+
return [first, last].filter(Boolean).join(" ").trim();
|
|
700
|
+
};
|
|
701
|
+
// Prefer getUserDataFromStorage first (IAM firstName+lastName or persist:userdb name)
|
|
723
702
|
const storedUser = getUserDataFromStorage();
|
|
724
703
|
if (storedUser) {
|
|
725
|
-
userName =
|
|
704
|
+
userName = storedUser.name || "";
|
|
726
705
|
userEmail = userEmail || storedUser.email || "";
|
|
727
706
|
userRole = userRole || storedUser.role || "";
|
|
728
707
|
}
|
|
729
|
-
//
|
|
708
|
+
// Then enrich from decoded token (email from sub; name only if token has name/given_name/family_name, never use sub as name)
|
|
709
|
+
if (allData.decodedToken) {
|
|
710
|
+
const token = allData.decodedToken;
|
|
711
|
+
userEmail = userEmail || token.sub || token.email || "";
|
|
712
|
+
const tokenName = token.name || buildNameFromFirstLast(token);
|
|
713
|
+
userName = userName || (tokenName || "");
|
|
714
|
+
userRole = userRole || token.role || "";
|
|
715
|
+
}
|
|
716
|
+
if (allData.auth) {
|
|
717
|
+
const auth = allData.auth;
|
|
718
|
+
userEmail = userEmail || auth.email || auth.sub || "";
|
|
719
|
+
userName = userName || auth.name || buildNameFromFirstLast(auth) || "";
|
|
720
|
+
userRole = userRole || auth.role || auth.activeRole || "";
|
|
721
|
+
}
|
|
730
722
|
if (allData.userDetails) {
|
|
731
|
-
const userDetails = allData.userDetails.user
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
723
|
+
const userDetails = allData.userDetails.user
|
|
724
|
+
|| allData.userDetails.data
|
|
725
|
+
|| allData.userDetails;
|
|
726
|
+
const details = userDetails;
|
|
727
|
+
if (details) {
|
|
728
|
+
userEmail = userEmail || details.email || details.emailAddress || "";
|
|
729
|
+
userName = userName || details.name || details.fullName || buildNameFromFirstLast(details) || "";
|
|
730
|
+
userRole = userRole || details.role || details.userRole || "";
|
|
736
731
|
}
|
|
737
732
|
}
|
|
738
733
|
if (allData.user) {
|
|
739
|
-
const
|
|
734
|
+
const u = allData.user.user
|
|
735
|
+
|| allData.user.data
|
|
736
|
+
|| allData.user.currentUser
|
|
737
|
+
|| allData.user;
|
|
738
|
+
const userData = u;
|
|
740
739
|
if (userData) {
|
|
741
|
-
userName = userName || userData.name || userData.fullName || "";
|
|
742
740
|
userEmail = userEmail || userData.email || userData.emailAddress || "";
|
|
741
|
+
userName = userName || userData.name || userData.fullName || buildNameFromFirstLast(userData) || "";
|
|
743
742
|
userRole = userRole || userData.role || userData.userRole || "";
|
|
744
743
|
}
|
|
745
744
|
}
|
|
746
745
|
if (allData.profile) {
|
|
747
|
-
const
|
|
746
|
+
const p = allData.profile.user
|
|
747
|
+
|| allData.profile.data
|
|
748
|
+
|| allData.profile;
|
|
749
|
+
const profileData = p;
|
|
748
750
|
if (profileData) {
|
|
749
|
-
userName = userName || profileData.name || profileData.fullName || "";
|
|
750
751
|
userEmail = userEmail || profileData.email || profileData.emailAddress || "";
|
|
752
|
+
userName = userName || profileData.name || profileData.fullName || buildNameFromFirstLast(profileData) || "";
|
|
751
753
|
userRole = userRole || profileData.role || profileData.userRole || "";
|
|
752
754
|
}
|
|
753
755
|
}
|
|
@@ -796,67 +798,81 @@ const AppHeader = ({ language: languageProp }) => {
|
|
|
796
798
|
}, []); // Only run once on mount - fetch when component loads
|
|
797
799
|
React__default.useEffect(() => {
|
|
798
800
|
const allData = getAllDataFromStorage();
|
|
799
|
-
// Try to get user data from various sources
|
|
800
801
|
let userName = "";
|
|
801
802
|
let userEmail = "";
|
|
802
803
|
let userRole = "";
|
|
803
|
-
let userAvatar
|
|
804
|
-
let userInitials
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
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
|
|
804
|
+
let userAvatar;
|
|
805
|
+
let userInitials;
|
|
806
|
+
const buildNameFromFirstLast = (obj) => {
|
|
807
|
+
if (!obj || typeof obj !== "object")
|
|
808
|
+
return "";
|
|
809
|
+
const first = (obj.firstName ?? obj.given_name ?? obj.first_name);
|
|
810
|
+
const last = (obj.lastName ?? obj.family_name ?? obj.last_name);
|
|
811
|
+
return [first, last].filter(Boolean).join(" ").trim();
|
|
812
|
+
};
|
|
820
813
|
const storedUser = getUserDataFromStorage();
|
|
821
814
|
if (storedUser) {
|
|
822
|
-
userName =
|
|
815
|
+
userName = storedUser.name || "";
|
|
823
816
|
userEmail = userEmail || storedUser.email || "";
|
|
824
817
|
userRole = userRole || storedUser.role || "";
|
|
825
|
-
userAvatar =
|
|
826
|
-
userInitials =
|
|
818
|
+
userAvatar = storedUser.avatar;
|
|
819
|
+
userInitials = storedUser.initials;
|
|
820
|
+
}
|
|
821
|
+
if (allData.decodedToken) {
|
|
822
|
+
const token = allData.decodedToken;
|
|
823
|
+
userEmail = userEmail || token.sub || token.email || "";
|
|
824
|
+
const tokenName = token.name || buildNameFromFirstLast(token);
|
|
825
|
+
userName = userName || (tokenName || "");
|
|
826
|
+
userRole = userRole || token.role || "";
|
|
827
|
+
}
|
|
828
|
+
if (allData.auth) {
|
|
829
|
+
const auth = allData.auth;
|
|
830
|
+
userEmail = userEmail || auth.email || auth.sub || "";
|
|
831
|
+
userName = userName || auth.name || buildNameFromFirstLast(auth) || "";
|
|
832
|
+
userRole = userRole || auth.role || auth.activeRole || "";
|
|
833
|
+
userAvatar = userAvatar || auth.avatar || undefined;
|
|
834
|
+
userInitials = userInitials || auth.initials || undefined;
|
|
827
835
|
}
|
|
828
|
-
// Priority 4: From other parsed data
|
|
829
836
|
if (allData.userDetails) {
|
|
830
|
-
const userDetails = allData.userDetails.user
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
+
const userDetails = allData.userDetails.user
|
|
838
|
+
|| allData.userDetails.data
|
|
839
|
+
|| allData.userDetails;
|
|
840
|
+
const details = userDetails;
|
|
841
|
+
if (details) {
|
|
842
|
+
userEmail = userEmail || details.email || details.emailAddress || "";
|
|
843
|
+
userName = userName || details.name || details.fullName || buildNameFromFirstLast(details) || "";
|
|
844
|
+
userRole = userRole || details.role || details.userRole || "";
|
|
845
|
+
userAvatar = userAvatar || details.avatar || details.profilePicture || undefined;
|
|
846
|
+
userInitials = userInitials || details.initials || undefined;
|
|
837
847
|
}
|
|
838
848
|
}
|
|
839
849
|
if (allData.user) {
|
|
840
|
-
const
|
|
850
|
+
const u = allData.user.user
|
|
851
|
+
|| allData.user.data
|
|
852
|
+
|| allData.user.currentUser
|
|
853
|
+
|| allData.user;
|
|
854
|
+
const userData = u;
|
|
841
855
|
if (userData) {
|
|
842
|
-
userName = userName || userData.name || userData.fullName || "";
|
|
843
856
|
userEmail = userEmail || userData.email || userData.emailAddress || "";
|
|
857
|
+
userName = userName || userData.name || userData.fullName || buildNameFromFirstLast(userData) || "";
|
|
844
858
|
userRole = userRole || userData.role || userData.userRole || "";
|
|
845
859
|
userAvatar = userAvatar || userData.avatar || userData.profilePicture || undefined;
|
|
846
860
|
userInitials = userInitials || userData.initials || undefined;
|
|
847
861
|
}
|
|
848
862
|
}
|
|
849
863
|
if (allData.profile) {
|
|
850
|
-
const
|
|
864
|
+
const p = allData.profile.user
|
|
865
|
+
|| allData.profile.data
|
|
866
|
+
|| allData.profile;
|
|
867
|
+
const profileData = p;
|
|
851
868
|
if (profileData) {
|
|
852
|
-
userName = userName || profileData.name || profileData.fullName || "";
|
|
853
869
|
userEmail = userEmail || profileData.email || profileData.emailAddress || "";
|
|
870
|
+
userName = userName || profileData.name || profileData.fullName || buildNameFromFirstLast(profileData) || "";
|
|
854
871
|
userRole = userRole || profileData.role || profileData.userRole || "";
|
|
855
872
|
userAvatar = userAvatar || profileData.avatar || profileData.profilePicture || undefined;
|
|
856
873
|
userInitials = userInitials || profileData.initials || undefined;
|
|
857
874
|
}
|
|
858
875
|
}
|
|
859
|
-
// Use fetched blob URL if available, otherwise fall back to other sources
|
|
860
876
|
setUser({
|
|
861
877
|
name: userName || "",
|
|
862
878
|
email: userEmail || "",
|