impact-chatbot 2.3.91 → 2.3.94

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,5 +1,5 @@
1
1
  export function pxToRem(px: any): string;
2
- export function getCurrentUserId(): any;
2
+ export function getCurrentUserId(): Promise<any>;
3
3
  export function getUserName(): any;
4
4
  export function fetchApplicationCode(): string;
5
5
  export function fetchBaseUrl(): string;
package/dist/index.cjs.js CHANGED
@@ -1315,13 +1315,39 @@ const replaceSpecialCharToCharCode = (str) => {
1315
1315
  * Only includes functions used by chatbot-v2
1316
1316
  */
1317
1317
 
1318
+ // Users listing endpoint (same as core's GET_USERS). Inlined here so this
1319
+ // standalone package doesn't depend on the core user-management service.
1320
+ const GET_USERS_URL = "/core/user-mgmt/list";
1321
+
1318
1322
  // Convert pixels to rem
1319
1323
  const pxToRem = (px) => `${px / 16}rem`;
1320
1324
 
1321
- // Get current user ID from session storage
1322
- const getCurrentUserId = () => {
1323
- const userDetails = JSON.parse(sessionStorage.getItem("userDetails") || "{}");
1324
- return userDetails?.user_id || null;
1325
+ // Resolve the current user's code via the users API, matching the logged-in
1326
+ // email (localStorage "name"). Mirrors core/Utils/functions/utils.getCurrentUserId
1327
+ // so the multi-chat history APIs receive a real user_id (sessionStorage may not
1328
+ // carry it in the standalone package host).
1329
+ const getCurrentUserId = async () => {
1330
+ try {
1331
+ const postBody = {
1332
+ meta: {
1333
+ search: [],
1334
+ range: [],
1335
+ sort: [],
1336
+ },
1337
+ };
1338
+ const users = await axiosInstance({
1339
+ url: GET_USERS_URL,
1340
+ method: "POST",
1341
+ data: postBody,
1342
+ });
1343
+ const loggedInUserEmail = localStorage.getItem("name");
1344
+ const user = users?.data?.data?.filter((item) => {
1345
+ return item.email === loggedInUserEmail;
1346
+ });
1347
+ return user[0]?.user_code;
1348
+ } catch (error) {
1349
+ console.error("getCurrentUserId error", error);
1350
+ }
1325
1351
  };
1326
1352
 
1327
1353
  // Get user name from session storage