l-min-components 1.0.876 → 1.0.883

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.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/src/components/AdminAppMainLayout/index.jsx +0 -3
  3. package/src/components/AdminResetPassword/change-password.jsx +1 -2
  4. package/src/components/AdminResetPassword/index.jsx +1 -1
  5. package/src/components/AdminSecuritySettings/modals/success-modal.jsx +0 -1
  6. package/src/components/AdminSidebar/index.jsx +3 -6
  7. package/src/components/AppMainLayout/index.jsx +22 -18
  8. package/src/components/banner/index.jsx +1 -7
  9. package/src/components/button/index.jsx +1 -7
  10. package/src/components/datePicker/index.jsx +0 -1
  11. package/src/components/deactivated/modal/subscription-expired-modal.jsx +1 -11
  12. package/src/components/dropdown component/dropdown.jsx +1 -3
  13. package/src/components/errorPage/index.jsx +1 -1
  14. package/src/components/fileRightBar/enterpriseRightBar/index.jsx +0 -8
  15. package/src/components/fileRightBar/instructorRightBar.jsx +0 -8
  16. package/src/components/fileRightBar/managerPageRight.jsx +0 -3
  17. package/src/components/fileRightBar/personalRightBar/index.jsx +1 -10
  18. package/src/components/fileRightBar/upgrade.jsx +0 -12
  19. package/src/components/fileRightBar/uploadRight.jsx +0 -16
  20. package/src/components/fileRightBar/users.jsx +0 -13
  21. package/src/components/friendRequest/friendRequestList/index.jsx +0 -1
  22. package/src/components/fullPageLoader/index.jsx +0 -3
  23. package/src/components/graph/index.jsx +0 -1
  24. package/src/components/header/index.jsx +20 -13
  25. package/src/components/header/languageDropdown.jsx +6 -9
  26. package/src/components/header/login-header.jsx +3 -5
  27. package/src/components/index.js +0 -1
  28. package/src/components/input/index.jsx +1 -4
  29. package/src/components/mobileLayout/index.jsx +1 -1
  30. package/src/components/radio/index.jsx +1 -2
  31. package/src/components/searchBar/index.jsx +0 -2
  32. package/src/components/sideBar/sideMenu/index.jsx +4 -2
  33. package/src/components/sideBar/userCard/index.jsx +4 -2
  34. package/src/components/sideNav/index.jsx +2 -3
  35. package/src/components/textEditor/index.jsx +1 -1
  36. package/src/hooks/leftNavMenu.jsx +5 -10
  37. package/src/hooks/useTranslation.jsx +84 -57
  38. package/src/hooks/utils/db.js +0 -13
  39. package/src/hooks/utils/translation.js +0 -89
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.0.876",
3
+ "version": "1.0.883",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -1,9 +1,6 @@
1
1
  import React, {
2
2
  useState,
3
- useEffect,
4
3
  createContext,
5
- useRef,
6
- useContext,
7
4
  } from 'react';
8
5
  import { Outlet, useLocation } from 'react-router-dom';
