l-min-components 1.0.886 → 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,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.0.886",
3
+ "version": "1.0.891",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -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
- translateData,
176
- isTranslationsComplete
171
+ translations,
172
+ isTranslationsLoading,
173
+ translateData
177
174
  } = useTranslation(wordBank);
178
-
175
+
179
176
  return (
180
- !translateData?.loading && !isTranslationsComplete && (
181
- <OutletContext.Provider
182
- value={{
183
- findText,
184
- defaultLang,
185
- setDefaultLang,
186
- setRightComponent,
187
- setRightLayout,
188
- generalData,
189
- setGeneralData,
190
- coming,
191
- hasLayoutBackgroundImage,
192
- setHasLayoutBackgroundImage,
193
- setSideMenuLayout,
194
- activePage,
195
- setActivePage,
196
- studyTab,
197
- setStudyTab,
198
- page,
199
- setPage,
200
- selectedCourseId,
201
- setSelectedCourseId,
202
- centerLayoutStyle,
203
- setCenterLayoutStyle,
204
- // return true if instructor affiliates is Active
205
- setHideAffilicates,
206
- affiliatesActive,
207
- accessToken,
208
- envType,
209
- newNotifications,
210
- setNewNotifications,
211
- notificationMarkReadData,
212
- handleGetNotificationMarkRead,
213
- }}>
214
- {/* display mobile layout on device width*/}
215
- {deviceWidth < 1200 ? (
216
- <MobileLayout />
217
- ) : (
218
- <Layout
219
- coming={coming}
220
- hasLayoutBackgroundImage={hasLayoutBackgroundImage}>
221
- <HeaderComponent setNewNotifications={setNewNotifications} />
222
- <MainLayout coming={coming}>
223
- <LeftLayout>
224
- <SideBar routes={leftNavMenu} />
225
- {!coming && (
226
- <>
227
- {sideMenuLayout && (
228
- <SideMenu
229
- user={user}
230
- routes={sideMenuOptions}
231
- affiliatesActive={affiliatesActive}
232
- userType={generalData?.selectedAccount?.type?.toLowerCase()}
233
- isOpen={isOpen}
234
- setIsOpen={setIsOpen}
235
- setRightComponent={setRightComponent}
236
- planState={planState}
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
- // window.location.pathname.includes("enterprise")
243
- // ? "enterprise"
244
- // : window.location.pathname.includes("personal")
245
- // ? "personal"
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
- {window.location.pathname.includes("enterprise") &&
265
- planState === "GRACE PERIOD" ? (
266
- <GracePeriod
267
- getCurrentSubscriptionData={getCurrentSubscriptionData}
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
- <InstructorRightBar />
312
- ) : window.location.pathname.includes("developer") ? (
313
- <Banner />
314
- ) : (
315
- <Banner />
316
- ))}
317
- {/* {rightComponent ?? <Banner />} */}
318
- </RightLayout>
319
- )}
320
- </MainLayout>
321
- </Layout>
322
- )}
323
- </OutletContext.Provider>
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 { findText, translateData, defaultLang, setDefaultLang } = useTranslation(wordBank);
91
+ const { translateData, defaultLang, setDefaultLang } = useTranslation(wordBank);
90
92
 
91
93
  useEffect(() => {
92
94
  setIsOpen(false);
@@ -528,7 +530,7 @@ const HeaderComponent = (props) => {
528
530
  setIsOpen();
529
531
  }}
530
532
  >
531
- <img src={selectedLanguage?.flag || currentFlag || usFlag} alt="" />
533
+ <img src={ currentFlag || usFlag} alt="" />
532
534
  <ArrowDownIcon />
533
535
  </div>
534
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,
@@ -34,10 +37,8 @@ const LanguageDropdown = ({ languageDropdown, setLanguageDropdown }) => {
34
37
  const {
35
38
  findText,
36
39
  translateData,
37
- defaultLang,
38
- setDefaultLang,
40
+
39
41
  handleTranslate,
40
- wordsToTranslate,
41
42
  } = useTranslation();
42
43
 
43
44
  const languagesData = [
@@ -99,7 +100,7 @@ const LanguageDropdown = ({ languageDropdown, setLanguageDropdown }) => {
99
100
  }
100
101
  setLanguageDropdown();
101
102
  setDefaultLang(item?.slug);
102
- handleTranslate(item?.slug, wordsToTranslate)
103
+ // handleTranslate(item?.slug, wordBank)
103
104
  // item?.slug === defaultLang
104
105
  // ? setIsLoading(false)
105
106
  // : setIsLoading(true);
@@ -27,12 +27,13 @@ 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
- const { setGeneralData, generalData, findText } = useContext(OutletContext);
36
+ const { setGeneralData, generalData } = useContext(OutletContext);
36
37
  // const { findText } = useTranslation();
37
38
  const onToggle = () => {
38
39
  setIsOpen(!isOpen);
@@ -4,29 +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 ?? "en");
7
+ const [defaultLang, setDefaultLang] = useState(value?.slug ?? "ko");
8
8
  const [translations, setTranslations] = useState({}); // returned translation from backend
9
- const [wordsToTranslate, setWordsToTranslate] = useState([]); // sent translations to backend
10
- const isTranslationsComplete = Object.keys(translations)?.length === 0;
11
- console.log("🚀 ~ useTranslation ~ translations:", translations)
12
- console.log("🚀 ~ useTranslation ~ wordsToTranslate:", wordsToTranslate)
9
+ const [isTranslationsLoading, setIsTranslationsLoading] = useState(true)
13
10
 
14
11
 
15
12
  const findText = useCallback(
16
13
  (word, kwargs = {}) => {
17
- // Check if the word is not already translated and not already in the list to avoid duplicates
18
- if (!translations[word] && !wordsToTranslate.includes(word)) {
19
- setWordsToTranslate((prevWords) => {
20
- // Ensure the word is only added if it's not already in the list
21
- if (!prevWords.includes(word)) {
22
- return [...prevWords, word];
23
- }
24
- return prevWords;
25
- });
26
- }
27
- 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
28
15
  },
29
- [translations, wordsToTranslate]
16
+ [translations]
30
17
  );
31
18
 
32
19
  // api request for sending data to backend
@@ -55,39 +42,32 @@ const useTranslation = (initialSentences = []) => {
55
42
  }
56
43
  };
57
44
 
58
- useEffect(() => {
59
- if (initialSentences.length > 0) {
60
- // Add initial sentences while ensuring no duplicates
61
- const uniqueSentences = initialSentences.filter(
62
- (word, index) => initialSentences.indexOf(word) === index
63
- );
64
- setWordsToTranslate((prevWords) => [
65
- ...prevWords,
66
- ...uniqueSentences.filter((word) => !prevWords.includes(word)),
67
- ]);
68
- }
69
- }, []);
70
45
 
71
46
  useEffect(() => {
72
- if (wordsToTranslate?.length > 0) {
73
- handleTranslate(defaultLang, wordsToTranslate);
74
- // setWordsToTranslate([]); // Clear the list after translating
75
- }
47
+ handleTranslate(defaultLang, initialSentences);
76
48
  }, [defaultLang]);
77
49
 
78
50
  useEffect(() => {
79
- if (translateData?.response) {
80
-
51
+ if (translateData?.data) {
81
52
  const newTranslations = {};
82
- wordsToTranslate.forEach((word, index) => {
53
+ initialSentences.map((word, index) => {
83
54
  newTranslations[word] = translateData?.data?.result[index];
55
+ console.log(translateData?.data?.result, "result")
84
56
  });
85
57
  setTranslations((prevTranslations) => ({
86
58
  ...prevTranslations,
87
59
  ...newTranslations,
88
60
  }));
89
61
  }
90
- }, [translateData?.response]);
62
+ }, [translateData?.data]);
63
+
64
+ useEffect(() => {
65
+
66
+ if(Object.keys(translations)?.length > 0){
67
+ setIsTranslationsLoading(false)
68
+ }
69
+ }, [translations])
70
+
91
71
 
92
72
 
93
73
  return {
@@ -97,8 +77,7 @@ const useTranslation = (initialSentences = []) => {
97
77
  handleTranslate,
98
78
  translations,
99
79
  findText,
100
- wordsToTranslate,
101
- isTranslationsComplete,
80
+ isTranslationsLoading,
102
81
  };
103
82
  };
104
83