l-min-components 1.7.1269 → 1.7.1287

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.7.1269",
3
+ "version": "1.7.1287",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -109,6 +109,7 @@ const AppMainLayout = ({ children }) => {
109
109
  } = useHeader();
110
110
 
111
111
  // get current default account and store in cookie (from api)
112
+
112
113
  useEffect(() => {
113
114
  if (getDefaultAccount?.data) {
114
115
  const date = new Date();
@@ -305,6 +306,7 @@ const AppMainLayout = ({ children }) => {
305
306
  setNewNotifications,
306
307
  notificationMarkReadData,
307
308
  handleGetNotificationMarkRead,
309
+ planState,
308
310
  }}>
309
311
  {/* display mobile layout on device width*/}
310
312
  {deviceWidth < 1200 ? (
@@ -18,6 +18,24 @@ export const Layout = styled.div`
18
18
  hasLayoutBackgroundImage ? "100%" : ""};
19
19
  background-position: ${({ hasLayoutBackgroundImage }) =>
20
20
  hasLayoutBackgroundImage ? "bottom" : ""};
21
+
22
+ scrollbar-width: thin;
23
+
24
+ min-height: 100vh;
25
+ /* "auto" or "thin" depending on browser support */
26
+ scrollbar-color: transparent transparent;
27
+
28
+ &::-webkit-scrollbar {
29
+ width: 6px;
30
+ /* adjust as needed */
31
+ background-color: transparent;
32
+ /* color value for track */
33
+ }
34
+
35
+ &::-webkit-scrollbar-thumb {
36
+ background-color: transparent;
37
+ /* color value for thumb */
38
+ }
21
39
  `;
22
40
 
23
41
  export const MainLayout = styled.div`
@@ -26,7 +44,8 @@ export const MainLayout = styled.div`
26
44
  justify-content: space-between;
27
45
  width: 100%;
28
46
  padding: 84px 20px 20px 0;
29
- max-height: 100vh;
47
+ /* max-height: 100vh; */
48
+ min-height: 100vh;
30
49
  `;
31
50
 
32
51
  export const LeftLayout = styled.div`
@@ -44,23 +63,8 @@ export const CenterLayout = styled.div`
44
63
  @media screen and (max-width: 1023px) {
45
64
  margin-right: 0;
46
65
  }
47
- overflow-y: scroll;
48
- scrollbar-width: thin;
49
- /* "auto" or "thin" depending on browser support */
50
- scrollbar-color: transparent transparent;
51
- /* color values for thumb and track */
52
66
 
53
- &::-webkit-scrollbar {
54
- width: 6px;
55
- /* adjust as needed */
56
- background-color: transparent;
57
- /* color value for track */
58
- }
59
-
60
- &::-webkit-scrollbar-thumb {
61
- background-color: transparent;
62
- /* color value for thumb */
63
- }
67
+ /* color values for thumb and track */
64
68
  `;
65
69
 
66
70
  export const RightLayout = styled.div`
@@ -50,7 +50,7 @@ const AccountDropdown = (props) => {
50
50
  // //console.log(id, "bam");
51
51
  };
52
52
 
53
- console.log(props?.selectedAccount, "selected");
53
+ // console.log(props?.selectedAccount, "selected");
54
54
 
55
55
  return (
56
56
  <>
@@ -1,4 +1,4 @@
1
- import { useContext, useEffect, useState } from "react";
1
+ import { useContext, useEffect, useMemo, useState } from "react";
2
2
  import styled from "styled-components";
3
3
  // import ExpiryModal from "./components/expiry modal";
4
4
  import Search from "../searchBar";
@@ -97,15 +97,36 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
97
97
  }
98
98
  };
99
99
 
100
- useEffect(() => {
100
+ const { accountName, planState } = useContext(OutletContext);
101
+
102
+ // handle if account does not have subscription but is an affiliate
103
+ const prioritizedAffiliateId = useMemo(() => {
104
+ let prioritizedAffiliateId = null;
105
+
101
106
  if (cookieValue) {
107
+ // Priority 1: Use cookie value if it exists
108
+ prioritizedAffiliateId = cookieValue;
109
+ } else if (
110
+ !planState && // Check for NO subscription
111
+ getAllAffiliateData?.data?.results?.length > 0 // Check if the list exists and is not empty
112
+ ) {
113
+ // Priority 2: If no cookie, no subscription, and list exists...
114
+ // Assign the ID of the *first* affiliate directly from the results array
115
+ prioritizedAffiliateId = getAllAffiliateData.data.results[0]?.id; // Optional chaining on 'id'
116
+ }
117
+ return prioritizedAffiliateId;
118
+ }, [getAllAffiliateData, planState]);
119
+
120
+ useEffect(() => {
121
+ const cookie = prioritizedAffiliateId ?? cookieValue;
122
+ if (cookie) {
102
123
  setSwitchValue("affiliates");
103
- onChange({ id: cookieValue });
124
+ onChange({ id: cookie });
104
125
  } else {
105
126
  setSwitchValue(null);
106
127
  onChange(null);
107
128
  }
108
- }, []);
129
+ }, [prioritizedAffiliateId]);
109
130
 
110
131
  useEffect(() => {
111
132
  if (getAllAffiliateData?.data?.results?.length > 0) {
@@ -133,8 +154,6 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
133
154
  }
134
155
  };
135
156
 
136
- const { accountName } = useContext(OutletContext);
137
- console.log(selectedValue, "selected..");
138
157
  return getAllAffiliateData?.data?.results?.length > 0 && !search ? (
139
158
  <>
140
159
  {(setDefaultAffiliateData?.loading ||
@@ -217,20 +236,24 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
217
236
  </AffiliatesDropDown>
218
237
  )}
219
238
  </div>
220
- <div className="btn__wrapper">
221
- <button
222
- className={switchValue !== "affiliates" ? "active" : ""}
223
- onClick={() => handleSwitch(1)}>
224
- <span>My Account</span>
225
- <span className="circle"></span>
226
- </button>
227
- <button
228
- className={switchValue === "affiliates" ? "active" : ""}
229
- onClick={() => handleSwitch(2)}>
230
- <span>Affiliates</span>
231
- <span className="circle"></span>
232
- </button>
233
- </div>
239
+ {
240
+ <div className="btn__wrapper">
241
+ {!!!prioritizedAffiliateId && (
242
+ <button
243
+ className={switchValue !== "affiliates" ? "active" : ""}
244
+ onClick={() => handleSwitch(1)}>
245
+ <span>My Account</span>
246
+ <span className="circle"></span>
247
+ </button>
248
+ )}
249
+ <button
250
+ className={switchValue === "affiliates" ? "active" : ""}
251
+ onClick={() => handleSwitch(2)}>
252
+ <span>Affiliates</span>
253
+ <span className="circle"></span>
254
+ </button>
255
+ </div>
256
+ }
234
257
  </Container>
235
258
  </>
236
259
  ) : (