9
6
  import {
@@ -2,10 +2,9 @@ import React from "react";
2
2
  import { AdminResetPasswordContainer } from "./index.styled";
3
3
  import bg from "./assets/images/reset_password_bg.png";
4
4
  import logo from "./assets/images/logo.png";
5
- import { Link, useNavigate } from "react-router-dom";
5
+ import { useNavigate } from "react-router-dom";
6
6
  import ButtonComponent from "../button";
7
7
  import InputComponent from "../input";
8
- import { BackArrow } from "./assets/svg/back-arrow";
9
8
 
10
9
  const AdminResetPassword = () => {
11
10
  const navigate = useNavigate();
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { AdminResetPasswordContainer } from "./index.styled";
3
3
  import bg from "./assets/images/reset_password_bg.png";
4
4
  import logo from "./assets/images/logo.png";
5
- import { Link, useNavigate } from "react-router-dom";
5
+ import { useNavigate } from "react-router-dom";
6
6
  import ButtonComponent from "../button";
7
7
  import InputComponent from "../input";
8
8
  import { BackArrow } from "./assets/svg/back-arrow";
@@ -5,7 +5,6 @@ import {
5
5
  ModalCardContainer,
6
6
  CloseModalButton,
7
7
  } from "./index.styled";
8
- import { IoMdClose } from "react-icons/io";
9
8
  import Modal from "react-modal";
10
9
  import ButtonComponent from "../../button";
11
10
  import img from "../assets/images/subtract.png"
@@ -1,16 +1,13 @@
1
1
  import React, { useState, useRef } from 'react';
2
2
  import { NavLink } from 'react-router-dom';
3
3
  import {
4
- NavigationContainer,
5
4
  SideMenuContainer,
6
- SideMenuDropdownBody,
7
- SideMenuDropdownHeader,
8
5
  NavWrapper,
9
6
  } from './index.styled';
10
- import { adminSideMenuOptions } from '../../hooks/adminSideMenuItems';
7
+ // import { adminSideMenuOptions } from '../../hooks/adminSideMenuItems';
11
8
  import logo from './assets/images/logo.png';
12
- import { ChevronIconActive } from './assets/svg/chevronIcon';
13
- import cx from 'classnames';
9
+ // import { ChevronIconActive } from './assets/svg/chevronIcon';
10
+ // import cx from 'classnames';
14
11
  import { LogoutIcon } from './assets/svg/logoutIcon';
15
12
  import {
16
13
  adminCMSItems,
@@ -2,8 +2,6 @@ import React, {
2
2
  useState,
3
3
  useEffect,
4
4
  createContext,
5
- useRef,
6
- useContext,
7
5
  } from "react";
8
6
  import { Outlet, useLocation } from "react-router-dom";
9
7
  import {
@@ -29,7 +27,6 @@ import useHeader from "../header/getHeaderDetails";
29
27
  import GracePeriod from "../deactivated";
30
28
  import MobileLayout from "../mobileLayout";
31
29
  import useTranslation from "../../hooks/useTranslation";
32
- import { preLoadWords } from "../../hooks/utils/translation";
33
30
 
34
31
  const AppMainLayout = () => {
35
32
  const [isOpen, setIsOpen] = useState(true);
@@ -100,11 +97,6 @@ const AppMainLayout = () => {
100
97
  // set access token from cookie to context
101
98
 
102
99
  useEffect(() => {
103
- try {
104
- preLoadWords();
105
- } catch (err) {
106
- console.error("Error preloading translations::", err);
107
- }
108
100
 
109
101
  let cookieValue = null;
110
102
  const cookieName = "access";
@@ -159,26 +151,38 @@ const AppMainLayout = () => {
159
151
  const currentPlan = userPlanData?.data?.current_plan;
160
152
  const planState = userPlanData?.data?.state;
161
153
 
154
+ const wordBank = [
155
+ "Sign Out",
156
+ "Learning",
157
+ "Community",
158
+ "Fun",
159
+ "Duet",
160
+ "Speech",
161
+ "Settings",
162
+ "Notifications",
163
+ "Hello",
164
+ "API",
165
+ "Documentation",
166
+ "Report",
167
+ "Created",
168
+ "Report",
169
+ ];
170
+
162
171
  const {
163
- textSchema,
164
172
  setDefaultLang,
165
173
  defaultLang,
166
174
  findText,
167
- isLoading,
168
- setIsLoading,
169
- textSchemaLoading
170
- } = useTranslation();
171
- // //console.log(findText());
175
+ translateData,
176
+ isTranslationsComplete
177
+ } = useTranslation(wordBank);
178
+
172
179
  return (
173
- !textSchemaLoading && (
180
+ !translateData?.loading && !isTranslationsComplete && (
174
181
  <OutletContext.Provider
175
182
  value={{
176
- textSchema,
177
183
  findText,
178
184
  defaultLang,
179
185
  setDefaultLang,
180
- isLoading,
181
- setIsLoading,
182
186
  setRightComponent,
183
187
  setRightLayout,
184
188
  generalData,
@@ -1,8 +1,5 @@
1
1
  import React, { useContext } from "react";
2
2
  import {
3
- AbsoluteSVG,
4
- ArrowIcon,
5
- BannerCTA,
6
3
  BannerImage,
7
4
  BannerSubtitle,
8
5
  BannerTitle,
@@ -11,14 +8,12 @@ import {
11
8
  import BannerImg from "./assets/banner.png";
12
9
  import Button from "../button";
13
10
  import { FaArrowRight } from "react-icons/fa";
14
- import { OutletContext } from "../AppMainLayout";
15
11
  import useTranslation from "../../hooks/useTranslation";
16
12
 
17
13
  const Banner = () => {
18
- const { textSchema, findText } = useTranslation();
14
+ const { findText } = useTranslation();
19
15
 
20
16
  return (
21
- textSchema && (
22
17
  <BannerWrapper>
23
18
  <BannerTitle>
24
19
  {" "}
@@ -43,7 +38,6 @@ const Banner = () => {
43
38
  }}
44
39
  />
45
40
  </BannerWrapper>
46
- )
47
41
  );
48
42
  };
49
43
 
@@ -20,7 +20,7 @@ import useTranslation from "../../hooks/useTranslation";
20
20
  *
21
21
  */
22
22
  const ButtonComponent = (props) => {
23
- const { textSchema, findText } = useTranslation();
23
+ const { findText } = useTranslation();
24
24
 
25
25
  const handleClick = useCallback((e) => {
26
26
  props.onClick && props.onClick(e);
@@ -29,7 +29,6 @@ const ButtonComponent = (props) => {
29
29
  switch (props.type) {
30
30
  case "primary":
31
31
  return (
32
- textSchema && (
33
32
  <Button
34
33
  disabled={props.disabled}
35
34
  onClick={handleClick}
@@ -75,10 +74,8 @@ const ButtonComponent = (props) => {
75
74
  )}
76
75
  </Button>
77
76
  )
78
- );
79
77
  case "secondary":
80
78
  return (
81
- textSchema && (
82
79
  <SecondaryButton
83
80
  disabled={props.disabled}
84
81
  onClick={handleClick}
@@ -123,7 +120,6 @@ const ButtonComponent = (props) => {
123
120
  )
124
121
  )}
125
122
  </SecondaryButton>
126
- )
127
123
  );
128
124
  case "tertiary":
129
125
  return (
@@ -174,7 +170,6 @@ const ButtonComponent = (props) => {
174
170
  );
175
171
  default:
176
172
  return (
177
- textSchema && (
178
173
  <Button
179
174
  disabled={props.disabled}
180
175
  onClick={handleClick}
@@ -219,7 +214,6 @@ const ButtonComponent = (props) => {
219
214
  )
220
215
  )}
221
216
  </Button>
222
- )
223
217
  );
224
218
  }
225
219
  };
@@ -1,7 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import DatePicker from 'react-datepicker';
3
3
  import { CalendarIcon } from './svg/calendar';
4
- import { DownloadIcon } from './svg/download';
5
4
  import CustomDatePickerHeader from './dateNavigation';
6
5
  import { DatePickerWrapper, DateCont } from './style';
7
6
  import moment from 'moment';
@@ -1,10 +1,7 @@
1
1
  import { useState, useEffect } from "react";
2
2
  import {
3
- CardContainer,
4
3
  CardBody,
5
- CardHeader,
6
4
  ModalCardContainer,
7
- CloseModalButton,
8
5
  ExpiryCardContainer,
9
6
  } from "./index.styled";
10
7
  import Modal from "react-modal";
@@ -12,7 +9,7 @@ import ButtonComponent from "../../button";
12
9
  import RemoveUser from "./img/removeUser.png";
13
10
  import { ErrorBookIcon } from "./img/book";
14
11
  import moment from "moment";
15
- import { toast, ToastContainer } from "react-toastify";
12
+ import { toast } from "react-toastify";
16
13
  import "react-toastify/dist/ReactToastify.css";
17
14
  import { useNavigate } from "react-router-dom";
18
15
 
@@ -103,13 +100,6 @@ const SubscriptionExpiredModal = ({
103
100
 
104
101
  const isWithin10Days = moment().add(10, "days").isSameOrBefore(expiryDate);
105
102
 
106
- if (isWithin10Days) {
107
- //console.log('Expiry date is within 10 days');
108
- } else {
109
- //console.log('Expiry date is more than 10 days away');
110
- }
111
- //console.log(isWithin10Days)
112
-
113
103
  const [daysLeft, setDaysLeft] = useState(null);
114
104
 
115
105
  useEffect(() => {
@@ -81,10 +81,9 @@ const DropDownComponent = (props) => {
81
81
  }
82
82
  }, [props.dropdownData]);
83
83
 
84
- const { textSchema, findText } = useTranslation();
84
+ const { findText } = useTranslation();
85
85
 
86
86
  return (
87
- textSchema && (
88
87
  <DropDownContainer
89
88
  className={props?.className}
90
89
  ref={dropdownRef}
@@ -165,7 +164,6 @@ const DropDownComponent = (props) => {
165
164
  )}
166
165
  </DropDownControls>
167
166
  </DropDownContainer>
168
- )
169
167
  );
170
168
  };
171
169
  export default DropDownComponent;
@@ -1,4 +1,4 @@
1
- import React, { useContext, useLayoutEffect } from "react";
1
+ import React from "react";
2
2
  import { Container } from "./style";
3
3
  import ErrorImage from "./errorPage.png";
4
4
  import ButtonComponent from "../button";
@@ -4,16 +4,8 @@ import {
4
4
  InstructorContainer,
5
5
  NewLanguage,
6
6
  RecentAdded,
7
- Container,
8
- Upgrade,
9
- Users,
10
- UploadProgressContainer,
11
7
  } from "../styles";
12
8
  import Button from "../../button";
13
- import CircularProgressBar from "../components/progressBar";
14
- import UpgradeIcon from "../assets/Feature.png";
15
- import { UploadProgress } from "../assets/uploadProgressIcon";
16
- import ProgressBar from "../../progressBar";
17
9
  import UpgradeComponent from "./upgrade";
18
10
  import LessonIcon from "../assets/lession";
19
11
  import LessonFlag from "../assets/lessonflag";
@@ -4,16 +4,8 @@ import {
4
4
  InstructorContainer,
5
5
  NewLanguage,
6
6
  RecentAdded,
7
- Container,
8
- Upgrade,
9
- Users,
10
- UploadProgressContainer
11
7
  } from "./styles";
12
8
  import Button from "../button";
13
- import CircularProgressBar from "./components/progressBar";
14
- import UpgradeIcon from "./assets/Feature.png";
15
- import { UploadProgress } from "./assets/uploadProgressIcon";
16
- import ProgressBar from "../progressBar";
17
9
  import UpgradeComponent from "./components/ugradeLock";
18
10
  import LessonIcon from "./assets/lession";
19
11
  import LessonFlag from "./assets/lessonflag";
@@ -2,13 +2,10 @@ import React from "react";
2
2
  import {
3
3
  BannerWrapper,
4
4
  Container,
5
- Upgrade,
6
- Users,
7
5
  UploadProgressContainer
8
6
  } from "./styles";
9
7
  import Button from "../button";
10
8
  import CircularProgressBar from "./components/progressBar";
11
- import UpgradeIcon from "./assets/Feature.png";
12
9
  import { UploadProgress } from "./assets/uploadProgressIcon";
13
10
  import ProgressBar from "../progressBar";
14
11
  import UpgradeComponent from "./components/ugradeLock";
@@ -4,16 +4,7 @@ import {
4
4
  InstructorContainer,
5
5
  NewLanguage,
6
6
  RecentAdded,
7
- Container,
8
- Upgrade,
9
- Users,
10
- UploadProgressContainer
11
7
  } from "../styles";
12
- import Button from "../../button";
13
- import CircularProgressBar from "../components/progressBar";
14
- import UpgradeIcon from "../assets/Feature.png";
15
- import { UploadProgress } from "../assets/uploadProgressIcon";
16
- import ProgressBar from "../../progressBar";
17
8
  import UpgradeComponent from "../components/ugradeLock";
18
9
  import LessonIcon from "../assets/lession";
19
10
  import LessonFlag from "../assets/lessonflag";
@@ -33,7 +24,7 @@ import LibraryAdImage from "../assets/libraryAd.png"
33
24
  *
34
25
  */
35
26
 
36
- const PersonalRightBar = ({UpgradeClick, CourseClick, personalReport, personalLibrary }) => {
27
+ const PersonalRightBar = ({ personalReport, personalLibrary }) => {
37
28
 
38
29
  return (
39
30
  <InstructorContainer>
@@ -1,23 +1,11 @@
1
1
  import React from "react";
2
2
  import {
3
- AbsoluteSVG,
4
- ArrowIcon,
5
- BannerCTA,
6
- BannerImage,
7
- BannerSubtitle,
8
- BannerTitle,
9
3
  BannerWrapper,
10
4
  Container,
11
- Upgrade,
12
- Users,
13
5
  UploadProgressContainer
14
6
  } from "./styles";
15
- import BannerImg from "./assets/banner.png";
16
7
  import Button from "../button";
17
- import { FaArrowRight } from "react-icons/fa";
18
8
  import CircularProgressBar from "./components/progressBar";
19
- import UpgradeIcon from "./assets/Feature.png";
20
- import UploadOwner from "./assets/uploadOwner.png";
21
9
  import { UploadProgress } from "./assets/uploadProgressIcon";
22
10
  import ProgressBar from "../progressBar";
23
11
  import UsersList from "./components/users";
@@ -1,25 +1,9 @@
1
1
  import React from "react";
2
2
  import {
3
- AbsoluteSVG,
4
- ArrowIcon,
5
- BannerCTA,
6
- BannerImage,
7
- BannerSubtitle,
8
- BannerTitle,
9
3
  BannerWrapper,
10
4
  Container,
11
- Upgrade,
12
- Users,
13
- UploadProgressContainer
14
5
  } from "./styles";
15
- import BannerImg from "./assets/banner.png";
16
- import Button from "../button";
17
- import { FaArrowRight } from "react-icons/fa";
18
6
  import CircularProgressBar from "./components/progressBar";
19
- import UpgradeIcon from "./assets/Feature.png";
20
- import UploadOwner from "./assets/uploadOwner.png";
21
- import { UploadProgress } from "./assets/uploadProgressIcon";
22
- import ProgressBar from "../progressBar";
23
7
  import UpgradeComponent from "./components/ugradeLock";
24
8
 
25
9
 
@@ -1,23 +1,10 @@
1
1
  import React from "react";
2
2
  import {
3
- AbsoluteSVG,
4
- ArrowIcon,
5
- BannerCTA,
6
- BannerImage,
7
- BannerSubtitle,
8
- BannerTitle,
9
3
  BannerWrapper,
10
4
  Container,
11
- Upgrade,
12
- Users,
13
- UploadProgressContainer
14
5
  } from "./styles";
15
- import BannerImg from "./assets/banner.png";
16
6
  import Button from "../button";
17
- import { FaArrowRight } from "react-icons/fa";
18
7
  import CircularProgressBar from "./components/progressBar";
19
- import UpgradeIcon from "./assets/Feature.png";
20
- import UploadOwner from "./assets/uploadOwner.png";
21
8
  import UsersList from "./components/users";
22
9
 
23
10
 
@@ -2,7 +2,6 @@ import React, { useState } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import FriendRequestCard from "../friendRequestCard";
4
4
  import { Container, Header, RequestList, SeeLessButton } from "./styles";
5
- import FriendImg from "../../../assets/friendrequest.png"
6
5
 
7
6
  const FriendRequestList = ({ friendRequests, onAdd, onDecline }) => {
8
7
  const [expanded, setExpanded] = useState(false);
@@ -1,8 +1,5 @@
1
1
  import React from 'react';
2
2
  import styled, { css } from 'styled-components';
3
- import loaderGif from './assets/first.gif';
4
- import Lottie from 'react-lottie';
5
- import defaultLoaderAnimation from './loader_3.json';
6
3
  import Loader from './loader';
7
4
 
8
5
  /**
@@ -7,7 +7,6 @@ import {
7
7
  } from "./index.styled";
8
8
  import DatePicker from "react-datepicker";
9
9
  import "react-datepicker/dist/react-datepicker.css";
10
- import moment from "moment";
11
10
  import { CalendarIcon } from "../../assets/svg/calendar";
12
11
  import { DownloadIcon } from "../../assets/svg/download";
13
12
  import GraphChart from "./graphData";
@@ -1,9 +1,6 @@
1
1
  import React, { useState, useEffect, useRef, useContext } from "react";
2
- import ReactFlagsSelect from "react-flags-select";
3
2
  import logo from "./assets/images/logo.png";
4
3
  import { BookIcon } from "./assets/svg/book";
5
- import { PeopleIcon } from "./assets/svg/people";
6
- import { MessageIcon } from "./assets/svg/message";
7
4
  import { SettingIcon } from "./assets/svg/setting";
8
5
  import { SearchIcon } from "./assets/svg/search";
9
6
  import {
@@ -20,7 +17,6 @@ import {
20
17
  SearchInputGroup,
21
18
  SearchInput,
22
19
  UserProfile,
23
- CountryFlagGroup,
24
20
  } from "./index.styled";
25
21
  import useHeader from "./getHeaderDetails";
26
22
  import { FullPageLoader, OutletContext } from "..";
@@ -28,9 +24,9 @@ import { useLocation } from "react-router-dom";
28
24
  import usFlag from "../../assets/images/usFlag.png";
29
25
  import LanguageDropdown from "./languageDropdown";
30
26
  import { getCookie } from "./getCookies";
31
- import { data } from "../GraphMap/data";
27
+ // import { data } from "../GraphMap/data";
32
28
  import { languagesData } from "./languages";
33
- import loadTranslations, { preLoadWords } from "../../hooks/utils/translation";
29
+ import useTranslation from "../../hooks/useTranslation";
34
30
  /**
35
31
  * @param {{
36
32
  * type: string,
@@ -71,14 +67,26 @@ const HeaderComponent = (props) => {
71
67
  setGeneralData,
72
68
  generalData,
73
69
  notificationMarkReadData,
74
- findText,
75
- defaultLang,
76
- isLoading,
77
- setIsLoading,
78
- setDefaultLang
79
70
  } = useContext(OutletContext);
80
71
  const [selectedAccount, setSelectedAccount] = useState();
81
72
  const { setDefaultAccount, handleSetDefaultAccount } = useHeader();
73
+ const wordBank = [
74
+ "Sign Out",
75
+ "Learning",
76
+ "Community",
77
+ "Fun",
78
+ "Duet",
79
+ "Speech",
80
+ "Settings",
81
+ "Notifications",
82
+ "Hello",
83
+ "API",
84
+ "Documentation",
85
+ "Report",
86
+ "Created",
87
+ "Report",
88
+ ];
89
+ const { findText, translateData, defaultLang, setDefaultLang } = useTranslation(wordBank);
82
90
 
83
91
  useEffect(() => {
84
92
  setIsOpen(false);
@@ -185,7 +193,6 @@ const HeaderComponent = (props) => {
185
193
  if (nextValidAccount) {
186
194
  setSelectedAccount(nextValidAccount);
187
195
  }
188
- // If there is no valid developer account, do nothing (do not set a new selected account)
189
196
  }
190
197
  }
191
198
  }, [generalData?.selectedAccount, userAccountsDetail?.data]);
@@ -407,7 +414,7 @@ const HeaderComponent = (props) => {
407
414
 
408
415
  return (
409
416
  <Navbar>
410
- {isLoading && <FullPageLoader hasBackground={true} />}
417
+ {translateData?.loading && <FullPageLoader hasBackground={true} />}
411
418
 
412
419
  <img src={logo} alt="Learngual logo" />
413
420
  <Nav
@@ -1,7 +1,7 @@
1
1
  import React, { useState, useEffect, useRef, useContext } from "react";
2
2
  import ReactFlagsSelect from "react-flags-select";
3
3
  import useHeader from "./getHeaderDetails";
4
- import { OutletContext } from "..";
4
+ import { OutletContext, useTranslation } from "..";
5
5
  import { useLocation } from "react-router-dom";
6
6
  import usFlag from "../../assets/images/usFlag.png";
7
7
  import koreanFlag from "../../assets/images/koreaFlag.png";
@@ -24,11 +24,6 @@ const LanguageDropdown = ({ languageDropdown, setLanguageDropdown }) => {
24
24
  const {
25
25
  setGeneralData,
26
26
  generalData,
27
- defaultLang,
28
- setDefaultLang,
29
- findText,
30
- isLoading,
31
- setIsLoading,
32
27
  } = useContext(OutletContext);
33
28
  const {
34
29
  retrieveUserDetailsData,
@@ -36,6 +31,7 @@ const LanguageDropdown = ({ languageDropdown, setLanguageDropdown }) => {
36
31
  updateUserAccountData,
37
32
  handleUpdateUserAccount,
38
33
  } = useHeader();
34
+ const { findText, translateData, defaultLang, setDefaultLang, handleTranslate, wordsToTranslate } = useTranslation();
39
35
 
40
36
  const languagesData = [
41
37
  {
@@ -96,9 +92,10 @@ const LanguageDropdown = ({ languageDropdown, setLanguageDropdown }) => {
96
92
  }
97
93
  setLanguageDropdown();
98
94
  setDefaultLang(item?.slug);
99
- item?.slug === defaultLang
100
- ? setIsLoading(false)
101
- : setIsLoading(true);
95
+ handleTranslate(item?.slug, wordsToTranslate)
96
+ // item?.slug === defaultLang
97
+ // ? setIsLoading(false)
98
+ // : setIsLoading(true);
102
99
  localStorage.setItem("defaultLang", JSON.stringify(item));
103
100
  console.log("general id", generalData?.defaultAccount?.id)
104
101
 
@@ -3,18 +3,16 @@ import React, {
3
3
  useEffect,
4
4
  useRef,
5
5
  useCallback,
6
- useContext,
7
6
  } from "react";
8
- import ReactFlagsSelect from "react-flags-select";
9
7
  import logo from "./assets/images/logo.png";
10
- import { Navbar2, NavGroup2, Nav2, CountryFlagGroup2 } from "./index.styled";
8
+ import { Navbar2, NavGroup2, } from "./index.styled";
11
9
  import { ArrowDownIcon } from "./assets/svg/arrow-down";
12
10
  import ButtonComponent from "../button";
13
11
  import { useLocation, useNavigate } from "react-router-dom";
14
12
  import usFlag from "../../assets/images/usFlag.png";
15
13
  import koreanFlag from "../../assets/images/koreaFlag.png";
16
- import { FullPageLoader, OutletContext } from "..";
17
- import useTranslation from "../../hooks/useTranslation";
14
+ import { FullPageLoader } from "..";
15
+ // import useTranslation from "../../hooks/useTranslation";
18
16
 
19
17
  /**
20
18
  * @param {{
@@ -51,6 +51,5 @@ export { default as AdminRolesPermissions } from "./AdminRolesPermission";
51
51
  export { default as AdminCreateRolesPermissions } from "./AdminRolesPermission/create";
52
52
  export { default as MobileLayout } from "./mobileLayout";
53
53
  export { default as useTranslation } from "../hooks/useTranslation";
54
- export { default as preLoadWords } from "../hooks/utils/translation";
55
54
  export { default as ImageComponent } from "./ImageComponent";
56
55
 
@@ -1,6 +1,5 @@
1
1
  import React, { useState, useEffect, useContext } from "react";
2
2
  import { Input, Label, ErrorMsg } from "./index.styled";
3
- import { OutletContext } from "../AppMainLayout";
4
3
  import useTranslation from "../../hooks/useTranslation";
5
4
 
6
5
  /**
@@ -19,7 +18,7 @@ import useTranslation from "../../hooks/useTranslation";
19
18
  const InputComponent = (props) => {
20
19
  const [value, setValue] = useState("");
21
20
  const [formErrors, setFormErrors] = useState(false);
22
- const { textSchema, findText } = useTranslation();
21
+ const { findText } = useTranslation();
23
22
 
24
23
  const validate = (e) => {
25
24
  if (!e.target.value) {
@@ -38,7 +37,6 @@ const InputComponent = (props) => {
38
37
  };
39
38
 
40
39
  return (
41
- textSchema && (
42
40
  <div style={props.style}>
43
41
  <Label htmlFor={props.in} style={props.customLabelStyle}>
44
42
  {findText(props.label)}
@@ -66,7 +64,6 @@ const InputComponent = (props) => {
66
64
  </ErrorMsg>
67
65
  )}
68
66
  </div>
69
- )
70
67
  );
71
68
  };
72
69
 
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect, useRef } from "react";
2
2
  import { MobileLayoutContainer } from "./index.styled";
3
- import BackArrow from "./assets/svg/backArrow";
3
+ // import BackArrow from "./assets/svg/backArrow";
4
4
  import img from "./assets/images/bg_img.png";
5
5
  import play from "./assets/images/play_store.png";
6
6
  import apple from "./assets/images/apple_store.png";
@@ -23,9 +23,8 @@ const Radio = ({
23
23
  setValue(newValue);
24
24
  onChange && onChange(newValue);
25
25
  };
26
- const { textSchema, findText } = useTranslation();
26
+ const { findText } = useTranslation();
27
27
  return (
28
- textSchema &&
29
28
  <Container direction={direction} {...props}>
30
29
  {options.map((option) => (
31
30
  <RadioWrapper key={option.value}>
@@ -8,8 +8,6 @@ import {
8
8
  SuggestionList,
9
9
  SuggestionItem,
10
10
  Container,
11
- OptionIcon,
12
- OptionIconSearch,
13
11
  } from "./styles";
14
12
  import { SearchFilterIcon } from "./svg/searchFilter";
15
13
  import { SearchSvg } from "./svg/search-normal";
@@ -10,12 +10,12 @@ import {
10
10
  NavigationContainer,
11
11
  } from "./styles";
12
12
  import { IoIosArrowBack, IoIosArrowForward } from "react-icons/io";
13
- import { CiLogout } from "react-icons/ci";
14
13
  import UserCard from "../userCard";
15
14
  import cx from "classnames";
16
15
  import InstructorRightBar from "../../fileRightBar/instructorRightBar";
17
16
  import EnterpriseRightBar from "../../fileRightBar/enterpriseRightBar";
18
17
  import { OutletContext } from "../../AppMainLayout";
18
+ import useTranslation from "../../../hooks/useTranslation";
19
19
 
20
20
  const SideMenu = ({
21
21
  user,
@@ -32,7 +32,8 @@ const SideMenu = ({
32
32
  // const [isOpen, setIsOpen] = useState(false);
33
33
  const [gracePeriod, setGracePeriod] = useState(true);
34
34
 
35
- const { setGeneralData, generalData, findText } = useContext(OutletContext);
35
+ const { setGeneralData, generalData } = useContext(OutletContext);
36
+ const { findText } = useTranslation();
36
37
  const onToggle = () => {
37
38
  setIsOpen(!isOpen);
38
39
  };
@@ -49,6 +50,7 @@ const SideMenu = ({
49
50
  generalData?.selectedAccount?.type === "PERSONAL" &&
50
51
  window.location.hostname.includes("staging");
51
52
 
53
+ // When pending delete and on staging
52
54
  const isPendingDelete =
53
55
  generalData?.selectedAccount?.pending_delete === true &&
54
56
  window.location.hostname.includes("staging");
@@ -11,12 +11,14 @@ import useHeader from "../../header/getHeaderDetails";
11
11
  import Loader from "../../loader";
12
12
  import avatar from "../../../assets/images/avatar.png";
13
13
  import { OutletContext } from "../../AppMainLayout";
14
+ import useTranslation from "../../../hooks/useTranslation";
14
15
 
15
16
  const UserCard = ({ user, isOpen }) => {
16
17
  const { handleGetUserDetails, userDetails, handleSetDefaultAccount } =
17
18
  useHeader();
18
19
  const [organizationName, setOrganizationName] = useState();
19
- const { generalData, findText } = useContext(OutletContext);
20
+ const { generalData } = useContext(OutletContext);
21
+ const { findText } = useTranslation();
20
22
  useEffect(() => {
21
23
  handleGetUserDetails();
22
24
  if (generalData?.selectedAccount) {
@@ -58,7 +60,7 @@ const UserCard = ({ user, isOpen }) => {
58
60
  }
59
61
  }
60
62
  }, [generalData]);
61
- console.log(generalData, "data");
63
+ // console.log(generalData, "data");
62
64
 
63
65
  return (
64
66
  <UserCardContainer isOpen={isOpen}>
@@ -7,15 +7,14 @@ import {
7
7
  NavWrapper,
8
8
  IconContainer,
9
9
  } from "./styles";
10
- import { CiLogout } from "react-icons/ci";
11
- import { HiOutlineLogout } from "react-icons/hi";
12
10
  import LogoutIcon from "./svg/logout";
13
11
  // import deleteCookies from "../../utils/deleteCookies";
14
12
  import Cookies from "js-cookie";
15
13
  import { OutletContext } from "../AppMainLayout";
14
+ import useTranslation from "../../hooks/useTranslation";
16
15
 
17
16
  const SideBar = ({ routes }) => {
18
- const { findText } = useContext(OutletContext);
17
+ const { findText } = useTranslation();
19
18
 
20
19
  const deleteCookies = (name) => {
21
20
  const date = new Date();
@@ -2,7 +2,7 @@ import { useCallback, useMemo, useEffect, useRef, useState } from "react";
2
2
  import BinWhite from "./assets/binWhite";
3
3
  import MoveUpDownWhite from "./assets/moveUppDownWhite";
4
4
  import "./style.scss";
5
- import { createEditor, Editor, Transforms } from "slate";
5
+ import { createEditor, Editor, } from "slate";
6
6
  import { Slate, Editable, withReact } from "slate-react";
7
7
  import DropDownComponent from "../dropdown component";
8
8
  import ButtonComponent from "../button";
@@ -1,10 +1,6 @@
1
1
  // import { useState } from "react";
2
2
  import React from "react";
3
3
  import {
4
- FaSmile,
5
- FaMicrophone,
6
- FaHeadphonesAlt,
7
- FaLanguage,
8
4
  FaChartLine,
9
5
  FaFileAlt,
10
6
  FaBook,
@@ -13,25 +9,24 @@ import {
13
9
  FaUser,
14
10
  FaCog,
15
11
  FaQuestion,
16
- FaCode,
17
12
  } from "react-icons/fa";
18
13
  // import { HiOutlineBookOpen } from "react-icons/hi";
19
- import { BsChatSquareText } from "react-icons/bs";
20
- import { MdOutlineBook } from "react-icons/md";
14
+ // import { BsChatSquareText } from "react-icons/bs";
15
+ // import { MdOutlineBook } from "react-icons/md";
21
16
  import UserImage from "../assets/images/dashboardImage.png";
22
17
  import Learning from "../assets/svg/learning";
23
18
  import { AwardIcon, AwardIconActive } from "../assets/svg/award";
24
19
  import { DocumentIcon, DocumentIconActive } from "../assets/svg/document";
25
20
  import { TeamsIcon, TeamsIconActive } from "../assets/svg/teams";
26
- import { VolumeIcon } from "../assets/svg/volume";
27
- import { BookIcon, CoursesIcon, CoursesIconActive } from "../assets/svg/book";
21
+ // import { VolumeIcon } from "../assets/svg/volume";
22
+ import { CoursesIcon, CoursesIconActive } from "../assets/svg/book";
28
23
  import { DashboardIcon, DashboardIconActive } from "../assets/svg/dashboard";
29
24
  import CommunityIcon from "../components/sideNav/svg/commIcon";
30
25
  import FunIcon from "../components/sideNav/svg/fun";
31
26
  import DuetIcon from "../components/sideNav/svg/duetIcon";
32
27
  import SpeechIcon from "../components/sideNav/svg/speechIcon";
33
28
  import DictionaryIcon from "../components/sideNav/svg/dictionaryIcon";
34
- import { MessageIcon } from "../assets/svg/message";
29
+ // import { MessageIcon } from "../assets/svg/message";
35
30
  import { MessagesIcon, MessagesIconActive } from "../assets/svg/messagesIcon";
36
31
  import {
37
32
  AnnouncementsIcon,
@@ -1,82 +1,108 @@
1
- import React, { useCallback, useContext, useEffect, useState } from "react";
2
- import loadTranslations from "./utils/translation";
3
- import { db } from "./utils/db";
4
- import { useLiveQuery } from "dexie-react-hooks";
5
- import { OutletContext } from "../components";
1
+ import React, { useCallback, useEffect, useState } from "react";
2
+ import useAxios from "axios-hooks";
6
3
 
7
- const useTranslation = () => {
8
- const screenId = btoa(window.location.href);
4
+ const useTranslation = (initialSentences = []) => {
9
5
  const value = JSON?.parse(localStorage.getItem("defaultLang"));
10
- const { generalData } = useContext(OutletContext);
11
6
 
12
7
  const [defaultLang, setDefaultLang] = useState(value?.slug ?? "en");
13
- const [isLoading, setIsLoading] = useState(false);
14
- const [textSchemaLoading, setTextSchemaLoading] = useState(true);
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;
15
11
 
16
- /**
17
- * @type {{key: string; value: string; updatedAt: string; screenId: string}[]}
18
- */
19
- const textSchema =
20
- useLiveQuery(
21
- async () => db[defaultLang?.toLowerCase()]?.toArray(),
22
- [defaultLang]
23
- ) ?? [];
24
-
25
- useEffect(() => {
26
- if (textSchema.length) {
27
- setTextSchemaLoading(false); // textSchema has been loaded, so stop loading
12
+ const findText = useCallback(
13
+ (word, kwargs = {}) => {
14
+ // Check if the word is not already translated and not already in the list to avoid duplicates
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
+ });
28
23
  }
29
- }, [textSchema]);
24
+ return formatSentence(translations[word] || word, kwargs); // Return translated word or original word if not yet translated
25
+ },
26
+ [translations, wordsToTranslate]
27
+ );
30
28
 
31
- const findText = useCallback(
32
- (str, kwarg = {}) => {
33
- if (!str) return "";
34
- // add text to db if not exist
35
- db.words.add({
36
- text: str,
37
- screenId,
38
- updatedAt: new Date().toDateString(),
29
+ // api request for sending data to backend
30
+ const [{ ...translateData }, translate] = useAxios(
31
+ {
32
+ method: "POST",
33
+ },
34
+ {
35
+ manual: true,
36
+ }
37
+ );
38
+
39
+ const handleTranslate = async (language, words) => {
40
+ try {
41
+ await translate({
42
+ url: `/iam/v1/utils/translate/`,
43
+ data: {
44
+ language,
45
+ sentences: words,
46
+ // kwargs,
47
+ },
48
+ params: {},
39
49
  });
50
+ } catch (err) {
51
+ console.log(err);
52
+ }
53
+ };
40
54
 
41
- if (Object.keys(kwarg).length) {
42
- db.kwarg.bulkPut(
43
- Object.keys(kwarg).map((x) => ({ key: x, value: kwarg[x], screenId }))
44
- );
45
- }
46
- const schema = textSchema?.reduce(
47
- (x, y) => ({ ...x, [y.key]: y.value }),
48
- {}
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
49
60
  );
50
- if (schema[str]) {
51
- return schema[str];
52
- } else {
53
- return formatSentence(str, kwarg);
54
- }
55
- },
56
- [textSchema, defaultLang]
57
- );
61
+ setWordsToTranslate((prevWords) => [
62
+ ...prevWords,
63
+ ...uniqueSentences.filter((word) => !prevWords.includes(word)),
64
+ ]);
65
+ }
66
+ }, []);
58
67
 
59
68
  useEffect(() => {
60
- loadTranslations(defaultLang, setIsLoading);
61
- }, [defaultLang]);
69
+ if (wordsToTranslate?.length > 0) {
70
+ handleTranslate(defaultLang, wordsToTranslate);
71
+ // setWordsToTranslate([]); // Clear the list after translating
72
+ }
73
+ }, [defaultLang, wordsToTranslate]);
74
+
75
+ useEffect(() => {
76
+ if (translateData?.response) {
77
+
78
+ const newTranslations = {};
79
+ wordsToTranslate.forEach((word, index) => {
80
+ newTranslations[word] = translateData?.data?.result[index];
81
+ });
82
+ setTranslations((prevTranslations) => ({
83
+ ...prevTranslations,
84
+ ...newTranslations,
85
+ }));
86
+ }
87
+ }, [translateData?.response]);
88
+
62
89
 
63
90
  return {
64
- textSchema,
65
- // setTextSchema,
66
- setDefaultLang,
67
91
  defaultLang,
92
+ setDefaultLang,
93
+ translateData,
94
+ handleTranslate,
95
+ translations,
68
96
  findText,
69
- isLoading,
70
- setIsLoading,
71
- textSchemaLoading,
72
- setTextSchemaLoading
97
+ wordsToTranslate,
98
+ isTranslationsComplete,
73
99
  };
74
100
  };
75
101
 
76
102
  export function formatSentence(sentence, kwargs) {
77
103
  // console.log(sentence);
78
104
  // Use replace with a regular expression and a callback function
79
- const finalSentence = sentence.replace(/\{(\w+)\}/g, (match, key) => {
105
+ const finalSentence = sentence?.replace(/\{(\w+)\}/g, (match, key) => {
80
106
  // If the key exists in kwargs, replace it with the corresponding value
81
107
  // Otherwise, keep the original placeholder
82
108
  return kwargs[key] !== undefined ? kwargs[key] : match;
@@ -84,4 +110,5 @@ export function formatSentence(sentence, kwargs) {
84
110
 
85
111
  return finalSentence;
86
112
  }
113
+
87
114
  export default useTranslation;
@@ -1,13 +0,0 @@
1
- import Dexie from "dexie";
2
- import locale from "iso-639-1";
3
- export const db = new Dexie("translations");
4
-
5
- const languages = locale.getAllCodes();
6
- db.version(2).stores({
7
- kwarg: "&key, value, screenId",
8
- ...languages.reduce(
9
- (x, y) => ({ ...x, [y]: "&key, value, screenId, updatedAt" }),
10
- {}
11
- ),
12
- words: "&text, screenId, updatedAt",
13
- });
@@ -1,89 +0,0 @@
1
- import { db } from "./db";
2
- import axios from "./axiosConfig";
3
-
4
- async function loadTranslations(language = "en", setIsLoading) {
5
- await new Promise((resolve) => {
6
- //check if loading else resolve
7
- if (document.readyState === "complete") {
8
- return resolve();
9
- }
10
- window.addEventListener("load", resolve);
11
- });
12
-
13
- const screenId = btoa(window.location.href);
14
-
15
- /**
16
- * @typedef {{text: string; screenId: string; updatedAt: string}} WORDS
17
- * @type {WORDS[]}
18
- */
19
- const words = await db.words.toArray();
20
- const texts = words.map((x) => x.text.trim() !== "" && x.text).filter((x) => x); // list of texts
21
-
22
- /**
23
- * @typedef {{ key: string; value: string; screenId: string }} Kwarg
24
- * @type {Kwarg[]} kwargList
25
- */
26
- const kwargList = await db.kwarg.where({ screenId }).toArray();
27
- const kwargs = kwargList.reduce((x, t) => ({ ...x, [t.key]: t.value }), {});
28
- /**
29
- * @type {{ data: {has_translated: boolean; result: string[]} }}
30
- */
31
-
32
- try {
33
- const res = await axios({
34
- url: "/iam/v1/utils/translate/",
35
- method: "POST",
36
- data: {
37
- language,
38
- sentences: texts,
39
- kwargs,
40
- },
41
- // params: {},
42
- });
43
- // build an object using texts as key and results from request as value
44
- if (!res.data) return {}; // somehow data was not found
45
- const translations = texts.reduce(
46
- (x, y, z) => ({ ...x, [y]: res.data.result[z] }),
47
- {}
48
- );
49
- db[language].bulkPut(
50
- Object.keys(translations).map((x, i) => ({
51
- key: texts[i],
52
- value: translations[x],
53
- screenId,
54
- updatedAt: new Date().toDateString(),
55
- }))
56
- );
57
-
58
- return translations;
59
- } catch (error) {
60
- console.error("clg Error fetching data:", error);
61
- } finally {
62
- setIsLoading(false);
63
- }
64
- }
65
-
66
- export function extractBracedText(text) {
67
- const pattern = /\{([^}]+)\}/g; // Match all occurrences of text within {}
68
- const matches = text.match(pattern);
69
- return matches ? matches.map((match) => match.slice(1, -1)) : []; // Remove braces
70
- }
71
-
72
- export async function preLoadWords(cb) {
73
- const screenId = btoa(window.location.href);
74
- const updatedAt = new Date().toDateString();
75
- const response = await axios({
76
- url: "iam/v1/utils/translations/",
77
- });
78
- /**
79
- * @type {{[key: string]: string }}
80
- */
81
- const data = response.data;
82
- db.words.bulkPut(
83
- Object?.keys(data).map((x) => ({ text: x, screenId, updatedAt }))
84
- );
85
- if (typeof cb === "function") cb(data);
86
- return true;
87
- }
88
-
89
- export default loadTranslations;