l-min-components 1.0.647 → 1.0.652

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.647",
3
+ "version": "1.0.652",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -25,6 +25,7 @@ import InstructorAccountSwitcher from "../instructorAccountSwitcher";
25
25
  import InstructorRightBar from "../fileRightBar/instructorRightBar";
26
26
  import EnterpriseRightBar from "../fileRightBar/enterpriseRightBar";
27
27
  import PersonalRightBar from "../fileRightBar/personalRightBar";
28
+ import useHeader from "../header/getHeaderDetails";
28
29
 
29
30
  const AppMainLayout = () => {
30
31
  const [isOpen, setIsOpen] = useState(true);
@@ -46,6 +47,7 @@ const AppMainLayout = () => {
46
47
  const [affiliatesActive, setAffiliatesActive] = useState(false);
47
48
  const [accessToken, setAccessToken] = useState("");
48
49
  const [envType, setEnvType] = useState("");
50
+ const { setDefaultAccount, handleSetDefaultAccount } = useHeader();
49
51
 
50
52
  useEffect(() => {
51
53
  if (window.location.host.includes("coming")) {
@@ -71,21 +73,42 @@ const AppMainLayout = () => {
71
73
  }, [defaultAcct]);
72
74
 
73
75
  // set access token from cookie to context
76
+
74
77
  useEffect(() => {
75
78
  let cookieValue = null;
76
79
  const cookieName = "access";
80
+
77
81
  // Retrieve the value of the cookie
82
+
78
83
  const cookies = document.cookie.split(";");
79
84
  for (let i = 0; i < cookies.length; i++) {
80
85
  const cookie = cookies[i].trim();
81
86
  if (cookie.startsWith(cookieName + "=")) {
82
87
  cookieValue = cookie.substring(cookieName.length + 1);
83
- setDefaultAcct(cookieValue);
88
+ setAccessToken(cookieValue);
84
89
  break;
85
90
  }
86
91
  }
87
- setAccessToken(cookieValue);
88
- }, [defaultAcct]);
92
+ }, []);
93
+
94
+ // get current account and set as default acct on page load.
95
+
96
+ useEffect(() => {
97
+ let cookieValue = null;
98
+ const cookieName = "defaultAccountID";
99
+
100
+ // Retrieve the value of the cookie
101
+
102
+ const cookies = document.cookie.split(";");
103
+ for (let i = 0; i < cookies.length; i++) {
104
+ const cookie = cookies[i].trim();
105
+ if (cookie.startsWith(cookieName + "=")) {
106
+ cookieValue = cookie.substring(cookieName.length + 1);
107
+ handleSetDefaultAccount(cookieValue);
108
+ break;
109
+ }
110
+ }
111
+ }, []);
89
112
 
90
113
  // setting current environment type
91
114
  useEffect(() => {
@@ -97,7 +120,7 @@ const AppMainLayout = () => {
97
120
  setEnvType("live");
98
121
  }
99
122
  }, []);
100
- console.log("envType", envType)
123
+ console.log("envType", envType);
101
124
 
102
125
  return (
103
126
  <OutletContext.Provider
@@ -124,7 +147,7 @@ const AppMainLayout = () => {
124
147
  setHideAffilicates,
125
148
  affiliatesActive,
126
149
  accessToken,
127
- envType
150
+ envType,
128
151
  }}
129
152
  >
130
153
  <Layout
@@ -149,7 +172,8 @@ const AppMainLayout = () => {
149
172
  ? "personal"
150
173
  : window.location.pathname.includes("instructor")
151
174
  ? "instructor"
152
- : window.location.pathname.includes("developer") || window.location.hostname.includes("developer")
175
+ : window.location.pathname.includes("developer") ||
176
+ window.location.hostname.includes("developer")
153
177
  ? "developer"
154
178
  : defaultAcct
155
179
  }
@@ -187,7 +211,7 @@ const AppMainLayout = () => {
187
211
  ) : window.location.pathname.includes("personal/courses") ? (
188
212
  <InstructorRightBar personal />
189
213
  ) : window.location.pathname.includes(
190
- "personal/library/selectlanguage",
214
+ "personal/library/selectlanguage"
191
215
  ) ? (
192
216
  <InstructorRightBar personal />
193
217
  ) : window.location.pathname.includes("personal/library") ? (
@@ -30,3 +30,33 @@ export const NotificationIcon = ({ width, height, fill }) => (
30
30
  <circle cx="17.1797" cy="5" r="4.5" fill="#F39B33" stroke="white" />
31
31
  </svg>
32
32
  );
33
+ export const NotificationEmptyIcon = ({ width, height, fill }) => (
34
+ <svg
35
+ width={width || "23"}
36
+ height={height || "23"}
37
+ viewBox="0 0 23 23"
38
+ fill="none"
39
+ xmlns="http://www.w3.org/2000/svg">
40
+ <path
41
+ d="M10.891 3.59375C7.94042 3.59375 5.54254 5.99163 5.54254 8.94218V11.5183C5.54254 12.0621 5.31077 12.8911 5.03444 13.3546L4.00932 15.0572C3.37642 16.1091 3.81321 17.2768 4.97204 17.669C8.814 18.9527 12.959 18.9527 16.801 17.669C17.8796 17.3125 18.352 16.0378 17.7637 15.0572L16.7386 13.3546C16.4712 12.8911 16.2394 12.0621 16.2394 11.5183V8.94218C16.2394 6.00055 13.8326 3.59375 10.891 3.59375Z"
42
+ stroke="#4A4D4D"
43
+ strokeWidth="1.5"
44
+ strokeMiterlimit="10"
45
+ strokeLinecap="round"
46
+ />
47
+ <path
48
+ d="M12.5404 3.85266C12.2641 3.77244 11.9788 3.71004 11.6846 3.67438C10.8289 3.56741 10.0088 3.62981 9.24219 3.85266C9.5007 3.19302 10.1425 2.72949 10.8913 2.72949C11.6401 2.72949 12.2819 3.19302 12.5404 3.85266Z"
49
+ stroke="#4A4D4D"
50
+ strokeWidth="1.5"
51
+ strokeMiterlimit="10"
52
+ strokeLinecap="round"
53
+ strokeLinejoin="round"
54
+ />
55
+ <path
56
+ d="M13.5672 17.9902C13.5672 19.4611 12.3638 20.6645 10.893 20.6645C10.162 20.6645 9.48455 20.3614 9.00319 19.88C8.52183 19.3987 8.21875 18.7212 8.21875 17.9902"
57
+ stroke="#4A4D4D"
58
+ strokeWidth="1.5"
59
+ strokeMiterlimit="10"
60
+ />
61
+ </svg>
62
+ );
@@ -68,6 +68,27 @@ const useHeader = () => {
68
68
  console.log(err);
69
69
  }
70
70
  };
71
+ const [{ ...unreadNotificationData }, getUnreadNotification] = useAxios(
72
+ {
73
+ method: "GET",
74
+ },
75
+ {
76
+ manual: true,
77
+ }
78
+ );
79
+
80
+ const handleGetUnreadNotification = async (read = false) => {
81
+ try {
82
+ await getUnreadNotification({
83
+ url: `/notify/v1/notifications/`,
84
+ params: {
85
+ read: read,
86
+ },
87
+ });
88
+ } catch (err) {
89
+ console.log(err);
90
+ }
91
+ };
71
92
 
72
93
  return {
73
94
  handleGetUserDetails,
@@ -78,6 +99,8 @@ const useHeader = () => {
78
99
  getDefaultAccount,
79
100
  handleSetDefaultAccount,
80
101
  setDefaultAccount,
102
+ unreadNotificationData,
103
+ handleGetUnreadNotification
81
104
  };
82
105
  };
83
106
  export default useHeader;
@@ -6,7 +6,7 @@ import { PeopleIcon } from "./assets/svg/people";
6
6
  import { MessageIcon } from "./assets/svg/message";
7
7
  import { SettingIcon } from "./assets/svg/setting";
8
8
  import { SearchIcon } from "./assets/svg/search";
9
- import { NotificationIcon } from "./assets/svg/notification";
9
+ import { NotificationEmptyIcon, NotificationIcon } from "./assets/svg/notification";
10
10
  import { ArrowDownIcon } from "./assets/svg/arrow-down";
11
11
  import AccountDropdown from "./account-dropdown";
12
12
  import avatar from "./assets/images/avatar.png";
@@ -48,6 +48,8 @@ const HeaderComponent = (props) => {
48
48
  userDetails,
49
49
  getDefaultAccount,
50
50
  handleGetDefaultAccount,
51
+ unreadNotificationData,
52
+ handleGetUnreadNotification
51
53
  } = useHeader();
52
54
  const { pathname } = useLocation();
53
55
  const { setGeneralData, generalData } = useContext(OutletContext);
@@ -58,6 +60,7 @@ const HeaderComponent = (props) => {
58
60
  handleGetUserAccountsDetail();
59
61
  handleGetUserDetails();
60
62
  handleGetDefaultAccount();
63
+ handleGetUnreadNotification();
61
64
  }, []);
62
65
  useEffect(() => {
63
66
  if (userAccountsDetail?.data) {
@@ -273,11 +276,22 @@ const HeaderComponent = (props) => {
273
276
  <SettingIcon /> Settings
274
277
  </a>
275
278
  </li>
276
- {/* <li>
277
- <a href="#">
278
- <NotificationIcon /> Notifications
279
+ <li>
280
+ <a
281
+ href="https://developer-staging-01.learngual.com/notifications/"
282
+ className={
283
+ window.location.pathname.includes("notifications") ? "active" : ""
284
+ }
285
+ style={{ cursor: "pointer" }}
286
+ >
287
+ {unreadNotificationData?.data?.count > 0 ? (
288
+ <NotificationIcon />
289
+ ) : (
290
+ <NotificationEmptyIcon />
291
+ )}
292
+ Notifications
279
293
  </a>
280
- </li> */}
294
+ </li>
281
295
  </Nav>
282
296
 
283
297
  <NavGroup