l-min-components 1.6.1271 → 1.6.1273

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.6.1271",
3
+ "version": "1.6.1273",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, createContext } from "react";
1
+ import React, { useState, useEffect, createContext, useMemo } from "react";
2
2
  import { Outlet, useLocation } from "react-router-dom";
3
3
  import {
4
4
  Layout,
@@ -42,13 +42,11 @@ const AppMainLayout = ({ children }) => {
42
42
  const [sideMenuLayout, setSideMenuLayout] = useState(true);
43
43
  const [defaultAcct, setDefaultAcct] = useState("");
44
44
  const [centerLayoutStyle, setCenterLayoutStyle] = useState({});
45
- const [hideAffilicates, setHideAffilicates] = useState(false);
46
45
  const [affiliatesActive, setAffiliatesActive] = useState(false);
47
46
  const [accessToken, setAccessToken] = useState("");
48
47
  const [envType, setEnvType] = useState("");
49
48
  const [newNotifications, setNewNotifications] = useState([]);
50
49
  const [affiliateAccount, setAffiliateAccount] = useState(null);
51
- const [deactivated, setDeactivated] = useState(true); // testing, until we get account setup
52
50
  const [gracePeriod, setGracePeriod] = useState(true); // test
53
51
  const [deviceWidth, setDeviceWidth] = useState(window.innerWidth);
54
52
  const [newLoadingForPostDefaultAccount, setNewLoadingForPostDefaultAccount] =
@@ -69,6 +67,34 @@ const AppMainLayout = ({ children }) => {
69
67
  );
70
68
  }, []);
71
69
 
