l-min-components 1.0.614 → 1.0.620

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.614",
3
+ "version": "1.0.620",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -45,6 +45,7 @@ const AppMainLayout = () => {
45
45
  const [hideAffilicates, setHideAffilicates] = useState(false);
46
46
  const [affiliatesActive, setAffiliatesActive] = useState(false);
47
47
  const [accessToken, setAccessToken] = useState("");
48
+ const [envType, setEnvType] = useState("");
48
49
 
49
50
  useEffect(() => {
50
51
  if (window.location.host.includes("coming")) {
@@ -86,6 +87,18 @@ const AppMainLayout = () => {
86
87
  setAccessToken(cookieValue);
87
88
  }, [defaultAcct]);
88
89
 
90
+ // setting current environment type
91
+ useEffect(() => {
92
+ if (window.location.hostname.includes("staging")) {
93
+ setEnvType("staging");
94
+ } else if (window.location.hostname.includes("localhost")) {
95
+ setEnvType("localhost");
96
+ } else {
97
+ setEnvType("live");
98
+ }
99
+ }, []);
100
+ console.log("envType", envType)
101
+
89
102
  return (
90
103
  <OutletContext.Provider
91
104
  value={{
@@ -111,6 +124,7 @@ const AppMainLayout = () => {
111
124
  setHideAffilicates,
112
125
  affiliatesActive,
113
126
  accessToken,
127
+ envType
114
128
  }}
115
129
  >
116
130
  <Layout
@@ -9,6 +9,7 @@ import {
9
9
  } from "./index.styled";
10
10
  import { useLocation, useNavigate } from "react-router-dom";
11
11
  import useHeader from "./getHeaderDetails";
12
+ import { OutletContext } from "..";
12
13
  /**
13
14
  * @param {{
14
15
  * type: string,
@@ -24,6 +25,7 @@ const AccountDropdown = (props) => {
24
25
  const { pathname } = useLocation();
25
26
  useEffect(() => {}, [pathname]);
26
27
  const { setDefaultAccount, handleSetDefaultAccount } = useHeader();
28
+ const { envType } = useContext(OutletContext);
27
29
 
28
30
  useEffect(() => {
29
31
  if (props?.selectedAccount?.type === "DEVELOPER") {
@@ -102,6 +104,10 @@ const AccountDropdown = (props) => {
102
104
  ))}
103
105
  </div>
104
106
  )} */}
107
+
108
+
109
+ {envType === "live" &&
110
+ <>
105
111
  {props?.developerAccountData.length > 0 && (
106
112
  <div>
107
113
  <h3 style={{ marginBottom: 10 }}>Developer accounts</h3>
@@ -145,6 +151,11 @@ const AccountDropdown = (props) => {
145
151
  ))}
146
152
  </div>
147
153
  )}
154
+ </>
155
+ }
156
+
157
+ {envType === "staging" || envType === "localhost" ?
158
+ <>
148
159
  {props?.instructorAccountData?.length > 0 && (
149
160
  <div>
150
161
  <h3>Instructor account</h3>
@@ -253,6 +264,9 @@ const AccountDropdown = (props) => {
253
264
  ))}
254
265
  </div>
255
266
  )}
267
+ </> :
268
+ <></>
269
+ }
256
270
  {/* // )} */}
257
271
  </AccountDropdownBody>
258
272
 
@@ -52,6 +52,7 @@ const HeaderComponent = (props) => {
52
52
  const { pathname } = useLocation();
53
53
  const { setGeneralData, generalData } = useContext(OutletContext);
54
54
  const [selectedAccount, setSelectedAccount] = useState();
55
+ const prevAccountRef = useRef();
55
56
 
56
57
  useEffect(() => {
57
58
  setIsOpen(false);
@@ -59,6 +60,15 @@ const HeaderComponent = (props) => {
59
60
  handleGetUserDetails();
60
61
  handleGetDefaultAccount();
61
62
  }, []);
63
+
64
+ // Reload when another account is selected
65
+ useEffect(() => {
66
+ if (selectedAccount && selectedAccount !== prevAccountRef.current) {
67
+ window.location.reload();
68
+ }
69
+ prevAccountRef.current = selectedAccount;
70
+ }, [selectedAccount]);
71
+
62
72
  useEffect(() => {
63
73
  if (userAccountsDetail?.data) {
64
74
  setGeneralData((generalData) => ({
@@ -148,6 +158,15 @@ const HeaderComponent = (props) => {
148
158
  }));
149
159
  }
150
160
  }, [selectedAccount])
161
+
162
+ useEffect(()=>{
163
+ if(selectedAccount){
164
+ setGeneralData((generalData) => ({
165
+ ...generalData,
166
+ defaultAccount: getDefaultAccount?.data,
167
+ }));
168
+ }
169
+ }, [getDefaultAccount?.response])
151
170
 
152
171
  const containerRef = useRef(null);
153
172
  const secondContainerRef = useRef(null);
@@ -71,18 +71,18 @@ const SideMenu = ({
71
71
  console.log(window.location.pathname, "pathname");
72
72
  // checking developer account routes
73
73
  if (
74
- (window.location.pathname.includes("api") && path === "/") ||
75
- (window.location.pathname === "/" && path === "/")
74
+ (window.location.pathname.includes("api") && path === "/developer") ||
75
+ (window.location.pathname === "/" && path === "/developer")
76
76
  ) {
77
77
  return (statusText = true);
78
78
  }
79
79
  if (
80
80
  window.location.pathname.includes("documentation") &&
81
- path === "/documentation"
81
+ path === "/developer/documentation"
82
82
  ) {
83
83
  return (statusText = true);
84
84
  }
85
- if (window.location.pathname.includes("report") && path === "/report") {
85
+ if (window.location.pathname.includes("developer/report") && path === "/developer/report") {
86
86
  return (statusText = true);
87
87
  }
88
88