varminer-app-header 2.1.9 → 2.2.1
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/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +44 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +44 -21
- package/dist/index.js.map +1 -1
- package/dist/utils/localStorage.d.ts +9 -2
- package/dist/utils/localStorage.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -376,38 +376,60 @@ const getAllDataFromStorage = () => {
|
|
|
376
376
|
}
|
|
377
377
|
};
|
|
378
378
|
/**
|
|
379
|
-
* Get profile picture URL from object store API using
|
|
379
|
+
* Get profile picture URL from object store API using user_id.
|
|
380
380
|
* @param baseUrl - Base URL for the object store API (default: http://objectstore.impact0mics.local:9012)
|
|
381
|
-
* @returns Profile picture URL or null if
|
|
381
|
+
* @returns Profile picture URL or null if user_id is not available
|
|
382
382
|
*/
|
|
383
383
|
const getProfilePictureUrl = (baseUrl = "http://objectstore.impact0mics.local:9012") => {
|
|
384
384
|
try {
|
|
385
385
|
const allData = getAllDataFromStorage();
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
tenantId = allData.decodedToken.tenant_id || allData.decodedToken.tenant || null;
|
|
391
|
-
userId = allData.decodedToken.user_id || null;
|
|
392
|
-
}
|
|
393
|
-
// If not found in decoded token, try auth data
|
|
394
|
-
if ((!tenantId || !userId) && allData.auth) {
|
|
395
|
-
tenantId = tenantId || allData.auth.tenant_id || allData.auth.tenant || null;
|
|
396
|
-
userId = userId || allData.auth.user_id || null;
|
|
397
|
-
}
|
|
398
|
-
// Construct URL if we have both tenant_id and user_id
|
|
399
|
-
if (tenantId && userId) {
|
|
400
|
-
// Remove trailing slash from baseUrl if present
|
|
401
|
-
const cleanBaseUrl = baseUrl.replace(/\/$/, '');
|
|
402
|
-
return `${cleanBaseUrl}/v1/objectStore/profilePicture/path/${tenantId}/${userId}`;
|
|
403
|
-
}
|
|
404
|
-
return null;
|
|
386
|
+
const userId = allData.decodedToken?.user_id ?? allData.auth?.user_id ?? getStoredUserDetails()?.userId ?? null;
|
|
387
|
+
if (userId == null)
|
|
388
|
+
return null;
|
|
389
|
+
return `${baseUrl.replace(/\/$/, "")}/v1/objectStore/profilePicture/path/${userId}`;
|
|
405
390
|
}
|
|
406
391
|
catch (err) {
|
|
407
392
|
console.error("Error getting profile picture URL:", err);
|
|
408
393
|
return null;
|
|
409
394
|
}
|
|
410
395
|
};
|
|
396
|
+
/**
|
|
397
|
+
* Get profile picture upload URL for the object store API.
|
|
398
|
+
* URL format: {baseUrl}/v1/objectStore/profilePictureUpload?tenantId=&userId=&roleId=
|
|
399
|
+
* @param baseUrl - Base URL for the object store API (default: http://objectstore.impact0mics.local:9012)
|
|
400
|
+
* @returns Full upload URL with query params, or null if tenantId, userId, or roleId is missing
|
|
401
|
+
*/
|
|
402
|
+
const getProfilePictureUploadUrl = (baseUrl = "http://objectstore.impact0mics.local:9012") => {
|
|
403
|
+
try {
|
|
404
|
+
const allData = getAllDataFromStorage();
|
|
405
|
+
const iamUser = getStoredUserDetails();
|
|
406
|
+
const tenantId = allData.decodedToken?.tenant_id ??
|
|
407
|
+
allData.decodedToken?.tenant ??
|
|
408
|
+
allData.auth?.tenant_id ??
|
|
409
|
+
allData.auth?.tenant ??
|
|
410
|
+
null;
|
|
411
|
+
const userId = allData.decodedToken?.user_id ??
|
|
412
|
+
allData.auth?.user_id ??
|
|
413
|
+
iamUser?.userId ??
|
|
414
|
+
null;
|
|
415
|
+
const roleId = allData.decodedToken?.role_id ??
|
|
416
|
+
allData.auth?.role_id ??
|
|
417
|
+
null;
|
|
418
|
+
if (tenantId == null || userId == null || roleId == null)
|
|
419
|
+
return null;
|
|
420
|
+
const cleanBaseUrl = baseUrl.replace(/\/$/, "");
|
|
421
|
+
const params = new URLSearchParams({
|
|
422
|
+
tenantId: String(tenantId),
|
|
423
|
+
userId: String(userId),
|
|
424
|
+
roleId: String(roleId),
|
|
425
|
+
});
|
|
426
|
+
return `${cleanBaseUrl}/v1/objectStore/profilePictureUpload?${params.toString()}`;
|
|
427
|
+
}
|
|
428
|
+
catch (err) {
|
|
429
|
+
console.error("Error getting profile picture upload URL:", err);
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
411
433
|
/**
|
|
412
434
|
* Generate AWS S3 presigned URL for accessing S3 object
|
|
413
435
|
* @param s3Url - Full S3 URL (e.g., https://bucket.s3.region.amazonaws.com/key)
|
|
@@ -1170,6 +1192,7 @@ exports.getAllDataFromStorage = getAllDataFromStorage;
|
|
|
1170
1192
|
exports.getI18nLocaleFromStorage = getI18nLocaleFromStorage;
|
|
1171
1193
|
exports.getMessageCountFromStorage = getMessageCountFromStorage;
|
|
1172
1194
|
exports.getNotificationCountFromStorage = getNotificationCountFromStorage;
|
|
1195
|
+
exports.getProfilePictureUploadUrl = getProfilePictureUploadUrl;
|
|
1173
1196
|
exports.getProfilePictureUrl = getProfilePictureUrl;
|
|
1174
1197
|
exports.getStoredUserDetails = getStoredUserDetails;
|
|
1175
1198
|
exports.getTranslations = getTranslations;
|