l-min-components 1.0.1025 → 1.0.1029
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
|
@@ -44,21 +44,26 @@ const InstructorAccountSwitcher = ({
|
|
|
44
44
|
const [dropdown, setDropdown] = useState(false);
|
|
45
45
|
|
|
46
46
|
const getCookie = () => {
|
|
47
|
-
|
|
48
|
-
const
|
|
47
|
+
const cookies = document.cookie;
|
|
48
|
+
const cookieArray = cookies.split(";");
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
let affiliateAccount = null;
|
|
51
|
+
|
|
52
|
+
cookieArray?.forEach((cookieValue) => {
|
|
53
|
+
const cookie = cookieValue?.trim();
|
|
54
|
+
if (cookie.startsWith("affiliateAccount=")) {
|
|
55
|
+
affiliateAccount = cookie.substring(
|
|
56
|
+
"affiliateAccount=".length,
|
|
57
|
+
cookie.length
|
|
58
|
+
);
|
|
56
59
|
}
|
|
57
|
-
}
|
|
60
|
+
});
|
|
58
61
|
|
|
59
|
-
return
|
|
62
|
+
return affiliateAccount;
|
|
60
63
|
};
|
|
61
64
|
|
|
65
|
+
const cookieValue = getCookie();
|
|
66
|
+
|
|
62
67
|
const setCookie = (id) => {
|
|
63
68
|
const date = new Date();
|
|
64
69
|
date.setDate(date.getDate() + 20);
|
|
@@ -73,53 +78,40 @@ const InstructorAccountSwitcher = ({
|
|
|
73
78
|
|
|
74
79
|
const handleSwitch = (value) => {
|
|
75
80
|
if (value === 2) {
|
|
76
|
-
setSwitchValue("affiliates");
|
|
77
81
|
if (selectedValue) {
|
|
78
82
|
setCookie(selectedValue?.id);
|
|
79
83
|
}
|
|
80
84
|
} else {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
if (cookieValue) {
|
|
86
|
+
deleteCookies("affiliateAccount");
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
window.location.href = "/instructor/dashboard";
|
|
86
90
|
};
|
|
87
91
|
|
|
88
92
|
useEffect(() => {
|
|
89
|
-
let cookieValue = getCookie();
|
|
90
93
|
if (cookieValue) {
|
|
91
94
|
setSwitchValue("affiliates");
|
|
95
|
+
onChange({ id: selectedValue?.id });
|
|
92
96
|
} else {
|
|
93
97
|
setSwitchValue(null);
|
|
98
|
+
onChange(null);
|
|
94
99
|
}
|
|
95
100
|
}, []);
|
|
96
101
|
|
|
97
102
|
useEffect(() => {
|
|
98
|
-
handleGetDefaultAffiliate()
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
.catch(() => {
|
|
111
|
-
deleteCookies("affiliateAccount");
|
|
112
|
-
});
|
|
113
|
-
}, [setDefaultAffiliateData?.data, switchValue]);
|
|
114
|
-
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
const value = JSON.parse(localStorage.getItem("affiliates"));
|
|
117
|
-
if (value) {
|
|
118
|
-
setAccountType && setAccountType(switchValue);
|
|
119
|
-
} else {
|
|
120
|
-
setAccountType && setAccountType(switchValue);
|
|
121
|
-
}
|
|
122
|
-
}, [switchValue]);
|
|
103
|
+
handleGetDefaultAffiliate().then((res) => {
|
|
104
|
+
if (res?.data) {
|
|
105
|
+
const value = res?.data;
|
|
106
|
+
const image = value?.profile_photo?.url;
|
|
107
|
+
setSelectedValue(() => ({
|
|
108
|
+
name: value?.display_name,
|
|
109
|
+
image,
|
|
110
|
+
id: value?.id,
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}, []);
|
|
123
115
|
|
|
124
116
|
const handleSelection = async (item) => {
|
|
125
117
|
const res = await handleSetDefaultAffiliate({
|
|
@@ -127,19 +119,10 @@ const InstructorAccountSwitcher = ({
|
|
|
127
119
|
});
|
|
128
120
|
if (res?.data) {
|
|
129
121
|
setCookie(item?.id);
|
|
130
|
-
setSelectedValue(item);
|
|
131
|
-
setDropdown(false);
|
|
132
122
|
window.location.href = "/instructor/dashboard";
|
|
133
123
|
}
|
|
134
124
|
};
|
|
135
125
|
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
if (onChange) {
|
|
138
|
-
let cookieValue = getCookie();
|
|
139
|
-
if (cookieValue) onChange({ id: selectedValue?.id });
|
|
140
|
-
else onChange(null);
|
|
141
|
-
}
|
|
142
|
-
}, [selectedValue]);
|
|
143
126
|
return getAllAffiliateData?.data?.count && !search ? (
|
|
144
127
|
<>
|
|
145
128
|
{(setDefaultAffiliateData?.loading ||
|