l-min-components 1.0.397 → 1.0.400
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
|
@@ -43,6 +43,7 @@ const AppMainLayout = () => {
|
|
|
43
43
|
const [centerLayoutStyle, setCenterLayoutStyle] = useState({});
|
|
44
44
|
const [hideAffilicates, setHideAffilicates] = useState(false);
|
|
45
45
|
const [affiliatesActive, setAffiliatesActive] = useState(false);
|
|
46
|
+
const [accessToken, setAccessToken] = useState("");
|
|
46
47
|
|
|
47
48
|
useEffect(() => {
|
|
48
49
|
if (window.location.host.includes("coming")) {
|
|
@@ -67,6 +68,23 @@ const AppMainLayout = () => {
|
|
|
67
68
|
}
|
|
68
69
|
}, [defaultAcct]);
|
|
69
70
|
|
|
71
|
+
// set access token from cookie to context
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
let cookieValue = null;
|
|
74
|
+
const cookieName = "access";
|
|
75
|
+
// Retrieve the value of the cookie
|
|
76
|
+
const cookies = document.cookie.split(";");
|
|
77
|
+
for (let i = 0; i < cookies.length; i++) {
|
|
78
|
+
const cookie = cookies[i].trim();
|
|
79
|
+
if (cookie.startsWith(cookieName + "=")) {
|
|
80
|
+
cookieValue = cookie.substring(cookieName.length + 1);
|
|
81
|
+
setDefaultAcct(cookieValue);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
setAccessToken(cookieValue)
|
|
86
|
+
}, [defaultAcct]);
|
|
87
|
+
|
|
70
88
|
return (
|
|
71
89
|
<OutletContext.Provider
|
|
72
90
|
value={{
|
|
@@ -91,6 +109,7 @@ const AppMainLayout = () => {
|
|
|
91
109
|
// return true if instructor affiliates is Active
|
|
92
110
|
setHideAffilicates,
|
|
93
111
|
affiliatesActive,
|
|
112
|
+
accessToken
|
|
94
113
|
}}
|
|
95
114
|
>
|
|
96
115
|
<Layout
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef, useContext } from "react";
|
|
2
|
+
import ReactFlagsSelect from "react-flags-select";
|
|
3
|
+
import useHeader from "./getHeaderDetails";
|
|
4
|
+
import { OutletContext } from "..";
|
|
5
|
+
import { useLocation } from "react-router-dom";
|
|
6
|
+
import usFlag from "../../assets/images/usFlag.png";
|
|
7
|
+
/**
|
|
8
|
+
* @param {{
|
|
9
|
+
* type: string,
|
|
10
|
+
* text: string,
|
|
11
|
+
* onClick: Function,
|
|
12
|
+
* style: CSSProperties,
|
|
13
|
+
* }} props - properties of Header Component
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
const LanguageDropdown = (props) => {
|
|
17
|
+
const [languageDropdown, setLanguageDropdown] = useState();
|
|
18
|
+
const { pathname } = useLocation();
|
|
19
|
+
const { setGeneralData, generalData } = useContext(OutletContext);
|
|
20
|
+
|
|
21
|
+
const containerRef = useRef(null);
|
|
22
|
+
|
|
23
|
+
// logic for closing language dropdown when clicking outside
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const handleClickOutside = (event) => {
|
|
26
|
+
if (
|
|
27
|
+
containerRef.current &&
|
|
28
|
+
!containerRef.current.contains(event.target)
|
|
29
|
+
) {
|
|
30
|
+
setLanguageDropdown();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
document.addEventListener("click", handleClickOutside);
|
|
35
|
+
|
|
36
|
+
return () => {
|
|
37
|
+
document.removeEventListener("click", handleClickOutside);
|
|
38
|
+
};
|
|
39
|
+
}, [setLanguageDropdown]);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<ul className="dropdown_list" ref={containerRef}>
|
|
44
|
+
<li onClick={() => setLanguageDropdown()}>
|
|
45
|
+
<img src={usFlag} alt="" /> <span>English</span>
|
|
46
|
+
</li>
|
|
47
|
+
</ul>
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default LanguageDropdown;
|