l-min-components 1.7.1388 → 1.7.1390
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 +1 -1
- package/src/components/AppMainLayout/index.jsx +66 -19
- package/src/components/header/getCookies.js +46 -33
- package/src/components/header/getHeaderDetails.js +7 -6
- package/src/components/header/index.jsx +10 -42
- package/src/components/instructorAccountSwitcher/index.jsx +17 -72
package/package.json
CHANGED
|
@@ -45,6 +45,8 @@ import PersonalRightBar from "../fileRightBar/instructorRightBar2/personalRightB
|
|
|
45
45
|
import TestModal from "../fileRightBar/instructorRightBar2/testModal";
|
|
46
46
|
import BlankState from "../dashboardState/blankState";
|
|
47
47
|
import PendingDeleteState from "../dashboardState/pendingDeleteState";
|
|
48
|
+
import { getCookie, setCookie } from "../header/getCookies";
|
|
49
|
+
import deleteCookies from "../instructorAccountSwitcher/deleteCookies";
|
|
48
50
|
|
|
49
51
|
const AppMainLayout = ({ children }) => {
|
|
50
52
|
const [isOpen, setIsOpen] = useState(true);
|
|
@@ -73,6 +75,7 @@ const AppMainLayout = ({ children }) => {
|
|
|
73
75
|
const [newLoadingForPostDefaultAccount, setNewLoadingForPostDefaultAccount] =
|
|
74
76
|
useState(true);
|
|
75
77
|
const [selectedAccount, setSelectedAccount] = useState();
|
|
78
|
+
const [affilitateSearch, setAffilitateSearch] = useState("");
|
|
76
79
|
// for mobile view
|
|
77
80
|
useEffect(() => {
|
|
78
81
|
const handleResize = () => setDeviceWidth(window.innerWidth);
|
|
@@ -267,9 +270,7 @@ const AppMainLayout = ({ children }) => {
|
|
|
267
270
|
|
|
268
271
|
// const currentPlan = userPlanData?.data?.current_plan;
|
|
269
272
|
const planState = userPlanData?.data?.state;
|
|
270
|
-
|
|
271
|
-
console.log(planState, "PLAN");
|
|
272
|
-
console.log("====================================");
|
|
273
|
+
|
|
273
274
|
const wordBank = [
|
|
274
275
|
"Sign out",
|
|
275
276
|
"Learning",
|
|
@@ -320,8 +321,6 @@ const AppMainLayout = ({ children }) => {
|
|
|
320
321
|
|
|
321
322
|
const messageKit = useMessageKit(); // useMessageKit
|
|
322
323
|
|
|
323
|
-
const [isAffiliateLoading, setIsAffiliateLoading] = useState(true);
|
|
324
|
-
|
|
325
324
|
const handleGetStorageSummary = async () => {
|
|
326
325
|
const accountType = generalData?.selectedAccount?.type?.toLowerCase();
|
|
327
326
|
if (accountType === "enterprise" || accountType === "instructor") {
|
|
@@ -334,6 +333,47 @@ const AppMainLayout = ({ children }) => {
|
|
|
334
333
|
handleGetStorageSummary();
|
|
335
334
|
}, [generalData?.selectedAccount]);
|
|
336
335
|
|
|
336
|
+
const {
|
|
337
|
+
handleGetAllAffiliate,
|
|
338
|
+
getAllAffiliateData,
|
|
339
|
+
getDefaultAffiliateData,
|
|
340
|
+
handleGetDefaultAffiliate,
|
|
341
|
+
} = useHeader();
|
|
342
|
+
|
|
343
|
+
useEffect(() => {
|
|
344
|
+
if (activeAccountType === "instructor") {
|
|
345
|
+
handleGetDefaultAffiliate();
|
|
346
|
+
}
|
|
347
|
+
}, [activeAccountType]);
|
|
348
|
+
|
|
349
|
+
useEffect(() => {
|
|
350
|
+
if (activeAccountType === "instructor") {
|
|
351
|
+
handleGetAllAffiliate({ search: affilitateSearch });
|
|
352
|
+
}
|
|
353
|
+
}, [activeAccountType, affilitateSearch]);
|
|
354
|
+
|
|
355
|
+
// handling instructor affiliate cookie
|
|
356
|
+
const hasAxtiveAffiliateId = getDefaultAffiliateData?.data?.id;
|
|
357
|
+
|
|
358
|
+
const affiliateList = getAllAffiliateData?.data?.results?.map?.((account) => {
|
|
359
|
+
const image = account?.profile_photo?.url;
|
|
360
|
+
return {
|
|
361
|
+
name: account?.metadata?.organization_name ?? "...",
|
|
362
|
+
image,
|
|
363
|
+
id: account?.id,
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
useEffect(() => {
|
|
368
|
+
if (hasAxtiveAffiliateId && activeAccountType === "instructor") {
|
|
369
|
+
setCookie("affiliateAccount", hasAxtiveAffiliateId);
|
|
370
|
+
setAffiliateAccount({ id: hasAxtiveAffiliateId });
|
|
371
|
+
} else {
|
|
372
|
+
deleteCookies("affiliateAccount");
|
|
373
|
+
setAffiliateAccount(null);
|
|
374
|
+
}
|
|
375
|
+
}, [hasAxtiveAffiliateId, activeAccountType]);
|
|
376
|
+
|
|
337
377
|
const accountIsPendingDeletion = generalData?.selectedAccount?.pending_delete;
|
|
338
378
|
|
|
339
379
|
return (
|
|
@@ -425,13 +465,22 @@ const AppMainLayout = ({ children }) => {
|
|
|
425
465
|
</LeftLayout>
|
|
426
466
|
<CenterLayout isOpen={isOpen} style={centerLayoutStyle}>
|
|
427
467
|
{activeAccountType === "instructor" &&
|
|
428
|
-
!accountIsPendingDeletion &&
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
468
|
+
!accountIsPendingDeletion &&
|
|
469
|
+
affiliateList?.length > 0 && (
|
|
470
|
+
<>
|
|
471
|
+
{(getDefaultAffiliateData?.loading ||
|
|
472
|
+
getAllAffiliateData?.loading) && (
|
|
473
|
+
<FullPageLoader fixed hasBackground />
|
|
474
|
+
)}
|
|
475
|
+
<InstructorAccountSwitcher
|
|
476
|
+
// setAccountType={setAffiliatesActive}
|
|
477
|
+
affiliateList={affiliateList}
|
|
478
|
+
generalData={generalData}
|
|
479
|
+
onChange={(v) => setAffiliateAccount(v)}
|
|
480
|
+
setSearch={setAffilitateSearch}
|
|
481
|
+
defaultAffiliate={getDefaultAffiliateData?.data}
|
|
482
|
+
/>
|
|
483
|
+
</>
|
|
435
484
|
)}
|
|
436
485
|
{!generalData?.selectedAccount ? (
|
|
437
486
|
<BlankState />
|
|
@@ -444,7 +493,7 @@ const AppMainLayout = ({ children }) => {
|
|
|
444
493
|
/>
|
|
445
494
|
) : (
|
|
446
495
|
<>
|
|
447
|
-
{
|
|
496
|
+
{activeAccountType === "enterprise" &&
|
|
448
497
|
(planState === "GRACE PERIOD" ||
|
|
449
498
|
planState === "EXPIRED" ||
|
|
450
499
|
(!userPlanData?.loading && !planState)) &&
|
|
@@ -457,11 +506,9 @@ const AppMainLayout = ({ children }) => {
|
|
|
457
506
|
gracePeriod={gracePeriod}
|
|
458
507
|
stateType={planState === "GRACE PERIOD" ? 1 : 2}
|
|
459
508
|
/>
|
|
460
|
-
) :
|
|
509
|
+
) : activeAccountType === "instructor" &&
|
|
461
510
|
!planState &&
|
|
462
|
-
!
|
|
463
|
-
!isAffiliateLoading &&
|
|
464
|
-
!affiliateAccount?.id &&
|
|
511
|
+
!hasAxtiveAffiliateId &&
|
|
465
512
|
!window.location.pathname.includes("notif") ? (
|
|
466
513
|
<div className="instructor_expired">
|
|
467
514
|
<h1>Dashboard</h1>
|
|
@@ -514,10 +561,10 @@ const AppMainLayout = ({ children }) => {
|
|
|
514
561
|
// )}
|
|
515
562
|
|
|
516
563
|
// </>
|
|
517
|
-
|
|
564
|
+
hasAxtiveAffiliateId && (
|
|
518
565
|
<AffiliateRightBar
|
|
519
566
|
planState={planState}
|
|
520
|
-
affiliateAccount={
|
|
567
|
+
affiliateAccount={hasAxtiveAffiliateId}
|
|
521
568
|
isPendingDelete={accountIsPendingDeletion}
|
|
522
569
|
/>
|
|
523
570
|
)
|
|
@@ -1,38 +1,51 @@
|
|
|
1
1
|
export function getCookie(name) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
// Split cookie string and get all individual name=value pairs in an array
|
|
3
|
+
var cookieArr = document.cookie.split(";");
|
|
4
|
+
|
|
5
|
+
// Loop through the array elements
|
|
6
|
+
for (var i = 0; i < cookieArr.length; i++) {
|
|
7
|
+
var cookiePair = cookieArr[i].split("=");
|
|
8
|
+
|
|
9
|
+
/* Removing whitespace at the beginning of the cookie name
|
|
10
10
|
and compare it with the given string */
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
11
|
+
if (name == cookiePair[0].trim()) {
|
|
12
|
+
// Decode the cookie value and return
|
|
13
|
+
return decodeURIComponent(cookiePair[1]);
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
// Return null if not found
|
|
18
|
-
return null;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
// Return null if not found
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const getCookieAffiliate = () => {
|
|
22
|
+
const cookies = document.cookie;
|
|
23
|
+
const cookieArray = cookies.split(";");
|
|
24
|
+
|
|
25
|
+
let affiliateAccount = null;
|
|
26
|
+
|
|
27
|
+
cookieArray?.forEach((cookieValue) => {
|
|
28
|
+
const cookie = cookieValue?.trim();
|
|
29
|
+
if (cookie.startsWith("affiliateAccount=")) {
|
|
30
|
+
affiliateAccount = cookie.substring(
|
|
31
|
+
"affiliateAccount=".length,
|
|
32
|
+
cookie.length
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return affiliateAccount;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const setCookie = (name, data) => {
|
|
41
|
+
const date = new Date();
|
|
42
|
+
date.setDate(date.getDate() + 20);
|
|
43
|
+
const expires = "; expires=" + date.toUTCString();
|
|
44
|
+
const path = "; path=/";
|
|
45
|
+
const domain = window.location.href.includes("localhost")
|
|
46
|
+
? "localhost"
|
|
47
|
+
: window.location.hostname?.includes("ca")
|
|
48
|
+
? ".learngual.ca"
|
|
49
|
+
: ".learngual.com";
|
|
50
|
+
document.cookie = `${name}=` + data + expires + path + "; domain=" + domain;
|
|
51
|
+
};
|
|
@@ -157,13 +157,12 @@ const useHeader = (props = { default: false }) => {
|
|
|
157
157
|
}
|
|
158
158
|
);
|
|
159
159
|
|
|
160
|
-
const handleGetUnreadNotification = async (
|
|
161
|
-
account_type = "",
|
|
162
|
-
read = false
|
|
163
|
-
) => {
|
|
160
|
+
const handleGetUnreadNotification = async (account_type, read = false) => {
|
|
164
161
|
try {
|
|
165
162
|
await getUnreadNotification({
|
|
166
|
-
url: `/notify/v1/${
|
|
163
|
+
url: `/notify/v1/${
|
|
164
|
+
account_type?.toLowerCase() === "personal" ? "" : account_type + "/"
|
|
165
|
+
}notifications/`,
|
|
167
166
|
params: {
|
|
168
167
|
read: read,
|
|
169
168
|
},
|
|
@@ -210,7 +209,9 @@ const useHeader = (props = { default: false }) => {
|
|
|
210
209
|
const handleGeneralNotificationCount = async (account_type = "") => {
|
|
211
210
|
try {
|
|
212
211
|
await generalNotificationCount({
|
|
213
|
-
url: `/notify/v1/${
|
|
212
|
+
url: `/notify/v1/${
|
|
213
|
+
account_type?.toLowerCase() === "personal" ? "" : account_type + "/"
|
|
214
|
+
}notifications/general_notification_count/`,
|
|
214
215
|
});
|
|
215
216
|
} catch (err) {
|
|
216
217
|
//console.log(err);
|
|
@@ -262,13 +262,6 @@ const HeaderComponent = (props) => {
|
|
|
262
262
|
};
|
|
263
263
|
}, [setIsOpen]);
|
|
264
264
|
|
|
265
|
-
// get current default account and store in cookie from path
|
|
266
|
-
useEffect(() => {
|
|
267
|
-
if (pathname?.includes("personal")) {
|
|
268
|
-
// document.cookie = "activeAccount" + path;
|
|
269
|
-
}
|
|
270
|
-
}, []);
|
|
271
|
-
|
|
272
265
|
// Determine home page for active style purpose
|
|
273
266
|
const isHomePage = () =>
|
|
274
267
|
window.location.pathname === "/" ||
|
|
@@ -302,9 +295,13 @@ const HeaderComponent = (props) => {
|
|
|
302
295
|
};
|
|
303
296
|
|
|
304
297
|
// websocket for notifications initialization
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
298
|
+
const socketUrl = `${
|
|
299
|
+
window.location.hostname.includes("localhost") ||
|
|
300
|
+
window.location.hostname.includes("staging")
|
|
301
|
+
? "dev-117782726-api"
|
|
302
|
+
: "api"
|
|
303
|
+
}.learngual.com/notify/v1/ws/connect/`;
|
|
304
|
+
|
|
308
305
|
const token = getCookie("access");
|
|
309
306
|
const defaultAcctId = getCookie("defaultAccountID");
|
|
310
307
|
const account_id = generalData?.defaultAccount?.id || defaultAcctId;
|
|
@@ -315,24 +312,12 @@ const HeaderComponent = (props) => {
|
|
|
315
312
|
`wss://${socketUrl}?_account=${account_id}&authorization=${token}`
|
|
316
313
|
);
|
|
317
314
|
|
|
318
|
-
websocket.onopen = () => {
|
|
319
|
-
//check if socket is connected
|
|
320
|
-
// console.log("websocket connection established");
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
websocket.onmessage = (event) => {
|
|
324
|
-
const data = JSON.parse(event.data);
|
|
325
|
-
//console.log("websocket data", data);
|
|
326
|
-
};
|
|
327
|
-
|
|
328
315
|
const handler = (event) => {
|
|
329
316
|
if (event?.data) {
|
|
330
317
|
const data = JSON.parse(event?.data); //check for incoming message from socket
|
|
331
318
|
if (data.event === "new.notification.result") {
|
|
332
319
|
if (data.data) {
|
|
333
320
|
props.setNewNotifications((prev) => [...prev, data.data]);
|
|
334
|
-
|
|
335
|
-
//console.log(data);
|
|
336
321
|
if (accountType) {
|
|
337
322
|
handleGetUnreadNotification(accountType);
|
|
338
323
|
handleGeneralNotificationCount();
|
|
@@ -346,7 +331,6 @@ const HeaderComponent = (props) => {
|
|
|
346
331
|
|
|
347
332
|
return () => {
|
|
348
333
|
websocket.removeEventListener("message", handler);
|
|
349
|
-
//console.log("websocket closed");
|
|
350
334
|
};
|
|
351
335
|
}, []);
|
|
352
336
|
|
|
@@ -356,28 +340,19 @@ const HeaderComponent = (props) => {
|
|
|
356
340
|
`wss://${socketUrl}?_account=${account_id}&authorization=${token}&room_id=${account_id}`
|
|
357
341
|
);
|
|
358
342
|
|
|
359
|
-
websocket2.onopen = () => {
|
|
360
|
-
//check if socket is connected
|
|
361
|
-
// console.log("room websocket connection established");
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
websocket2.onmessage = (event) => {
|
|
365
|
-
const data = JSON.parse(event.data);
|
|
366
|
-
//console.log("websocket data for room", data);
|
|
367
|
-
};
|
|
368
|
-
|
|
369
343
|
const handler = (event) => {
|
|
370
344
|
if (event?.data) {
|
|
371
345
|
const data = JSON.parse(event?.data); //check for incoming message from socket
|
|
372
346
|
if (data.event === "new.notification.result") {
|
|
373
347
|
if (data.data) {
|
|
374
|
-
|
|
348
|
+
if (accountType) {
|
|
349
|
+
handleGetUnreadNotification(accountType);
|
|
350
|
+
}
|
|
375
351
|
}
|
|
376
352
|
}
|
|
377
353
|
if (data.event === "message.new") {
|
|
378
354
|
}
|
|
379
355
|
if (data.event === "new.room.result") {
|
|
380
|
-
//console.log(data);
|
|
381
356
|
if (data.status) {
|
|
382
357
|
if (accountType) {
|
|
383
358
|
handleGetUnreadNotification(accountType);
|
|
@@ -392,7 +367,6 @@ const HeaderComponent = (props) => {
|
|
|
392
367
|
|
|
393
368
|
return () => {
|
|
394
369
|
websocket2.removeEventListener("message", handler);
|
|
395
|
-
//console.log("room websocket closed");
|
|
396
370
|
};
|
|
397
371
|
}, []);
|
|
398
372
|
|
|
@@ -443,12 +417,6 @@ const HeaderComponent = (props) => {
|
|
|
443
417
|
</li>
|
|
444
418
|
<li>
|
|
445
419
|
<a
|
|
446
|
-
// href={`https://559staging.learngual.com/${
|
|
447
|
-
// selectedAccount?.type
|
|
448
|
-
// ? selectedAccount?.type?.toLowerCase()
|
|
449
|
-
// : userAccountsDetail?.data?.[0]?.type?.toLowerCase()
|
|
450
|
-
// }/notifications/`}
|
|
451
|
-
|
|
452
420
|
onClick={(e) => {
|
|
453
421
|
if (isPendingDelete) {
|
|
454
422
|
e.preventDefault();
|
|
@@ -14,36 +14,14 @@ import { OutletContext } from "..";
|
|
|
14
14
|
const InstructorAccountSwitcher = ({
|
|
15
15
|
generalData,
|
|
16
16
|
onChange,
|
|
17
|
-
|
|
17
|
+
affiliateList,
|
|
18
|
+
setSearch,
|
|
19
|
+
defaultAffiliate,
|
|
18
20
|
}) => {
|
|
19
21
|
// const [expiryFlow, setExpiryFlow] = useState();
|
|
20
22
|
const [switchValue, setSwitchValue] = useState(null);
|
|
21
23
|
const [selectedValue, setSelectedValue] = useState(null);
|
|
22
|
-
const
|
|
23
|
-
const {
|
|
24
|
-
getDefaultAffiliateData,
|
|
25
|
-
handleGetDefaultAffiliate,
|
|
26
|
-
handleSetDefaultAffiliate,
|
|
27
|
-
setDefaultAffiliateData,
|
|
28
|
-
handleGetAllAffiliate,
|
|
29
|
-
getAllAffiliateData,
|
|
30
|
-
} = useHeader();
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const account = generalData?.selectedAccount;
|
|
34
|
-
if (account?.type?.toLocaleLowerCase() === "instructor") {
|
|
35
|
-
handleGetAllAffiliate({ search });
|
|
36
|
-
}
|
|
37
|
-
}, [generalData?.selectedAccount, search]);
|
|
38
|
-
|
|
39
|
-
const dropdownList = getAllAffiliateData?.data?.results?.map((item) => {
|
|
40
|
-
const image = item?.profile_photo?.url;
|
|
41
|
-
return {
|
|
42
|
-
name: item?.metadata?.organization_name ?? "...",
|
|
43
|
-
image,
|
|
44
|
-
id: item?.id,
|
|
45
|
-
};
|
|
46
|
-
});
|
|
24
|
+
const { handleSetDefaultAffiliate, setDefaultAffiliateData } = useHeader();
|
|
47
25
|
|
|
48
26
|
const [dropdown, setDropdown] = useState(false);
|
|
49
27
|
|
|
@@ -123,15 +101,14 @@ const InstructorAccountSwitcher = ({
|
|
|
123
101
|
prioritizedAffiliateId = cookieValue;
|
|
124
102
|
} else if (
|
|
125
103
|
planState !== "ACTIVE" &&
|
|
126
|
-
planState !== "GRACE PERIOD"
|
|
127
|
-
getAllAffiliateData?.data?.results?.length > 0 // Check if the list exists and is not empty
|
|
104
|
+
planState !== "GRACE PERIOD" // Check if the list exists and is not empty
|
|
128
105
|
) {
|
|
129
|
-
|
|
130
|
-
handleSelection(getAllAffiliateData.data.results[0]);
|
|
131
|
-
prioritizedAffiliateId = getAllAffiliateData.data.results[0]?.id; // Optional chaining on 'id'
|
|
106
|
+
prioritizedAffiliateId = cookieValue;
|
|
107
|
+
// handleSelection(getAllAffiliateData.data.results[0]);
|
|
108
|
+
// prioritizedAffiliateId = getAllAffiliateData.data.results[0]?.id; // Optional chaining on 'id'
|
|
132
109
|
}
|
|
133
110
|
return prioritizedAffiliateId;
|
|
134
|
-
}, [
|
|
111
|
+
}, [planState]);
|
|
135
112
|
|
|
136
113
|
useEffect(() => {
|
|
137
114
|
const cookie = prioritizedAffiliateId ?? cookieValue;
|
|
@@ -140,47 +117,17 @@ const InstructorAccountSwitcher = ({
|
|
|
140
117
|
// store cookie
|
|
141
118
|
setCookie(cookie);
|
|
142
119
|
onChange({ id: cookie });
|
|
143
|
-
setIsAffiliateLoading(false);
|
|
144
120
|
} else {
|
|
145
121
|
setSwitchValue(null);
|
|
146
122
|
onChange(null);
|
|
147
|
-
setIsAffiliateLoading(false);
|
|
148
123
|
}
|
|
149
124
|
}, [prioritizedAffiliateId]);
|
|
150
125
|
|
|
151
|
-
|
|
152
|
-
const res = await handleGetDefaultAffiliate();
|
|
153
|
-
const value = res?.data;
|
|
154
|
-
const error = res?.response?.data?.errors?.length > 0;
|
|
155
|
-
if (value) {
|
|
156
|
-
const image = value?.profile_photo?.url;
|
|
157
|
-
setSelectedValue(() => ({
|
|
158
|
-
name: value?.metadata?.organization_name,
|
|
159
|
-
image,
|
|
160
|
-
id: value?.id,
|
|
161
|
-
}));
|
|
162
|
-
} else if (error) {
|
|
163
|
-
deleteCookies("affiliateAccount");
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
useEffect(() => {
|
|
168
|
-
if (getAllAffiliateData?.data?.results?.length > 0) {
|
|
169
|
-
getDefault();
|
|
170
|
-
} else if (getAllAffiliateData?.data?.results?.length === 0) {
|
|
171
|
-
onChange && onChange(null);
|
|
172
|
-
cookieValue && deleteCookies("affiliateAccount");
|
|
173
|
-
}
|
|
174
|
-
}, [getAllAffiliateData?.data]);
|
|
175
|
-
|
|
176
|
-
//useeffect to supply loading state
|
|
177
|
-
useEffect(() => {}, [getAllAffiliateData]);
|
|
178
|
-
|
|
179
|
-
return getAllAffiliateData?.data?.results?.length > 0 && !search ? (
|
|
126
|
+
return (
|
|
180
127
|
<>
|
|
181
|
-
{
|
|
182
|
-
|
|
183
|
-
|
|
128
|
+
{setDefaultAffiliateData?.loading && (
|
|
129
|
+
<FullPageLoader fixed hasBackground />
|
|
130
|
+
)}
|
|
184
131
|
{/* {expiryFlow === "renew" && (
|
|
185
132
|
<RenewModal
|
|
186
133
|
close={() => setExpiryFlow(null)}
|
|
@@ -210,7 +157,7 @@ const InstructorAccountSwitcher = ({
|
|
|
210
157
|
{switchValue === "affiliates" && (
|
|
211
158
|
<OutsideAlerter handleClick={() => setDropdown(false)}>
|
|
212
159
|
<AffiliatesDropDown>
|
|
213
|
-
{!
|
|
160
|
+
{!defaultAffiliate ? (
|
|
214
161
|
<div
|
|
215
162
|
className="placeholder"
|
|
216
163
|
onClick={() => setDropdown(!dropdown)}
|
|
@@ -224,8 +171,8 @@ const InstructorAccountSwitcher = ({
|
|
|
224
171
|
onClick={() => setDropdown(!dropdown)}
|
|
225
172
|
>
|
|
226
173
|
<div>
|
|
227
|
-
<img src={
|
|
228
|
-
<p>{
|
|
174
|
+
<img src={defaultAffiliate?.cover_photo?.url} alt="" />
|
|
175
|
+
<p>{defaultAffiliate?.metadata?.organization_name}</p>
|
|
229
176
|
</div>
|
|
230
177
|
<ArrowDown />
|
|
231
178
|
</div>
|
|
@@ -240,7 +187,7 @@ const InstructorAccountSwitcher = ({
|
|
|
240
187
|
/>
|
|
241
188
|
</div>
|
|
242
189
|
<ul>
|
|
243
|
-
{
|
|
190
|
+
{affiliateList?.map((item) => (
|
|
244
191
|
<li
|
|
245
192
|
key={item?.id}
|
|
246
193
|
onClick={() => {
|
|
@@ -283,8 +230,6 @@ const InstructorAccountSwitcher = ({
|
|
|
283
230
|
}
|
|
284
231
|
</Container>
|
|
285
232
|
</>
|
|
286
|
-
) : (
|
|
287
|
-
<></>
|
|
288
233
|
);
|
|
289
234
|
};
|
|
290
235
|
|