l-min-components 1.7.1305 → 1.7.1306

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.7.1305",
3
+ "version": "1.7.1306",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -77,5 +77,6 @@
77
77
  "@types/react-dom": "^18.0.10",
78
78
  "@vitejs/plugin-react": "^3.1.0",
79
79
  "vite": "^4.1.0"
80
- }
80
+ },
81
+ "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
81
82
  }
@@ -131,10 +131,10 @@ const AppMainLayout = ({ children }) => {
131
131
  handleCurrentSubscription,
132
132
  getDefaultAccount,
133
133
  handleGetDefaultAccount,
134
- user,
135
- userDetails,
136
- } = useHeader({ default: true });
137
- // get current default account and store in cookie (from api);
134
+ } = useHeader();
135
+
136
+ // get current default account and store in cookie (from api)
137
+
138
138
  useEffect(() => {
139
139
  if (getDefaultAccount?.data) {
140
140
  const date = new Date();
@@ -298,17 +298,15 @@ const AppMainLayout = ({ children }) => {
298
298
  setIsTranslationsLoading,
299
299
  } = useTranslation(wordBank);
300
300
 
301
- const messageKit = useMessageKit(); // useMessageKit
301
+ const messageKit = useMessageKit({ affiliateAccount }); // useMessageKit
302
302
 
303
303
  return (
304
304
  <OutletContext.Provider
305
305
  value={{
306
306
  messageKit,
307
307
  affiliateAccount,
308
- userDetails,
309
308
  findAccountNames,
310
309
  accountName,
311
- user,
312
310
  setRightComponent,
313
311
  setRightLayout,
314
312
  generalData,
@@ -45,7 +45,7 @@ export const MainLayout = styled.div`
45
45
  width: 100%;
46
46
  padding: 84px 20px 20px 0;
47
47
  /* max-height: 100vh; */
48
- max-height: 100vh;
48
+ min-height: 100vh;
49
49
  `;
50
50
 
51
51
  export const LeftLayout = styled.div`
@@ -86,7 +86,7 @@ const InstructorRightBar = ({ planState }) => {
86
86
  marginBottom: "40px",
87
87
  }}
88
88
  onClick={() => {
89
- window.location.href = `${protocol}//${host}${port}/instructor/courses/create-course`;
89
+ window.location.href = `${protocol}//${host}${port}/enterprise/courses/create-course`;
90
90
  }}
91
91
  />
92
92
  </RecentAddedEnterprie>
@@ -1,17 +1,9 @@
1
1
  import useAxios from "axios-hooks";
2
2
  import { useEffect } from "react";
3
3
 
4
- const useHeader = (props = { default: false }) => {
4
+ const useHeader = () => {
5
5
  // get user details
6
- const [userDetails, getUserDetails] = useAxios(
7
- {
8
- method: "get",
9
- url: "/iam/v1/users/me/",
10
- },
11
- {
12
- manual: !props.default,
13
- }
14
- );
6
+ const [{ ...userDetails }, getUserDetails] = useAxios();
15
7
 
16
8
  const handleGetUserDetails = async () => {
17
9
  await getUserDetails({
@@ -377,11 +369,15 @@ const useHeader = (props = { default: false }) => {
377
369
  }
378
370
  };
379
371
 
372
+ //defaults
373
+ // get user info
374
+ useEffect(() => {
375
+ handleGetUserDetails();
376
+ }, []);
377
+
380
378
  return {
381
379
  handleGetUserDetails,
382
380
  userDetails,
383
- user: userDetails.data,
384
- getUserDetails,
385
381
  handleGetUserAccountsDetail,
386
382
  userAccountsDetail,
387
383
  handleGetDefaultAccount,
@@ -402,7 +398,7 @@ const useHeader = (props = { default: false }) => {
402
398
  handleGetAllAffiliate,
403
399
  handleSetDefaultAffiliate,
404
400
  setDefaultAffiliateData,
405
- plan: userPlanData?.data,
401
+
406
402
  userPlanData,
407
403
  handleGetUserPlan,
408
404
  getCurrentSubscriptionData,
@@ -56,7 +56,9 @@ const HeaderComponent = (props) => {
56
56
  // in general data find user info and replace where user details is being used
57
57
  const {
58
58
  handleGetUserAccountsDetail,
59
+ handleGetUserDetails,
59
60
  userAccountsDetail,
61
+ userDetails,
60
62
  // getDefaultAccount,
61
63
  // handleGetDefaultAccount,
62
64
  unreadNotificationData,
@@ -73,13 +75,8 @@ const HeaderComponent = (props) => {
73
75
  handleSetDefaultAccount,
74
76
  } = useHeader();
75
77
  const { pathname } = useLocation();
76
- const {
77
- setGeneralData,
78
- generalData,
79
- notificationMarkReadData,
80
- accountName,
81
- userDetails,
82
- } = useContext(OutletContext);
78
+ const { setGeneralData, generalData, notificationMarkReadData, accountName } =
79
+ useContext(OutletContext);
83
80
  const [accountType, setAccountType] = useState("");
84
81
  const currentAccountType = props?.selectedAccount?.type
85
82
  ? props?.selectedAccount?.type?.toLowerCase()
@@ -94,6 +91,7 @@ const HeaderComponent = (props) => {
94
91
  useEffect(() => {
95
92
  setIsOpen(false);
96
93
  handleGetUserAccountsDetail();
94
+ handleGetUserDetails();
97
95
  props?.handleGetDefaultAccount();
98
96
  }, []);
99
97
 
@@ -379,6 +377,7 @@ const HeaderComponent = (props) => {
379
377
  const data = JSON.parse(event?.data); //check for incoming message from socket
380
378
  if (data.event === "new.notification.result") {
381
379
  if (data.data) {
380
+ handleGetUnreadNotification(accountType);
382
381
  }
383
382
  }
384
383
  if (data.event === "message.new") {
@@ -423,7 +422,8 @@ const HeaderComponent = (props) => {
423
422
  onClick={() => {
424
423
  setLanguageDropdown();
425
424
  setIsOpen();
426
- }}>
425
+ }}
426
+ >
427
427
  <li>
428
428
  <a className={isHomePage() ? "active" : ""}>
429
429
  {getNavLinkIcon()} {props.findText(getNavLinkLabel())}
@@ -442,7 +442,8 @@ const HeaderComponent = (props) => {
442
442
  className={
443
443
  window.location.pathname.includes("settings") ? "active" : ""
444
444
  }
445
- style={{ cursor: "pointer" }}>
445
+ style={{ cursor: "pointer" }}
446
+ >
446
447
  <SettingIcon /> {props.findText("Settings")}
447
448
  </a>
448
449
  </li>
@@ -475,7 +476,8 @@ const HeaderComponent = (props) => {
475
476
  ? "disabled"
476
477
  : ""
477
478
  }
478
- style={{ cursor: isPendingDelete ? "not-allowed" : "pointer" }}>
479
+ style={{ cursor: isPendingDelete ? "not-allowed" : "pointer" }}
480
+ >
479
481
  {unreadNotificationData?.data?.count > 0 ? (
480
482
  <NotificationIcon />
481
483
  ) : (
@@ -509,7 +511,8 @@ const HeaderComponent = (props) => {
509
511
  onClick={() => {
510
512
  setLanguageDropdown();
511
513
  setIsOpen();
512
- }}>
514
+ }}
515
+ >
513
516
  {/* {(!isDeveloper || !window.location.hostname.includes("coming")) && ( // when developer and on staging, don't show
514
517
  <SearchInputGroup>
515
518
  <SearchIcon />
@@ -538,7 +541,8 @@ const HeaderComponent = (props) => {
538
541
  onClick={() => {
539
542
  setLanguageDropdown(!languageDropdown);
540
543
  setIsOpen();
541
- }}>
544
+ }}
545
+ >
542
546
  <img src={selectedLanguageData[value] || usFlag} alt="" />
543
547
  <ArrowDownIcon />
544
548
  </div>
@@ -560,7 +564,8 @@ const HeaderComponent = (props) => {
560
564
  setIsOpen(!isOpen);
561
565
  setLanguageDropdown();
562
566
  }}
563
- ref={secondContainerRef}>
567
+ ref={secondContainerRef}
568
+ >
564
569
  <div className="user-img-container">
565
570
  <img
566
571
  src={props?.selectedAccount?.profile_photo?.url || avatar}
@@ -56,4 +56,3 @@ export { default as DeveloperBanner } from "./banner/developerBanner";
56
56
  export { default as VideoPlayer } from "./video-player";
57
57
  export { default as useAudioPlayer } from "./useAudioPlayer";
58
58
  export { default as AudioWaveComponent } from "./useAudioPlayer/audioWave";
59
- export { default as InputEmoji } from "./InputEmoji";
@@ -98,6 +98,7 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
98
98
  };
99
99
 
100
100
  const { accountName, planState } = useContext(OutletContext);
101
+
101
102
  // handle if account does not have subscription but is an affiliate
102
103
  const prioritizedAffiliateId = useMemo(() => {
103
104
  let prioritizedAffiliateId = null;
@@ -106,13 +107,11 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
106
107
  // Priority 1: Use cookie value if it exists
107
108
  prioritizedAffiliateId = cookieValue;
108
109
  } else if (
109
- planState !== "ACTIVE" &&
110
- planState !== "GRACE PERIOD" && // Check for NO subscription
110
+ !planState && // Check for NO subscription
111
111
  getAllAffiliateData?.data?.results?.length > 0 // Check if the list exists and is not empty
112
112
  ) {
113
113
  // Priority 2: If no cookie, no subscription, and list exists...
114
114
  // Assign the ID of the *first* affiliate directly from the results array
115
- setCookie(getAllAffiliateData.data.results[0]?.id);
116
115
  prioritizedAffiliateId = getAllAffiliateData.data.results[0]?.id; // Optional chaining on 'id'
117
116
  }
118
117
  return prioritizedAffiliateId;
@@ -189,30 +188,28 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
189
188
  <div className="left">
190
189
  {switchValue !== "affiliates" && <p>{accountName}</p>}
191
190
  {switchValue === "affiliates" && (
192
- <OutsideAlerter handleClick={() => setDropdown(false)}>
193
- <AffiliatesDropDown>
194
- {!selectedValue ? (
195
- <div
196
- className="placeholder"
197
- onClick={() => setDropdown(!dropdown)}
198
- >
199
- <p>Select affiliate</p>
200
- <ArrowDown />
201
- </div>
202
- ) : (
203
- <div
204
- className="selected"
205
- onClick={() => setDropdown(!dropdown)}
206
- >
207
- <div>
208
- <img src={selectedValue?.image} alt="" />
209
- <p>{selectedValue?.name}</p>
210
- </div>
211
- <ArrowDown />
191
+ <AffiliatesDropDown>
192
+ {!selectedValue ? (
193
+ <div
194
+ className="placeholder"
195
+ onClick={() => setDropdown(!dropdown)}>
196
+ <p>Select affiliate</p>
197
+ <ArrowDown />
198
+ </div>
199
+ ) : (
200
+ <div
201
+ className="selected"
202
+ onClick={() => setDropdown(!dropdown)}>
203
+ <div>
204
+ <img src={selectedValue?.image} alt="" />
205
+ <p>{selectedValue?.name}</p>
212
206
  </div>
213
- )}
207
+ <ArrowDown />
208
+ </div>
209
+ )}
214
210
 
215
- {dropdown && switchValue === "affiliates" ? (
211
+ {dropdown && switchValue === "affiliates" ? (
212
+ <OutsideAlerter handleClick={() => setDropdown(false)}>
216
213
  <AffiliatesDropDownWrapper>
217
214
  <div className="search_wrapper">
218
215
  <Search
@@ -226,8 +223,7 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
226
223
  key={item?.id}
227
224
  onClick={() => {
228
225
  handleSelection(item);
229
- }}
230
- >
226
+ }}>
231
227
  <div className="left">
232
228
  <img src={item?.image} alt="" />
233
229
  <p>{item?.name}</p>
@@ -237,26 +233,24 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
237
233
  ))}
238
234
  </ul>
239
235
  </AffiliatesDropDownWrapper>
240
- ) : null}
241
- </AffiliatesDropDown>
242
- </OutsideAlerter>
236
+ </OutsideAlerter>
237
+ ) : null}
238
+ </AffiliatesDropDown>
243
239
  )}
244
240
  </div>
245
241
  {
246
242
  <div className="btn__wrapper">
247
- {(planState === "ACTIVE" || planState === "GRACE PERIOD") && (
243
+ {!!!prioritizedAffiliateId && (
248
244
  <button
249
245
  className={switchValue !== "affiliates" ? "active" : ""}
250
- onClick={() => handleSwitch(1)}
251
- >
246
+ onClick={() => handleSwitch(1)}>
252
247
  <span>My Account</span>
253
248
  <span className="circle"></span>
254
249
  </button>
255
250
  )}
256
251
  <button
257
252
  className={switchValue === "affiliates" ? "active" : ""}
258
- onClick={() => handleSwitch(2)}
259
- >
253
+ onClick={() => handleSwitch(2)}>
260
254
  <span>Affiliates</span>
261
255
  <span className="circle"></span>
262
256
  </button>
@@ -360,7 +354,6 @@ const AffiliatesDropDown = styled.div`
360
354
  img {
361
355
  width: 36px;
362
356
  height: 36px;
363
- border-radius: 50%;
364
357
  }
365
358
  p {
366
359
  color: #00c2c2;
@@ -414,8 +407,6 @@ const AffiliatesDropDownWrapper = styled.div`
414
407
  img {
415
408
  width: 20px;
416
409
  height: 20px;
417
- border-radius: 50%;
418
- object-fit: cover;
419
410
  }
420
411
  }
421
412
  span {
@@ -288,7 +288,7 @@ const SideMenu = ({
288
288
  }
289
289
  }}
290
290
  key={index}
291
- className={cx({ active, [route.text]: true, disabled: route.disabled })}
291
+ className={cx(`${route.text} ${active && "active"}`)}
292
292
  minimal={isOpen}>
293
293
  <IconContainer active={active}>
294
294
  {active ? iconActive : icon}
@@ -348,7 +348,6 @@ SideMenu.propTypes = {
348
348
  icon: PropTypes.element.isRequired,
349
349
  text: PropTypes.string.isRequired,
350
350
  notifications: PropTypes.number,
351
- disabled: PropTypes.bool,
352
351
  })
353
352
  ).isRequired,
354
353
  })
@@ -120,10 +120,6 @@ export const NavigationItemContainer = styled.p`
120
120
  background: #949999;
121
121
  }
122
122
  }
123
- &.disabled {
124
- pointer-events: none;
125
- opacity: 0.5;
126
- }
127
123
  `;
128
124
 
129
125
  export const IconContainer = styled.div`
@@ -12,12 +12,14 @@ import Loader from "../../loader";
12
12
  import avatar from "../../../assets/images/avatar.png";
13
13
  import { OutletContext } from "../../AppMainLayout";
14
14
 
15
- const UserCard = ({ isOpen, findText }) => {
16
- const { handleSetDefaultAccount } = useHeader();
15
+ const UserCard = ({ user, isOpen, findText }) => {
16
+ const { handleGetUserDetails, userDetails, handleSetDefaultAccount } =
17
+ useHeader();
17
18
  const [organizationName, setOrganizationName] = useState();
18
- const { generalData, accountName, userDetails } = useContext(OutletContext);
19
+ const { generalData, accountName } = useContext(OutletContext);
19
20
 
20
21
  useEffect(() => {
22
+ handleGetUserDetails();
21
23
  if (generalData?.selectedAccount) {
22
24
  const date = new Date();
23
25
  date.setDate(date.getDate() + 28);
@@ -69,9 +71,9 @@ const UserCard = ({ isOpen, findText }) => {
69
71
  src={generalData?.selectedAccount?.profile_photo?.url || avatar}
70
72
  isOpen={isOpen}
71
73
  onClick={() => {
72
- // if (window.location.pathname.includes("personal")) {
73
- // window.location.href = `${window.location.protocol}//${window.location.hostname}/personal/profile`;
74
- // }
74
+ if (window.location.pathname.includes("personal")) {
75
+ window.location.href = `${window.location.protocol}//${window.location.hostname}/personal/profile`;
76
+ }
75
77
  if (window.location.pathname.includes("enterprise")) {
76
78
  window.location.href = `${window.location.protocol}//${window.location.hostname}/enterprise/profile`;
77
79
  }
@@ -179,7 +179,6 @@ export const sideMenuOptions = [
179
179
  icon: <AwardIcon />,
180
180
  iconActive: <AwardIconActive />,
181
181
  text: "Manage report",
182
- // disabled: true,
183
182
  },
184
183
  {
185
184
  path: "/instructor/courses",
@@ -229,14 +228,12 @@ export const sideMenuOptions = [
229
228
  icon: <DashboardIcon />,
230
229
  iconActive: <DashboardIconActive />,
231
230
  text: "Dashboard",
232
- disabled: true,
233
231
  },
234
232
  {
235
233
  path: "/personal/library",
236
234
  icon: <LibraryIcon />,
237
235
  iconActive: <LibraryIconActive />,
238
236
  text: "Library",
239
- disabled: true,
240
237
  },
241
238
  {
242
239
  path: "/personal/courses",
@@ -262,7 +259,6 @@ export const sideMenuOptions = [
262
259
  icon: <AddOnIcon />,
263
260
  iconActive: <AddOnIconActive />,
264
261
  text: "Add on",
265
- disabled: true,
266
262
  },
267
263
  ],
268
264
  },
@@ -1,7 +1,6 @@
1
1
  import useAxios from "axios-hooks";
2
2
  import { useCallback, useEffect, useMemo, useState, useRef } from "react";
3
3
  import sound from "./new-notification-7-210334.mp3";
4
- import { cookieGrabber, useCookiePolling } from "../utils/cookiePolling";
5
4
 
6
5
  /**
7
6
  * Represents the details of the last message in a chat room overview.
@@ -237,28 +236,38 @@ import { cookieGrabber, useCookiePolling } from "../utils/cookiePolling";
237
236
  * @property {any | null} media - The media data (e.g., File object, FormData details). Needs proper handling before API call.
238
237
  */
239
238
 
240
- const useMessageKit = () => {
241
- const selectedAccountId = useCookiePolling("defaultAccountID");
242
- const defaultAccountType = useCookiePolling("defaultAccountType");
243
- const selectedAccount = {
244
- id: selectedAccountId,
245
- type: defaultAccountType,
239
+ const useMessageKit = ({ affiliateAccount: AffiliateAccount }) => {
240
+ const cookieGrabber = (key = "") => {
241
+ const cookies = document.cookie;
242
+ const string = cookies.split(";").find((cookie) => {
243
+ cookie = cookie.trim();
244
+ if (cookie.startsWith(key.trim() + "=")) return true;
245
+ });
246
+
247
+ if (!string) return "";
248
+ return string.split("=")[1].trim();
246
249
  };
247
- const token = useCookiePolling("access");
250
+ const selectedAccount = useMemo(
251
+ () => ({
252
+ id: cookieGrabber("defaultAccountID"),
253
+ type: cookieGrabber("defaultAccountType"),
254
+ }),
255
+ []
256
+ );
248
257
  const buildSocketUrl = useCallback(() => {
249
258
  const baseUrl =
250
259
  window.location.hostname.includes("staging") ||
251
260
  window.location.hostname.includes("localhost")
252
261
  ? "https://dev-117782726-api.learngual.com"
253
262
  : "https://api.learngual.com";
254
-
263
+ const token = cookieGrabber("access");
255
264
  return (
256
265
  baseUrl.replace("http", "ws") +
257
266
  `/notify/v1/ws/connect/?authorization=${token}&_account=${selectedAccount.id}`
258
267
  );
259
268
  }, []);
260
269
 
261
- const affiliateAccount = useCookiePolling("affiliateAccount", 1000);
270
+ const affiliateAccount = cookieGrabber("affiliateAccount");
262
271
  // console.log(affiliateAccount, affiliatesActive, "affiliate");
263
272
  // get account type
264
273
  const [, request] = useAxios(
@@ -361,13 +370,14 @@ const useMessageKit = () => {
361
370
  });
362
371
  }
363
372
 
364
- if (selectedAccount.type.toLowerCase() === "instructor") {
373
+ if (
374
+ selectedAccount.type.toLowerCase() === "instructor" &&
375
+ affiliateAccount
376
+ // &&
377
+ // affiliatesActive
378
+ ) {
365
379
  response = await request({
366
- url:
367
- nextPage ||
368
- `/notify/v1/instructor${
369
- affiliateAccount ? "/".concat(affiliateAccount) : ""
370
- }/rooms/`,
380
+ url: nextPage || `/notify/v1/instructor/${affiliateAccount}/rooms/`,
371
381
  params: {
372
382
  limit,
373
383
  _account: selectedAccount.id,
@@ -428,13 +438,14 @@ const useMessageKit = () => {
428
438
  });
429
439
  }
430
440
 
431
- if (String(selectedAccount.type).toLowerCase() === "instructor") {
441
+ if (
442
+ String(selectedAccount.type).toLowerCase() === "instructor" &&
443
+ affiliateAccount
444
+ // &&
445
+ // affiliatesActive
446
+ ) {
432
447
  response = await request({
433
- url:
434
- nextPage ||
435
- `/notify/v1/instructor${
436
- affiliateAccount ? "/".concat(affiliateAccount) : ""
437
- }/chats/`,
448
+ url: nextPage || `/notify/v1/instructor/${affiliateAccount}/chats/`,
438
449
  params: {
439
450
  _account: selectedAccount.id,
440
451
  room_id: roomId,
@@ -574,11 +585,12 @@ const useMessageKit = () => {
574
585
  url: `/notify/v1/enterprise/chats/${latestMessageId}/read_message/`,
575
586
  });
576
587
  }
577
- if (String(selectedAccount.type).toLowerCase() === "instructor") {
588
+ if (
589
+ String(selectedAccount.type).toLowerCase() === "instructor" &&
590
+ affiliateAccount
591
+ ) {
578
592
  await request({
579
- url: `/notify/v1/instructor${
580
- affiliateAccount ? "/".concat(affiliateAccount) : ""
581
- }/chats/${latestMessageId}/read_message/`,
593
+ url: `/notify/v1/instructor/${affiliateAccount}/chats/${latestMessageId}/read_message/`,
582
594
  });
583
595
  }
584
596
  if (String(selectedAccount.type).toLowerCase() === "personal") {
@@ -873,12 +885,11 @@ const useMessageKit = () => {
873
885
  method: "Post",
874
886
  });
875
887
  } else if (
876
- String(selectedAccount.type).toLowerCase() === "instructor"
888
+ String(selectedAccount.type).toLowerCase() === "instructor" &&
889
+ affiliateAccount
877
890
  ) {
878
891
  response = await request({
879
- url: `/notify/v1/instructor${
880
- affiliateAccount ? "/".concat(affiliateAccount) : ""
881
- }/chats/`,
892
+ url: `/notify/v1/instructor/${affiliateAccount}/chats/`,
882
893
  params: requestParams,
883
894
  data: requestData,
884
895
  method: "Post",
@@ -1284,11 +1295,14 @@ const useMessageKit = () => {
1284
1295
  method: "patch",
1285
1296
  });
1286
1297
  }
1287
- if (selectedAccount.type.toLowerCase() === "instructor") {
1298
+ if (
1299
+ selectedAccount.type.toLowerCase() === "instructor" &&
1300
+ affiliateAccount
1301
+ // &&
1302
+ // affiliatesActive
1303
+ ) {
1288
1304
  response = await request({
1289
- url: `/notify/v1/instructor${
1290
- affiliateAccount ? "/".concat(affiliateAccount) : ""
1291
- }/rooms/${roomId}/change_pin_status/`,
1305
+ url: `/notify/v1/instructor/${affiliateAccount}/rooms/${roomId}/change_pin_status/`,
1292
1306
  method: "patch",
1293
1307
  });
1294
1308
  } // incomplete
@@ -1361,11 +1375,14 @@ const useMessageKit = () => {
1361
1375
  method: "delete",
1362
1376
  });
1363
1377
  }
1364
- if (selectedAccount.type.toLowerCase() === "instructor") {
1378
+ if (
1379
+ selectedAccount.type.toLowerCase() === "instructor" &&
1380
+ affiliateAccount
1381
+ // &&
1382
+ // affiliatesActive
1383
+ ) {
1365
1384
  await request({
1366
- url: `/notify/v1/instructor${
1367
- affiliateAccount ? "/".concat(affiliateAccount) : ""
1368
- }/rooms/${roomId}/`,
1385
+ url: `/notify/v1/instructor/${affiliateAccount}/rooms/${roomId}/`,
1369
1386
  method: "delete",
1370
1387
  });
1371
1388
  } // incomplete
@@ -1402,11 +1419,12 @@ const useMessageKit = () => {
1402
1419
  data,
1403
1420
  });
1404
1421
  }
1405
- if (selectedAccount.type.toLowerCase() === "instructor") {
1422
+ if (
1423
+ selectedAccount.type.toLowerCase() === "instructor" &&
1424
+ affiliateAccount
1425
+ ) {
1406
1426
  response = await request({
1407
- url: `/notify/v1/instructor${
1408
- affiliateAccount ? "/".concat(affiliateAccount) : ""
1409
- }/chats/reports/`,
1427
+ url: `/notify/v1/instructor/${affiliateAccount}/chats/reports/`,
1410
1428
  method: "post",
1411
1429
  data,
1412
1430
  });
@@ -1423,7 +1441,6 @@ const useMessageKit = () => {
1423
1441
  // Initial data fetch effect
1424
1442
  useEffect(() => {
1425
1443
  (async () => {
1426
- if (!selectedAccountId || !defaultAccountType || !token) return;
1427
1444
  await getMessageRoomsByCourses();
1428
1445
  // reportChat({
1429
1446
  // reasons: ["Verbal harassment"],
@@ -1445,7 +1462,7 @@ const useMessageKit = () => {
1445
1462
  // accountId: "24dbaeede1",
1446
1463
  // });
1447
1464
  })();
1448
- }, [affiliateAccount, token, defaultAccountType, selectedAccountId]); // Rerun when selectedAccount changes
1465
+ }, [AffiliateAccount]); // Rerun when selectedAccount changes
1449
1466
  // console.log(
1450
1467
  // getMessagesForRoom("5be9b48281ac4c2885d3b719654ed59d", "878", "24dbaeede1"),
1451
1468
  // "hold versions"