70
+ // getting account name
71
+ // active account type
72
+ const activeAccountType = useMemo(
73
+ () => String(generalData?.selectedAccount?.type).toLowerCase(),
74
+ [generalData]
75
+ );
76
+ const accountName = useMemo(() => {
77
+ const { user: User, selectedAccount } = generalData;
78
+ if (!User || !selectedAccount) return "..."; // or an empty string
79
+ const defaultAccountName = String(User.first_name).concat(
80
+ " ",
81
+ User.last_name
82
+ );
83
+
84
+ switch (activeAccountType) {
85
+ case "enterprise":
86
+ return selectedAccount.metadata.organization_name ?? defaultAccountName;
87
+ case "developer":
88
+ return (
89
+ selectedAccount.metadata.organization_name ??
90
+ selectedAccount.metadata.org_name ??
91
+ defaultAccountName
92
+ );
93
+ default:
94
+ return defaultAccountName;
95
+ }
96
+ }, [generalData]);
97
+ console.log(activeAccountType, "activeAccountType");
72
98
  const {
73
99
  setDefaultAccount,
74
100
  handleSetDefaultAccount,
@@ -119,8 +145,8 @@ const AppMainLayout = ({ children }) => {
119
145
  if (setDefaultAccount?.data) {
120
146
  if (
121
147
  setDefaultAccount?.response?.status === 207 &&
122
- (!window.location.host.includes("staging") &&
123
- !window.location.host.includes("local"))
148
+ !window.location.host.includes("staging") &&
149
+ !window.location.host.includes("local")
124
150
  ) {
125
151
  window.location.href = "/auth/account-type";
126
152
  } else {
@@ -253,6 +279,7 @@ const AppMainLayout = ({ children }) => {
253
279
  value={{
254
280
  messageKit,
255
281
  affiliateAccount,
282
+ accountName,
256
283
  setRightComponent,
257
284
  setRightLayout,
258
285
  generalData,
@@ -271,8 +298,6 @@ const AppMainLayout = ({ children }) => {
271
298
  setSelectedCourseId,
272
299
  centerLayoutStyle,
273
300
  setCenterLayoutStyle,
274
- // return true if instructor affiliates is Active
275
- setHideAffilicates,
276
301
  affiliatesActive,
277
302
  accessToken,
278
303
  envType,
@@ -280,8 +305,7 @@ const AppMainLayout = ({ children }) => {
280
305
  setNewNotifications,
281
306
  notificationMarkReadData,
282
307
  handleGetNotificationMarkRead,
283
- }}
284
- >
308
+ }}>
285
309
  {/* display mobile layout on device width*/}
286
310
  {deviceWidth < 1200 ? (
287
311
  <MobileLayout findText={findText} />
@@ -293,8 +317,7 @@ const AppMainLayout = ({ children }) => {
293
317
  ) : (
294
318
  <Layout
295
319
  coming={coming}
296
- hasLayoutBackgroundImage={hasLayoutBackgroundImage}
297
- >
320
+ hasLayoutBackgroundImage={hasLayoutBackgroundImage}>
298
321
  <HeaderComponent
299
322
  setNewNotifications={setNewNotifications}
300
323
  findText={findText}
@@ -18,25 +18,6 @@ export const Layout = styled.div`
18
18
  hasLayoutBackgroundImage ? "100%" : ""};
19
19
  background-position: ${({ hasLayoutBackgroundImage }) =>
20
20
  hasLayoutBackgroundImage ? "bottom" : ""};
21
-
22
- overflow-y: auto;
23
- scrollbar-width: thin;
24
-
25
- min-height: 100vh;
26
- /* "auto" or "thin" depending on browser support */
27
- scrollbar-color: transparent transparent;
28
-
29
- &::-webkit-scrollbar {
30
- width: 6px;
31
- /* adjust as needed */
32
- background-color: transparent;
33
- /* color value for track */
34
- }
35
-
36
- &::-webkit-scrollbar-thumb {
37
- background-color: transparent;
38
- /* color value for thumb */
39
- }
40
21
  `;
41
22
 
42
23
  export const MainLayout = styled.div`
@@ -63,8 +44,23 @@ export const CenterLayout = styled.div`
63
44
  @media screen and (max-width: 1023px) {
64
45
  margin-right: 0;
65
46
  }
66
-
47
+ overflow-y: scroll;
48
+ scrollbar-width: thin;
49
+ /* "auto" or "thin" depending on browser support */
50
+ scrollbar-color: transparent transparent;
67
51
  /* color values for thumb and track */
52
+
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
+ }
68
64
  `;
69
65
 
70
66
  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
  <>
@@ -132,8 +132,7 @@ const AccountDropdown = (props) => {
132
132
  handleRedirectFunc(developerItem);
133
133
  }, 1000);
134
134
  }}
135
- key={idx}
136
- >
135
+ key={idx}>
137
136
  <div className="avatar-container">
138
137
  <img
139
138
  src={
@@ -179,8 +178,7 @@ const AccountDropdown = (props) => {
179
178
  handleRedirectFunc(instructorItem);
180
179
  }, 1000);
181
180
  }}
182
- key={idx}
183
- >
181
+ key={idx}>
184
182
  <div className="avatar-container">
185
183
  <img
186
184
  src={
@@ -221,8 +219,7 @@ const AccountDropdown = (props) => {
221
219
  handleRedirectFunc(enterpriseItem);
222
220
  }, 1000);
223
221
  }}
224
- key={idx}
225
- >
222
+ key={idx}>
226
223
  <div className="avatar-container">
227
224
  <img
228
225
  src={
@@ -266,8 +263,7 @@ const AccountDropdown = (props) => {
266
263
  handleRedirectFunc(personalItem);
267
264
  }, 1000);
268
265
  }}
269
- key={idx}
270
- >
266
+ key={idx}>
271
267
  <div className="avatar-container">
272
268
  <img
273
269
  src={
@@ -301,8 +297,7 @@ const AccountDropdown = (props) => {
301
297
  onClick={() => {
302
298
  window.location.href = "/auth/account-type";
303
299
  }}
304
- style={{ cursor: "pointer" }}
305
- >
300
+ style={{ cursor: "pointer" }}>
306
301
  <AddIcon /> {props.findText("Add account")}
307
302
  </button>
308
303
  </AccountDropdownFooter>
@@ -1,4 +1,5 @@
1
1
  import useAxios from "axios-hooks";
2
+ import { useEffect } from "react";
2
3
 
3
4
  const useHeader = () => {
4
5
  // get user details
@@ -332,7 +333,6 @@ const useHeader = () => {
332
333
  }
333
334
  };
334
335
 
335
-
336
336
  const [{ ...getTotalMessagesCountData }, getTotalMessagesCount] = useAxios(
337
337
  {
338
338
  method: "GET",
@@ -369,6 +369,11 @@ const useHeader = () => {
369
369
  }
370
370
  };
371
371
 
372
+ //defaults
373
+ // get user info
374
+ useEffect(() => {
375
+ handleGetUserDetails();
376
+ }, []);
372
377
 
373
378
  return {
374
379
  handleGetUserDetails,
@@ -53,6 +53,7 @@ const HeaderComponent = (props) => {
53
53
  const [languageDropdown, setLanguageDropdown] = useState();
54
54
  const [isOpen, setIsOpen] = useState(false);
55
55
  // const [searchResultOpen, setSearchResultOpen] = useState(false);
56
+ // in general data find user info and replace where user details is being used
56
57
  const {
57
58
  handleGetUserAccountsDetail,
58
59
  handleGetUserDetails,
@@ -74,7 +75,7 @@ const HeaderComponent = (props) => {
74
75
  handleSetDefaultAccount,
75
76
  } = useHeader();
76
77
  const { pathname } = useLocation();
77
- const { setGeneralData, generalData, notificationMarkReadData } =
78
+ const { setGeneralData, generalData, notificationMarkReadData, accountName } =
78
79
  useContext(OutletContext);
79
80
  const [accountType, setAccountType] = useState("");
80
81
  const currentAccountType = props?.selectedAccount?.type
@@ -420,8 +421,7 @@ const HeaderComponent = (props) => {
420
421
  onClick={() => {
421
422
  setLanguageDropdown();
422
423
  setIsOpen();
423
- }}
424
- >
424
+ }}>
425
425
  <li>
426
426
  <a className={isHomePage() ? "active" : ""}>
427
427
  {getNavLinkIcon()} {props.findText(getNavLinkLabel())}
@@ -440,8 +440,7 @@ const HeaderComponent = (props) => {
440
440
  className={
441
441
  window.location.pathname.includes("settings") ? "active" : ""
442
442
  }
443
- style={{ cursor: "pointer" }}
444
- >
443
+ style={{ cursor: "pointer" }}>
445
444
  <SettingIcon /> {props.findText("Settings")}
446
445
  </a>
447
446
  </li>
@@ -474,8 +473,7 @@ const HeaderComponent = (props) => {
474
473
  ? "disabled"
475
474
  : ""
476
475
  }
477
- style={{ cursor: isPendingDelete ? "not-allowed" : "pointer" }}
478
- >
476
+ style={{ cursor: isPendingDelete ? "not-allowed" : "pointer" }}>
479
477
  {unreadNotificationData?.data?.count > 0 ? (
480
478
  <NotificationIcon />
481
479
  ) : (
@@ -509,8 +507,7 @@ const HeaderComponent = (props) => {
509
507
  onClick={() => {
510
508
  setLanguageDropdown();
511
509
  setIsOpen();
512
- }}
513
- >
510
+ }}>
514
511
  {/* {(!isDeveloper || !window.location.hostname.includes("coming")) && ( // when developer and on staging, don't show
515
512
  <SearchInputGroup>
516
513
  <SearchIcon />
@@ -539,8 +536,7 @@ const HeaderComponent = (props) => {
539
536
  onClick={() => {
540
537
  setLanguageDropdown(!languageDropdown);
541
538
  setIsOpen();
542
- }}
543
- >
539
+ }}>
544
540
  <img src={selectedLanguageData[value] || usFlag} alt="" />
545
541
  <ArrowDownIcon />
546
542
  </div>
@@ -562,8 +558,7 @@ const HeaderComponent = (props) => {
562
558
  setIsOpen(!isOpen);
563
559
  setLanguageDropdown();
564
560
  }}
565
- ref={secondContainerRef}
566
- >
561
+ ref={secondContainerRef}>
567
562
  <div className="user-img-container">
568
563
  <img
569
564
  src={props?.selectedAccount?.profile_photo?.url || avatar}
@@ -571,10 +566,7 @@ const HeaderComponent = (props) => {
571
566
  />
572
567
  </div>
573
568
  <div className="user-info-container">
574
- <h5 style={{ textTransform: "capitalize" }}>
575
- {props?.selectedAccount?.metadata?.organization_name ||
576
- props?.selectedAccount?.display_name}
577
- </h5>
569
+ <h5 style={{ textTransform: "capitalize" }}>{accountName}</h5>
578
570
  <h6 style={{ textTransform: "capitalize" }}>
579
571
  {props?.selectedAccount?.type?.toLowerCase()}
580
572
  </h6>
@@ -1,4 +1,4 @@
1
- import { useEffect, useState } from "react";
1
+ import { useContext, useEffect, useState } from "react";
2
2
  import styled from "styled-components";
3
3
  // import ExpiryModal from "./components/expiry modal";
4
4
  import Search from "../searchBar";
@@ -9,6 +9,7 @@ import useHeader from "../header/getHeaderDetails";
9
9
  import OutsideAlerter from "../outsideEventChecker";
10
10
  import FullPageLoader from "../fullPageLoader";
11
11
  import deleteCookies from "./deleteCookies";
12
+ import { OutletContext } from "..";
12
13
 
13
14
  const InstructorAccountSwitcher = ({ generalData, onChange }) => {
14
15
  // const [expiryFlow, setExpiryFlow] = useState();
@@ -32,12 +33,14 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
32
33
  }, [generalData?.selectedAccount, search]);
33
34
 
34
35
  const dropdownList = getAllAffiliateData?.data?.results?.map((item) => {
35
- const image = item?.profile_photo?.url || item?.profile_photo[1][1];
36
- return { name: item?.display_name, image, id: item?.id };
36
+ const image = item?.profile_photo?.url;
37
+ return {
38
+ name: item?.metadata.organization_name ?? "...",
39
+ image,
40
+ id: item?.id,
41
+ };
37
42
  });
38
43
 
39
- console.log(dropdownList, getAllAffiliateData);
40
-
41
44
  const [dropdown, setDropdown] = useState(false);
42
45
 
43
46
  const getCookie = () => {
@@ -111,7 +114,7 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
111
114
  const value = res?.data;
112
115
  const image = value?.profile_photo?.url;
113
116
  setSelectedValue(() => ({
114
- name: value?.display_name,
117
+ name: value?.metadata.organization_name,
115
118
  image,
116
119
  id: value?.id,
117
120
  }));
@@ -130,6 +133,8 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
130
133
  }
131
134
  };
132
135
 
136
+ const { accountName } = useContext(OutletContext);
137
+ console.log(selectedValue, "selected..");
133
138
  return getAllAffiliateData?.data?.results?.length > 0 && !search ? (
134
139
  <>
135
140
  {(setDefaultAffiliateData?.loading ||
@@ -160,24 +165,20 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
160
165
  )} */}
161
166
  <Container className="instructor_account_switcher">
162
167
  <div className="left">
163
- {switchValue !== "affiliates" && (
164
- <p>{generalData?.selectedAccount?.display_name}</p>
165
- )}
168
+ {switchValue !== "affiliates" && <p>{accountName}</p>}
166
169
  {switchValue === "affiliates" && (
167
170
  <AffiliatesDropDown>
168
171
  {!selectedValue ? (
169
172
  <div
170
173
  className="placeholder"
171
- onClick={() => setDropdown(!dropdown)}
172
- >
174
+ onClick={() => setDropdown(!dropdown)}>
173
175
  <p>Select affiliate</p>
174
176
  <ArrowDown />
175
177
  </div>
176
178
  ) : (
177
179
  <div
178
180
  className="selected"
179
- onClick={() => setDropdown(!dropdown)}
180
- >
181
+ onClick={() => setDropdown(!dropdown)}>
181
182
  <div>
182
183
  <img src={selectedValue?.image} alt="" />
183
184
  <p>{selectedValue?.name}</p>
@@ -201,8 +202,7 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
201
202
  key={item?.id}
202
203
  onClick={() => {
203
204
  handleSelection(item);
204
- }}
205
- >
205
+ }}>
206
206
  <div className="left">
207
207
  <img src={item?.image} alt="" />
208
208
  <p>{item?.name}</p>
@@ -220,15 +220,13 @@ const InstructorAccountSwitcher = ({ generalData, onChange }) => {
220
220
  <div className="btn__wrapper">
221
221
  <button
222
222
  className={switchValue !== "affiliates" ? "active" : ""}
223
- onClick={() => handleSwitch(1)}
224
- >
223
+ onClick={() => handleSwitch(1)}>
225
224
  <span>My Account</span>
226
225
  <span className="circle"></span>
227
226
  </button>
228
227
  <button
229
228
  className={switchValue === "affiliates" ? "active" : ""}
230
- onClick={() => handleSwitch(2)}
231
- >
229
+ onClick={() => handleSwitch(2)}>
232
230
  <span>Affiliates</span>
233
231
  <span className="circle"></span>
234
232
  </button>
@@ -1,4 +1,4 @@
1
- import React, { useContext, useEffect, useState } from "react";
1
+ import React, { useContext, useEffect, useMemo, useState } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import {
4
4
  UserCardContainer,
@@ -16,7 +16,7 @@ const UserCard = ({ user, isOpen, findText }) => {
16
16
  const { handleGetUserDetails, userDetails, handleSetDefaultAccount } =
17
17
  useHeader();
18
18
  const [organizationName, setOrganizationName] = useState();
19
- const { generalData } = useContext(OutletContext);
19
+ const { generalData, accountName } = useContext(OutletContext);
20
20
 
21
21
  useEffect(() => {
22
22
  handleGetUserDetails();
@@ -59,7 +59,7 @@ const UserCard = ({ user, isOpen, findText }) => {
59
59
  }
60
60
  }
61
61
  }, [generalData]);
62
- // console.log(generalData, "data");
62
+ console.log(generalData, "data...");
63
63
 
64
64
  return (
65
65
  <UserCardContainer isOpen={isOpen}>
@@ -94,20 +94,16 @@ const UserCard = ({ user, isOpen, findText }) => {
94
94
  if (window.location.pathname.includes("instructor")) {
95
95
  window.location.href = `${window.location.protocol}//${window.location.hostname}/instructor/profile`;
96
96
  }
97
- }}
98
- >
97
+ }}>
99
98
  <UserName>{findText("Hello")}</UserName>
100
99
  <Handle
101
100
  style={{
102
101
  textTransform: "capitalize",
103
102
  fontWeight: 700,
104
103
  fontSize: 15,
105
- }}
106
- >{`${
107
- organizationName
108
- ? organizationName
109
- : generalData?.selectedAccount?.display_name ?? ""
110
- }.`}</Handle>
104
+ }}>
105
+ {accountName}
106
+ </Handle>
111
107
  </UserDetail>
112
108
  </>
113
109
  )}