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.
package/dist/index.esm.js CHANGED
@@ -1293,13 +1293,39 @@ const replaceSpecialCharToCharCode = (str) => {
1293
1293
  * Only includes functions used by chatbot-v2
1294
1294
  */
1295
1295
 
1296
+ // Users listing endpoint (same as core's GET_USERS). Inlined here so this
1297
+ // standalone package doesn't depend on the core user-management service.
1298
+ const GET_USERS_URL = "/core/user-mgmt/list";
1299
+
1296
1300
  // Convert pixels to rem
1297
1301
  const pxToRem = (px) => `${px / 16}rem`;
1298
1302
 
1299
- // Get current user ID from session storage
1300
- const getCurrentUserId = () => {
1301
- const userDetails = JSON.parse(sessionStorage.getItem("userDetails") || "{}");
1302
- return userDetails?.user_id || null;
1303
+ // Resolve the current user's code via the users API, matching the logged-in
1304
+ // email (localStorage "name"). Mirrors core/Utils/functions/utils.getCurrentUserId
1305
+ // so the multi-chat history APIs receive a real user_id (sessionStorage may not
1306
+ // carry it in the standalone package host).
1307
+ const getCurrentUserId = async () => {
1308
+ try {
1309
+ const postBody = {
1310
+ meta: {
1311
+ search: [],
1312
+ range: [],
1313
+ sort: [],
1314
+ },
1315
+ };
1316
+ const users = await axiosInstance({
1317
+ url: GET_USERS_URL,
1318
+ method: "POST",
1319
+ data: postBody,
1320
+ });
1321
+ const loggedInUserEmail = localStorage.getItem("name");
1322
+ const user = users?.data?.data?.filter((item) => {
1323
+ return item.email === loggedInUserEmail;
1324
+ });
1325
+ return user[0]?.user_code;
1326
+ } catch (error) {
1327
+ console.error("getCurrentUserId error", error);
1328
+ }
1303
1329
  };
1304
1330
 
1305
1331
  // Get user name from session storage