varminer-app-header 2.1.6 → 2.1.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.
@@ -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,CAwwBvC,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,CA6wBvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
package/dist/index.d.ts CHANGED
@@ -40,5 +40,88 @@ interface Translations {
40
40
  declare const translations: Record<SupportedLanguage, Translations>;
41
41
  declare const getTranslations: (language?: SupportedLanguage) => Translations;
42
42
 
43
- export { AppHeader, DrawerProvider, getTranslations, translations, useDrawer };
44
- export type { AppHeaderProps, SupportedLanguage, Translations, UserProfile };
43
+ /** localStorage key used by IAM app for user details (GET /v1/userManagement/userDetails response). */
44
+ declare const USER_DETAILS_STORAGE_KEY = "linn-i-am-userDetails";
45
+ /** Stored value is the full API response from userDetails. */
46
+ interface UserDetailsStoredResponse {
47
+ status: "SUCCESS" | "FAILURE";
48
+ statusinfo: {
49
+ code: string;
50
+ message: string;
51
+ };
52
+ data?: {
53
+ usersDetails: UserDetailsItem[];
54
+ };
55
+ errors?: Record<string, string> | null;
56
+ }
57
+ interface UserDetailsItem {
58
+ userId: number;
59
+ firstName: string;
60
+ lastName: string;
61
+ email: string;
62
+ status: string;
63
+ roles?: string[];
64
+ lastLogin?: string;
65
+ createdDate?: string;
66
+ contactNumber?: {
67
+ phoneType: string;
68
+ phoneNumber: string;
69
+ }[];
70
+ timeZone?: string;
71
+ workInfo?: {
72
+ jobTitle?: string;
73
+ department?: string;
74
+ supervisor?: string;
75
+ };
76
+ }
77
+ /**
78
+ * Read user details from IAM app localStorage (set after verify-OTP on same origin).
79
+ * Does not write or overwrite this key; IAM app is the source of truth.
80
+ */
81
+ declare function getStoredUserDetails(): UserDetailsItem | null;
82
+ declare const getUserDataFromStorage: () => {
83
+ name: any;
84
+ email: any;
85
+ role: any;
86
+ avatar: any;
87
+ initials: any;
88
+ } | null;
89
+ declare const getNotificationCountFromStorage: () => number;
90
+ declare const getMessageCountFromStorage: () => number | undefined;
91
+ declare const getI18nLocaleFromStorage: () => string | null;
92
+ declare const setI18nLocaleToStorage: (locale: string) => void;
93
+ /**
94
+ * Get all data from localStorage (persist:userdb) including decoded accessToken
95
+ * This function reads all available data without hardcoding and doesn't require any parameters
96
+ * @returns Comprehensive object containing all available data from localStorage and decoded JWT payload
97
+ */
98
+ declare const getAllDataFromStorage: () => any;
99
+ /**
100
+ * Get profile picture URL from object store API using tenant_id and user_id from JWT token
101
+ * @param baseUrl - Base URL for the object store API (default: http://objectstore.impact0mics.local:9012)
102
+ * @returns Profile picture URL or null if tenant_id or user_id is not available
103
+ */
104
+ declare const getProfilePictureUrl: (baseUrl?: string) => string | null;
105
+ /**
106
+ * Fetch profile picture from API with headers, get S3 URL, generate presigned URL, and return as blob URL
107
+ * This function:
108
+ * 1. Fetches the profile picture path from the API
109
+ * 2. Extracts the S3 filePath from the JSON response
110
+ * 3. Generates a presigned URL for the S3 object
111
+ * 4. Fetches the image using the presigned URL
112
+ * 5. Converts it to a blob URL that can be used in img src
113
+ * @param baseUrl - Base URL for the object store API (default: http://objectstore.impact0mics.local:9012)
114
+ * @param messageId - Optional message ID for X-Message-Id header (default: generated UUID)
115
+ * @param correlationId - Optional correlation ID for X-Correlation-Id header (default: generated UUID)
116
+ * @param awsConfig - AWS configuration (accessKeyId, secretAccessKey, region, bucket)
117
+ * @returns Promise that resolves to blob URL string or null if fetch fails
118
+ */
119
+ declare const fetchProfilePictureAsBlobUrl: (baseUrl?: string, messageId?: string, correlationId?: string, awsConfig?: {
120
+ accessKeyId: string;
121
+ secretAccessKey: string;
122
+ region?: string;
123
+ bucket?: string;
124
+ }) => Promise<string | null>;
125
+
126
+ export { AppHeader, DrawerProvider, USER_DETAILS_STORAGE_KEY, fetchProfilePictureAsBlobUrl, getAllDataFromStorage, getI18nLocaleFromStorage, getMessageCountFromStorage, getNotificationCountFromStorage, getProfilePictureUrl, getStoredUserDetails, getTranslations, getUserDataFromStorage, setI18nLocaleToStorage, translations, useDrawer };
127
+ export type { AppHeaderProps, SupportedLanguage, Translations, UserDetailsItem, UserDetailsStoredResponse, UserProfile };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.esm.js CHANGED
@@ -35,7 +35,42 @@ const DrawerProvider = ({ children }) => {
35
35
  };
36
36
  const useDrawer = () => React.useContext(DrawerContext);
37
37
 
38
+ // --- IAM app user details (shared from IAM after verify-OTP, same origin) ---
39
+ /** localStorage key used by IAM app for user details (GET /v1/userManagement/userDetails response). */
40
+ const USER_DETAILS_STORAGE_KEY = "linn-i-am-userDetails";
41
+ /**
42
+ * Read user details from IAM app localStorage (set after verify-OTP on same origin).
43
+ * Does not write or overwrite this key; IAM app is the source of truth.
44
+ */
45
+ function getStoredUserDetails() {
46
+ try {
47
+ const raw = localStorage.getItem(USER_DETAILS_STORAGE_KEY);
48
+ if (!raw)
49
+ return null;
50
+ const parsed = JSON.parse(raw);
51
+ if (parsed.status !== "SUCCESS" || !parsed.data?.usersDetails?.length) {
52
+ return null;
53
+ }
54
+ return parsed.data.usersDetails[0];
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ }
38
60
  const getUserDataFromStorage = () => {
61
+ // Prefer IAM user details when available (same origin, after verify-OTP)
62
+ const iamUser = getStoredUserDetails();
63
+ if (iamUser) {
64
+ const name = [iamUser.firstName, iamUser.lastName].filter(Boolean).join(" ").trim();
65
+ const role = iamUser.roles?.length ? iamUser.roles[0] : iamUser.workInfo?.jobTitle ?? "";
66
+ return {
67
+ name: name || "",
68
+ email: iamUser.email || "",
69
+ role: role || "",
70
+ avatar: undefined,
71
+ initials: name ? name.split(/\s+/).map((s) => s[0]).join("").slice(0, 2).toUpperCase() : undefined,
72
+ };
73
+ }
39
74
  const userDbString = localStorage.getItem("persist:userdb");
40
75
  if (userDbString) {
41
76
  try {
@@ -560,7 +595,8 @@ const languages = [
560
595
  { code: "en", name: "English", flag: GBFlag },
561
596
  { code: "es", name: "Spanish", flag: ESFlag },
562
597
  ];
563
- const LanguageSelector = ({ currentLanguage, onLanguageChange, }) => {
598
+ const LanguageSelector = ({ currentLanguage, onLanguageChange: _onLanguageChange, // reserved for parent callback; we reload the page on select
599
+ }) => {
564
600
  const [anchorEl, setAnchorEl] = React__default.useState(null);
565
601
  const open = Boolean(anchorEl);
566
602
  const currentLang = languages.find((lang) => lang.code === currentLanguage) || languages[0];
@@ -921,7 +957,13 @@ const AppHeader = ({ language: languageProp }) => {
921
957
  };
922
958
  const handleSignOutClick = () => {
923
959
  handleClose();
924
- localStorage.clear();
960
+ try {
961
+ localStorage.clear();
962
+ sessionStorage.clear();
963
+ }
964
+ catch (e) {
965
+ console.warn("Clear storage on logout:", e);
966
+ }
925
967
  const path = finalRoutes.logout.startsWith('/')
926
968
  ? finalRoutes.logout
927
969
  : `/${finalRoutes.logout}`;
@@ -1069,5 +1111,5 @@ const AppHeader = ({ language: languageProp }) => {
1069
1111
  }, children: jsx(MoreIcon, {}) }) })] }) }), renderMobileMenu, renderMenu] }));
1070
1112
  };
1071
1113
 
1072
- export { AppHeader, DrawerProvider, getTranslations, translations, useDrawer };
1114
+ export { AppHeader, DrawerProvider, USER_DETAILS_STORAGE_KEY, fetchProfilePictureAsBlobUrl, getAllDataFromStorage, getI18nLocaleFromStorage, getMessageCountFromStorage, getNotificationCountFromStorage, getProfilePictureUrl, getStoredUserDetails, getTranslations, getUserDataFromStorage, setI18nLocaleToStorage, translations, useDrawer };
1073
1115
  //# sourceMappingURL=index.esm.js.map