l-min-components 1.0.883 → 1.0.891
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,8 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useState,
|
|
3
|
-
useEffect,
|
|
4
|
-
createContext,
|
|
5
|
-
} from "react";
|
|
1
|
+
import React, { useState, useEffect, createContext } from "react";
|
|
6
2
|
import { Outlet, useLocation } from "react-router-dom";
|
|
7
3
|
import {
|
|
8
4
|
Layout,
|
|
@@ -16,6 +12,7 @@ import {
|
|
|
16
12
|
Banner,
|
|
17
13
|
SideNav as SideBar,
|
|
18
14
|
SideMenu,
|
|
15
|
+
FullPageLoader,
|
|
19
16
|
} from "../";
|
|
20
17
|
import { leftNavMenu, user, sideMenuOptions } from "../../hooks/leftNavMenu";
|
|
21
18
|
import InstructorAccountSwitcher from "../instructorAccountSwitcher";
|
|
@@ -97,7 +94,6 @@ const AppMainLayout = () => {
|
|
|
97
94
|
// set access token from cookie to context
|
|
98
95
|
|
|
99
96
|
useEffect(() => {
|
|
100
|
-
|
|
101
97
|
let cookieValue = null;
|
|
102
98
|
const cookieName = "access";
|
|
103
99
|
|
|
@@ -172,156 +168,167 @@ const AppMainLayout = () => {
|
|
|
172
168
|
setDefaultLang,
|
|
173
169
|
defaultLang,
|
|
174
170
|
findText,
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
translations,
|
|
172
|
+
isTranslationsLoading,
|
|
173
|
+
translateData
|
|
177
174
|
} = useTranslation(wordBank);
|
|
178
|
-
|
|
175
|
+
|
|
179
176
|
return (
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
<
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
177
|
+
<OutletContext.Provider
|
|
178
|
+
value={{
|
|
179
|
+
findText,
|
|
180
|
+
wordBank,
|
|
181
|
+
defaultLang,
|
|
182
|
+
setDefaultLang,
|
|
183
|
+
setRightComponent,
|
|
184
|
+
setRightLayout,
|
|
185
|
+
generalData,
|
|
186
|
+
setGeneralData,
|
|
187
|
+
coming,
|
|
188
|
+
hasLayoutBackgroundImage,
|
|
189
|
+
setHasLayoutBackgroundImage,
|
|
190
|
+
setSideMenuLayout,
|
|
191
|
+
activePage,
|
|
192
|
+
setActivePage,
|
|
193
|
+
studyTab,
|
|
194
|
+
setStudyTab,
|
|
195
|
+
page,
|
|
196
|
+
setPage,
|
|
197
|
+
selectedCourseId,
|
|
198
|
+
setSelectedCourseId,
|
|
199
|
+
centerLayoutStyle,
|
|
200
|
+
setCenterLayoutStyle,
|
|
201
|
+
// return true if instructor affiliates is Active
|
|
202
|
+
setHideAffilicates,
|
|
203
|
+
affiliatesActive,
|
|
204
|
+
accessToken,
|
|
205
|
+
envType,
|
|
206
|
+
newNotifications,
|
|
207
|
+
setNewNotifications,
|
|
208
|
+
notificationMarkReadData,
|
|
209
|
+
handleGetNotificationMarkRead,
|
|
210
|
+
}}
|
|
211
|
+
>
|
|
212
|
+
{/* display mobile layout on device width*/}
|
|
213
|
+
{deviceWidth < 1200 ? (
|
|
214
|
+
<MobileLayout />
|
|
215
|
+
) : (
|
|
216
|
+
<>
|
|
217
|
+
{isTranslationsLoading && Object.keys(translations)?.length === 0 ? (
|
|
218
|
+
<h1> LOADING </h1>
|
|
219
|
+
) : (
|
|
220
|
+
<Layout
|
|
221
|
+
coming={coming}
|
|
222
|
+
hasLayoutBackgroundImage={hasLayoutBackgroundImage}
|
|
223
|
+
>
|
|
224
|
+
<HeaderComponent setNewNotifications={setNewNotifications} />
|
|
225
|
+
<MainLayout coming={coming}>
|
|
226
|
+
<LeftLayout>
|
|
227
|
+
<SideBar routes={leftNavMenu} />
|
|
228
|
+
{!coming && (
|
|
229
|
+
<>
|
|
230
|
+
{sideMenuLayout && (
|
|
231
|
+
<SideMenu
|
|
232
|
+
user={user}
|
|
233
|
+
routes={sideMenuOptions}
|
|
234
|
+
affiliatesActive={affiliatesActive}
|
|
235
|
+
userType={generalData?.selectedAccount?.type?.toLowerCase()}
|
|
236
|
+
isOpen={isOpen}
|
|
237
|
+
setIsOpen={setIsOpen}
|
|
238
|
+
setRightComponent={setRightComponent}
|
|
239
|
+
planState={planState}
|
|
240
|
+
findText={findText}
|
|
241
|
+
/>
|
|
242
|
+
)}
|
|
243
|
+
</>
|
|
244
|
+
)}
|
|
245
|
+
{
|
|
246
|
+
// window.location.pathname.includes("enterprise")
|
|
247
|
+
// ? "enterprise"
|
|
248
|
+
// : window.location.pathname.includes("personal")
|
|
249
|
+
// ? "personal"
|
|
250
|
+
// : window.location.pathname.includes("instructor")
|
|
251
|
+
// ? "instructor"
|
|
252
|
+
// : window.location.pathname.includes("developer") ||
|
|
253
|
+
// window.location.hostname.includes("developer")
|
|
254
|
+
// ? "developer"
|
|
255
|
+
// : "developer"
|
|
256
|
+
}
|
|
257
|
+
</LeftLayout>
|
|
258
|
+
<CenterLayout isOpen={isOpen} style={centerLayoutStyle}>
|
|
259
|
+
{window.location.pathname.includes("instructor") &&
|
|
260
|
+
!window.location.pathname.includes("enterprise") &&
|
|
261
|
+
!window.location.pathname.includes("manage-teams") &&
|
|
262
|
+
!hideAffilicates && (
|
|
263
|
+
<InstructorAccountSwitcher
|
|
264
|
+
setAccountType={setAffiliatesActive}
|
|
237
265
|
/>
|
|
238
266
|
)}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// : window.location.pathname.includes("instructor")
|
|
247
|
-
// ? "instructor"
|
|
248
|
-
// : window.location.pathname.includes("developer") ||
|
|
249
|
-
// window.location.hostname.includes("developer")
|
|
250
|
-
// ? "developer"
|
|
251
|
-
// : "developer"
|
|
252
|
-
}
|
|
253
|
-
</LeftLayout>
|
|
254
|
-
<CenterLayout isOpen={isOpen} style={centerLayoutStyle}>
|
|
255
|
-
{window.location.pathname.includes("instructor") &&
|
|
256
|
-
!window.location.pathname.includes("enterprise") &&
|
|
257
|
-
!window.location.pathname.includes("manage-teams") &&
|
|
258
|
-
!hideAffilicates && (
|
|
259
|
-
<InstructorAccountSwitcher
|
|
260
|
-
setAccountType={setAffiliatesActive}
|
|
267
|
+
|
|
268
|
+
{window.location.pathname.includes("enterprise") &&
|
|
269
|
+
planState === "GRACE PERIOD" ? (
|
|
270
|
+
<GracePeriod
|
|
271
|
+
getCurrentSubscriptionData={getCurrentSubscriptionData}
|
|
272
|
+
handleCurrentSubscription={handleCurrentSubscription}
|
|
273
|
+
gracePeriod={gracePeriod}
|
|
261
274
|
/>
|
|
275
|
+
) : (
|
|
276
|
+
<Outlet />
|
|
262
277
|
)}
|
|
278
|
+
</CenterLayout>
|
|
263
279
|
|
|
264
|
-
{
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
handleCurrentSubscription={handleCurrentSubscription}
|
|
269
|
-
gracePeriod={gracePeriod}
|
|
270
|
-
/>
|
|
271
|
-
) : (
|
|
272
|
-
<Outlet />
|
|
273
|
-
)}
|
|
274
|
-
</CenterLayout>
|
|
275
|
-
|
|
276
|
-
{rightLayout && !coming && (
|
|
277
|
-
<RightLayout>
|
|
278
|
-
{rightComponent ??
|
|
279
|
-
(window.location.pathname.includes("enterprise") &&
|
|
280
|
-
!window.location.pathname.includes("file-manager") ? (
|
|
281
|
-
<EnterpriseRightBar
|
|
282
|
-
gracePeriod={gracePeriod}
|
|
283
|
-
setGracePeriod={setGracePeriod}
|
|
284
|
-
planState={planState}
|
|
285
|
-
/>
|
|
286
|
-
) : window.location.pathname.includes(
|
|
287
|
-
"personal/dashboard"
|
|
288
|
-
) ? (
|
|
289
|
-
<PersonalRightBar />
|
|
290
|
-
) : window.location.pathname.includes("personal/addons") ? (
|
|
291
|
-
<InstructorRightBar personal />
|
|
292
|
-
) : window.location.pathname.includes(
|
|
293
|
-
"personal/courses"
|
|
294
|
-
) ? (
|
|
295
|
-
<InstructorRightBar personal />
|
|
296
|
-
) : window.location.pathname.includes(
|
|
297
|
-
"personal/library/selectlanguage"
|
|
298
|
-
) ? (
|
|
299
|
-
<InstructorRightBar personal />
|
|
300
|
-
) : window.location.pathname.includes(
|
|
301
|
-
"personal/library"
|
|
302
|
-
) ? (
|
|
303
|
-
<PersonalRightBar personalLibrary />
|
|
304
|
-
) : window.location.pathname.includes(
|
|
305
|
-
"personal/reports"
|
|
306
|
-
) ? (
|
|
307
|
-
<PersonalRightBar personalReport />
|
|
308
|
-
) : window.location.pathname.includes("instructor") &&
|
|
309
|
-
!window.location.pathname.includes("manage-teams") &&
|
|
280
|
+
{rightLayout && !coming && (
|
|
281
|
+
<RightLayout>
|
|
282
|
+
{rightComponent ??
|
|
283
|
+
(window.location.pathname.includes("enterprise") &&
|
|
310
284
|
!window.location.pathname.includes("file-manager") ? (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
285
|
+
<EnterpriseRightBar
|
|
286
|
+
gracePeriod={gracePeriod}
|
|
287
|
+
setGracePeriod={setGracePeriod}
|
|
288
|
+
planState={planState}
|
|
289
|
+
/>
|
|
290
|
+
) : window.location.pathname.includes(
|
|
291
|
+
"personal/dashboard"
|
|
292
|
+
) ? (
|
|
293
|
+
<PersonalRightBar />
|
|
294
|
+
) : window.location.pathname.includes(
|
|
295
|
+
"personal/addons"
|
|
296
|
+
) ? (
|
|
297
|
+
<InstructorRightBar personal />
|
|
298
|
+
) : window.location.pathname.includes(
|
|
299
|
+
"personal/courses"
|
|
300
|
+
) ? (
|
|
301
|
+
<InstructorRightBar personal />
|
|
302
|
+
) : window.location.pathname.includes(
|
|
303
|
+
"personal/library/selectlanguage"
|
|
304
|
+
) ? (
|
|
305
|
+
<InstructorRightBar personal />
|
|
306
|
+
) : window.location.pathname.includes(
|
|
307
|
+
"personal/library"
|
|
308
|
+
) ? (
|
|
309
|
+
<PersonalRightBar personalLibrary />
|
|
310
|
+
) : window.location.pathname.includes(
|
|
311
|
+
"personal/reports"
|
|
312
|
+
) ? (
|
|
313
|
+
<PersonalRightBar personalReport />
|
|
314
|
+
) : window.location.pathname.includes("instructor") &&
|
|
315
|
+
!window.location.pathname.includes("manage-teams") &&
|
|
316
|
+
!window.location.pathname.includes("file-manager") ? (
|
|
317
|
+
<InstructorRightBar />
|
|
318
|
+
) : window.location.pathname.includes("developer") ? (
|
|
319
|
+
<Banner />
|
|
320
|
+
) : (
|
|
321
|
+
<Banner />
|
|
322
|
+
))}
|
|
323
|
+
{/* {rightComponent ?? <Banner />} */}
|
|
324
|
+
</RightLayout>
|
|
325
|
+
)}
|
|
326
|
+
</MainLayout>
|
|
327
|
+
</Layout>
|
|
328
|
+
)}
|
|
329
|
+
</>
|
|
330
|
+
)}
|
|
331
|
+
</OutletContext.Provider>
|
|
325
332
|
);
|
|
326
333
|
};
|
|
327
334
|
|
|
@@ -67,6 +67,7 @@ const HeaderComponent = (props) => {
|
|
|
67
67
|
setGeneralData,
|
|
68
68
|
generalData,
|
|
69
69
|
notificationMarkReadData,
|
|
70
|
+
findText
|
|
70
71
|
} = useContext(OutletContext);
|
|
71
72
|
const [selectedAccount, setSelectedAccount] = useState();
|
|
72
73
|
const { setDefaultAccount, handleSetDefaultAccount } = useHeader();
|
|
@@ -85,8 +86,9 @@ const HeaderComponent = (props) => {
|
|
|
85
86
|
"Report",
|
|
86
87
|
"Created",
|
|
87
88
|
"Report",
|
|
89
|
+
"Password mismatch"
|
|
88
90
|
];
|
|
89
|
-
const {
|
|
91
|
+
const { translateData, defaultLang, setDefaultLang } = useTranslation(wordBank);
|
|
90
92
|
|
|
91
93
|
useEffect(() => {
|
|
92
94
|
setIsOpen(false);
|
|
@@ -402,6 +404,7 @@ const HeaderComponent = (props) => {
|
|
|
402
404
|
const value = JSON?.parse(localStorage.getItem("defaultLang"));
|
|
403
405
|
const currentFlag = value?.flag;
|
|
404
406
|
const selectedLanguage = languagesData?.find((lang) => lang?.slug === defaultLang);
|
|
407
|
+
console.log("🚀 ~ HeaderComponent ~ defaultLang:", defaultLang, selectedLanguage?.flag, currentFlag)
|
|
405
408
|
|
|
406
409
|
// When Developer and on staging
|
|
407
410
|
const isDeveloper =
|
|
@@ -527,7 +530,7 @@ const HeaderComponent = (props) => {
|
|
|
527
530
|
setIsOpen();
|
|
528
531
|
}}
|
|
529
532
|
>
|
|
530
|
-
<img src={
|
|
533
|
+
<img src={ currentFlag || usFlag} alt="" />
|
|
531
534
|
<ArrowDownIcon />
|
|
532
535
|
</div>
|
|
533
536
|
{languageDropdown && (
|
|
@@ -24,6 +24,9 @@ const LanguageDropdown = ({ languageDropdown, setLanguageDropdown }) => {
|
|
|
24
24
|
const {
|
|
25
25
|
setGeneralData,
|
|
26
26
|
generalData,
|
|
27
|
+
wordBank,
|
|
28
|
+
defaultLang,
|
|
29
|
+
setDefaultLang,
|
|
27
30
|
} = useContext(OutletContext);
|
|
28
31
|
const {
|
|
29
32
|
retrieveUserDetailsData,
|
|
@@ -31,8 +34,13 @@ const LanguageDropdown = ({ languageDropdown, setLanguageDropdown }) => {
|
|
|
31
34
|
updateUserAccountData,
|
|
32
35
|
handleUpdateUserAccount,
|
|
33
36
|
} = useHeader();
|
|
34
|
-
const {
|
|
35
|
-
|
|
37
|
+
const {
|
|
38
|
+
findText,
|
|
39
|
+
translateData,
|
|
40
|
+
|
|
41
|
+
handleTranslate,
|
|
42
|
+
} = useTranslation();
|
|
43
|
+
|
|
36
44
|
const languagesData = [
|
|
37
45
|
{
|
|
38
46
|
name: "English",
|
|
@@ -92,7 +100,7 @@ const LanguageDropdown = ({ languageDropdown, setLanguageDropdown }) => {
|
|
|
92
100
|
}
|
|
93
101
|
setLanguageDropdown();
|
|
94
102
|
setDefaultLang(item?.slug);
|
|
95
|
-
handleTranslate(item?.slug,
|
|
103
|
+
// handleTranslate(item?.slug, wordBank)
|
|
96
104
|
// item?.slug === defaultLang
|
|
97
105
|
// ? setIsLoading(false)
|
|
98
106
|
// : setIsLoading(true);
|
|
@@ -27,13 +27,14 @@ const SideMenu = ({
|
|
|
27
27
|
affiliatesActive,
|
|
28
28
|
setRightComponent,
|
|
29
29
|
planState,
|
|
30
|
+
findText
|
|
30
31
|
}) => {
|
|
31
32
|
//console.log("user type", userType);
|
|
32
33
|
// const [isOpen, setIsOpen] = useState(false);
|
|
33
34
|
const [gracePeriod, setGracePeriod] = useState(true);
|
|
34
35
|
|
|
35
36
|
const { setGeneralData, generalData } = useContext(OutletContext);
|
|
36
|
-
const { findText } = useTranslation();
|
|
37
|
+
// const { findText } = useTranslation();
|
|
37
38
|
const onToggle = () => {
|
|
38
39
|
setIsOpen(!isOpen);
|
|
39
40
|
};
|
|
@@ -4,26 +4,16 @@ import useAxios from "axios-hooks";
|
|
|
4
4
|
const useTranslation = (initialSentences = []) => {
|
|
5
5
|
const value = JSON?.parse(localStorage.getItem("defaultLang"));
|
|
6
6
|
|
|
7
|
-
const [defaultLang, setDefaultLang] = useState(value?.slug ?? "
|
|
7
|
+
const [defaultLang, setDefaultLang] = useState(value?.slug ?? "ko");
|
|
8
8
|
const [translations, setTranslations] = useState({}); // returned translation from backend
|
|
9
|
-
const [
|
|
10
|
-
|
|
9
|
+
const [isTranslationsLoading, setIsTranslationsLoading] = useState(true)
|
|
10
|
+
|
|
11
11
|
|
|
12
12
|
const findText = useCallback(
|
|
13
13
|
(word, kwargs = {}) => {
|
|
14
|
-
|
|
15
|
-
if (!translations[word] && !wordsToTranslate.includes(word)) {
|
|
16
|
-
setWordsToTranslate((prevWords) => {
|
|
17
|
-
// Ensure the word is only added if it's not already in the list
|
|
18
|
-
if (!prevWords.includes(word)) {
|
|
19
|
-
return [...prevWords, word];
|
|
20
|
-
}
|
|
21
|
-
return prevWords;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return formatSentence(translations[word] || word, kwargs); // Return translated word or original word if not yet translated
|
|
14
|
+
return formatSentence(translations[word], kwargs); // Return translated word or original word if not yet translated
|
|
25
15
|
},
|
|
26
|
-
[translations
|
|
16
|
+
[translations]
|
|
27
17
|
);
|
|
28
18
|
|
|
29
19
|
// api request for sending data to backend
|
|
@@ -52,39 +42,32 @@ const useTranslation = (initialSentences = []) => {
|
|
|
52
42
|
}
|
|
53
43
|
};
|
|
54
44
|
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
if (initialSentences.length > 0) {
|
|
57
|
-
// Add initial sentences while ensuring no duplicates
|
|
58
|
-
const uniqueSentences = initialSentences.filter(
|
|
59
|
-
(word, index) => initialSentences.indexOf(word) === index
|
|
60
|
-
);
|
|
61
|
-
setWordsToTranslate((prevWords) => [
|
|
62
|
-
...prevWords,
|
|
63
|
-
...uniqueSentences.filter((word) => !prevWords.includes(word)),
|
|
64
|
-
]);
|
|
65
|
-
}
|
|
66
|
-
}, []);
|
|
67
45
|
|
|
68
46
|
useEffect(() => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// setWordsToTranslate([]); // Clear the list after translating
|
|
72
|
-
}
|
|
73
|
-
}, [defaultLang, wordsToTranslate]);
|
|
47
|
+
handleTranslate(defaultLang, initialSentences);
|
|
48
|
+
}, [defaultLang]);
|
|
74
49
|
|
|
75
50
|
useEffect(() => {
|
|
76
|
-
if (translateData?.
|
|
77
|
-
|
|
51
|
+
if (translateData?.data) {
|
|
78
52
|
const newTranslations = {};
|
|
79
|
-
|
|
53
|
+
initialSentences.map((word, index) => {
|
|
80
54
|
newTranslations[word] = translateData?.data?.result[index];
|
|
55
|
+
console.log(translateData?.data?.result, "result")
|
|
81
56
|
});
|
|
82
57
|
setTranslations((prevTranslations) => ({
|
|
83
58
|
...prevTranslations,
|
|
84
59
|
...newTranslations,
|
|
85
60
|
}));
|
|
86
61
|
}
|
|
87
|
-
}, [translateData?.
|
|
62
|
+
}, [translateData?.data]);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
|
|
66
|
+
if(Object.keys(translations)?.length > 0){
|
|
67
|
+
setIsTranslationsLoading(false)
|
|
68
|
+
}
|
|
69
|
+
}, [translations])
|
|
70
|
+
|
|
88
71
|
|
|
89
72
|
|
|
90
73
|
return {
|
|
@@ -94,8 +77,7 @@ const useTranslation = (initialSentences = []) => {
|
|
|
94
77
|
handleTranslate,
|
|
95
78
|
translations,
|
|
96
79
|
findText,
|
|
97
|
-
|
|
98
|
-
isTranslationsComplete,
|
|
80
|
+
isTranslationsLoading,
|
|
99
81
|
};
|
|
100
82
|
};
|
|
101
83
|
|