l-min-components 1.0.976 → 1.0.982

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.976",
3
+ "version": "1.0.982",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -26,7 +26,7 @@ import usFlag from "../../assets/images/usFlag.png";
26
26
  import LanguageDropdown from "./languageDropdown";
27
27
  import { getCookie } from "./getCookies";
28
28
  // import { data } from "../GraphMap/data";
29
- import { languagesData } from "./languages";
29
+ import { languagesData, selectedLanguageData } from "./languages";
30
30
  import { QuestionMark } from "./assets/svg/questionMark";
31
31
 
32
32
  /**
@@ -259,10 +259,7 @@ const HeaderComponent = (props) => {
259
259
  : ".learngual.com"
260
260
  }; path=/; expires=${date.toUTCString()};`;
261
261
 
262
- localStorage.setItem(
263
- "defaultLang",
264
- JSON?.stringify(getDefaultAccount?.data?.language)
265
- );
262
+ localStorage.setItem("defaultLang", getDefaultAccount?.data?.language);
266
263
 
267
264
  setSelectedAccount(getDefaultAccount?.data);
268
265
  }
@@ -393,20 +390,7 @@ const HeaderComponent = (props) => {
393
390
  generalData?.selectedAccount?.pending_delete === true &&
394
391
  window.location.hostname.includes("staging");
395
392
 
396
- const [currentFlag, setCurrentFlag] = useState(usFlag);
397
- const value = JSON?.parse(localStorage?.getItem("defaultLang"));
398
- const currentFlagIcon = value?.flag;
399
- const selectedLanguage = languagesData?.find(
400
- (lang) => lang?.slug === props?.defaultLang
401
- );
402
-
403
- useEffect(() => {
404
- if (currentFlagIcon) {
405
- setCurrentFlag(currentFlagIcon);
406
- } else {
407
- setCurrentFlag(usFlag);
408
- }
409
- }, []);
393
+ const value = localStorage.getItem("defaultLang");
410
394
 
411
395
  return (
412
396
  <Navbar>
@@ -540,7 +524,7 @@ const HeaderComponent = (props) => {
540
524
  setIsOpen();
541
525
  }}
542
526
  >
543
- <img src={currentFlag || usFlag} alt="" />
527
+ <img src={selectedLanguageData[value] || usFlag} alt="" />
544
528
  <ArrowDownIcon />
545
529
  </div>
546
530
  {languageDropdown && (
@@ -10,6 +10,7 @@ import { RiCloseCircleFill } from "react-icons/ri";
10
10
  import { HiSearch } from "react-icons/hi";
11
11
  import { InputSearchIcon } from "./assets/svg/search";
12
12
  import { DebounceInput } from "react-debounce-input";
13
+ import { languagesData } from "./languages";
13
14
 
14
15
  /**
15
16
  * @param {{
@@ -37,23 +38,9 @@ const LanguageDropdown = ({
37
38
  handleUpdateUserAccount,
38
39
  } = useHeader();
39
40
 
40
- const languagesData = [
41
- {
42
- name: "English",
43
- flag: usFlag,
44
- slug: "en",
45
- },
46
- {
47
- name: "Korean",
48
- flag: koreanFlag,
49
- slug: "ko",
50
- },
51
- ];
52
41
  const [filteredData, setFilteredData] = useState([]);
53
42
  const [isSearch, setIsSearch] = useState(false);
54
43
  const containerRef = useRef(null);
55
- const value = JSON?.parse(localStorage.getItem("defaultLang"));
56
- const currentFlag = value?.flag;
57
44
 
58
45
  const handleFilter = (event) => {
59
46
  const searchWord = event.target.value;
@@ -99,7 +86,7 @@ const LanguageDropdown = ({
99
86
  item?.slug === defaultLang
100
87
  ? setIsTranslationsLoading(false)
101
88
  : setIsTranslationsLoading(true);
102
- localStorage.setItem("defaultLang", JSON?.stringify(item));
89
+ localStorage.setItem("defaultLang", (item?.slug));
103
90
  window.location.reload();
104
91
  };
105
92
 
@@ -12,4 +12,9 @@ export const languagesData = [
12
12
  flag: koreanFlag,
13
13
  slug: "ko",
14
14
  },
15
- ];
15
+ ];
16
+
17
+ export const selectedLanguageData = {
18
+ en: usFlag,
19
+ ko: koreanFlag
20
+ }
@@ -7,6 +7,7 @@ import { useLocation, useNavigate } from "react-router-dom";
7
7
  import usFlag from "../../assets/images/usFlag.png";
8
8
  import koreanFlag from "../../assets/images/koreaFlag.png";
9
9
  import { FullPageLoader } from "..";
10
+ import { languagesData, selectedLanguageData } from "./languages";
10
11
 
11
12
  /**
12
13
  * @param {{
@@ -22,9 +23,9 @@ const HeaderComponentTwo = (props) => {
22
23
  const [isOpen, setIsOpen] = useState(false);
23
24
  const [searchResultOpen, setSearchResultOpen] = useState(false);
24
25
  const [languageDropdown, setLanguageDropdown] = useState();
25
- const value = JSON?.parse(localStorage.getItem("defaultLang"));
26
- const currentFlag = value?.flag;
26
+ const value = localStorage.getItem("defaultLang");
27
27
 
28
+
28
29
  const navigate = useNavigate();
29
30
  const location = useLocation();
30
31
  useEffect(() => {
@@ -60,18 +61,6 @@ const HeaderComponentTwo = (props) => {
60
61
  };
61
62
  }, [setLanguageDropdown]);
62
63
 
63
- const languagesData = [
64
- {
65
- name: "English",
66
- flag: usFlag,
67
- slug: "en",
68
- },
69
- {
70
- name: "Korean",
71
- flag: koreanFlag,
72
- slug: "ko",
73
- },
74
- ];
75
64
 
76
65
  const handleLanguageChange = async (item) => {
77
66
  setLanguageDropdown();
@@ -79,7 +68,7 @@ const HeaderComponentTwo = (props) => {
79
68
  item?.slug === props.defaultLang
80
69
  ? props?.setIsTranslationsLoading(false)
81
70
  : props?.setIsTranslationsLoading(true);
82
- localStorage.setItem("defaultLang", JSON?.stringify(item));
71
+ localStorage.setItem("defaultLang", (item?.slug));
83
72
  window.location.reload();
84
73
  };
85
74
 
@@ -113,7 +102,7 @@ const HeaderComponentTwo = (props) => {
113
102
  className="drop_holder"
114
103
  onClick={() => setLanguageDropdown(!languageDropdown)}
115
104
  >
116
- <img src={currentFlag || usFlag} alt="" />
105
+ <img src={selectedLanguageData[value] || usFlag} alt="" />
117
106
  <ArrowDownIcon />
118
107
  </div>
119
108
  {languageDropdown && (
@@ -1,13 +1,21 @@
1
- import React, { useCallback, useEffect, useState } from "react";
1
+ import React, { useCallback, useContext, useEffect, useState } from "react";
2
2
  import useAxios from "axios-hooks";
3
3
 
4
4
  const useTranslation = (initialSentences = []) => {
5
- const value = JSON?.parse(localStorage?.getItem("defaultLang"));
5
+ const value = localStorage?.getItem("defaultLang");
6
6
 
7
- const [defaultLang, setDefaultLang] = useState(value?.slug ?? "en");
8
- const [translations, setTranslations] = useState({}); // returned translation from backend
9
- const [isTranslationsLoading, setIsTranslationsLoading] = useState(true)
7
+ useEffect(() => {
8
+ if (value) {
9
+ console.log("====================================");
10
+ console.log(value, "bfr");
11
+ console.log("====================================");
12
+ setDefaultLang(value);
13
+ }
14
+ }, [value]);
10
15
 
16
+ const [defaultLang, setDefaultLang] = useState(value ?? "en");
17
+ const [translations, setTranslations] = useState({}); // returned translation from backend
18
+ const [isTranslationsLoading, setIsTranslationsLoading] = useState(true);
11
19
 
12
20
  const findText = useCallback(
13
21
  (word, kwargs = {}) => {
@@ -47,9 +55,8 @@ const useTranslation = (initialSentences = []) => {
47
55
  }
48
56
  };
49
57
 
50
-
51
58
  useEffect(() => {
52
- handleTranslate(defaultLang, initialSentences);
59
+ handleTranslate(defaultLang, initialSentences);
53
60
  }, [defaultLang]);
54
61
 
55
62
  useEffect(() => {
@@ -66,13 +73,11 @@ const useTranslation = (initialSentences = []) => {
66
73
  }, [translateData?.data]);
67
74
 
68
75
  useEffect(() => {
69
-
70
- if(Object.keys(translations)?.length > 0){
71
- setIsTranslationsLoading(false)
72
- }
73
- }, [translations])
74
- console.log("translateData", translateData)
75
-
76
+ if (Object.keys(translations)?.length > 0) {
77
+ setIsTranslationsLoading(false);
78
+ }
79
+ }, [translations]);
80
+ console.log("translateData", translateData);
76
81
 
77
82
  return {
78
83
  defaultLang,
@@ -82,7 +87,7 @@ const useTranslation = (initialSentences = []) => {
82
87
  translations,
83
88
  findText,
84
89
  isTranslationsLoading,
85
- setIsTranslationsLoading
90
+ setIsTranslationsLoading,
86
91
  };
87
92
  };
88
93