l-min-components 1.0.705 → 1.0.708

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.705",
3
+ "version": "1.0.708",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -49,7 +49,8 @@ const AppMainLayout = () => {
49
49
  const [accessToken, setAccessToken] = useState("");
50
50
  const [envType, setEnvType] = useState("");
51
51
  const [newNotifications, setNewNotifications] = useState([]);
52
- const [deactivated, setDeactivated] = useState(true) // testing, until we get account setup
52
+ const [deactivated, setDeactivated] = useState(true); // testing, until we get account setup
53
+ const [gracePeriod, setGracePeriod] = useState(true); // test
53
54
 
54
55
  const {
55
56
  setDefaultAccount,
@@ -58,6 +59,8 @@ const AppMainLayout = () => {
58
59
  handleGetNotificationMarkRead,
59
60
  userPlanData,
60
61
  handleGetUserPlan,
62
+ getCurrentSubscriptionData,
63
+ handleCurrentSubscription,
61
64
  } = useHeader();
62
65
 
63
66
  useEffect(() => {
@@ -134,11 +137,11 @@ const AppMainLayout = () => {
134
137
  console.log("envType", envType);
135
138
 
136
139
  useEffect(() => {
137
- handleGetUserPlan()
138
- }, [])
140
+ handleGetUserPlan();
141
+ }, []);
139
142
 
140
143
  const currentPlan = userPlanData?.data?.current_plan;
141
- const planState = userPlanData?.data?.state
144
+ const planState = userPlanData?.data?.state;
142
145
 
143
146
  return (
144
147
  <OutletContext.Provider
@@ -191,6 +194,7 @@ const AppMainLayout = () => {
191
194
  isOpen={isOpen}
192
195
  setIsOpen={setIsOpen}
193
196
  setRightComponent={setRightComponent}
197
+ planState={planState}
194
198
  />
195
199
  )}
196
200
  </>
@@ -218,7 +222,15 @@ const AppMainLayout = () => {
218
222
  />
219
223
  )}
220
224
 
221
- {window.location.pathname.includes("enterprise") && deactivated ? <GracePeriod /> : <Outlet />}
225
+ {window.location.pathname.includes("enterprise") && planState === "GRACE PERIOD" ? (
226
+ <GracePeriod
227
+ getCurrentSubscriptionData={getCurrentSubscriptionData}
228
+ handleCurrentSubscription={handleCurrentSubscription}
229
+ gracePeriod={gracePeriod}
230
+ />
231
+ ) : (
232
+ <Outlet />
233
+ )}
222
234
  </CenterLayout>
223
235
 
224
236
  {rightLayout && !coming && (
@@ -226,7 +238,7 @@ const AppMainLayout = () => {
226
238
  {rightComponent ??
227
239
  (window.location.pathname.includes("enterprise") &&
228
240
  !window.location.pathname.includes("file-manager") ? (
229
- <EnterpriseRightBar />
241
+ <EnterpriseRightBar gracePeriod={gracePeriod} setGracePeriod={setGracePeriod} planState={planState} />
230
242
  ) : window.location.pathname.includes("personal/dashboard") ? (
231
243
  <PersonalRightBar />
232
244
  ) : window.location.pathname.includes("personal/addons") ? (
@@ -1,6 +1,8 @@
1
- import React from 'react';
1
+ import React, { useState } from "react";
2
2
  import { useLocation } from "react-router-dom";
3
- import styled from 'styled-components';
3
+ import styled from "styled-components";
4
+ import SubscriptionExpiredModal from "./modal/subscription-expired-modal";
5
+ import Button from "../button";
4
6
 
5
7
  const routes = [
6
8
  { path: "dashboard", title: "Dashboard" },
@@ -12,11 +14,17 @@ const routes = [
12
14
  { path: "file-manager", title: "File Manager" },
13
15
  ];
14
16
 
15
- const GracePeriod = () => {
17
+ const GracePeriod = ({
18
+ getCurrentSubscriptionData,
19
+ handleCurrentSubscription,
20
+ gracePeriod,
21
+ }) => {
16
22
  const location = useLocation();
23
+ const [subscriptionExpiredModalIsOpen, setSubscriptionExpiredModalIsOpen] =
24
+ useState(false);
17
25
 
18
26
  const getTitleFromPath = (path) => {
19
- const route = routes.find(route => path.includes(route.path));
27
+ const route = routes.find((route) => path.includes(route.path));
20
28
  return route?.title || "Dashboard";
21
29
  };
22
30
 
@@ -25,11 +33,38 @@ const GracePeriod = () => {
25
33
  return (
26
34
  <GracePeriodWrapper>
27
35
  <h1>{pageTitle}</h1>
36
+ {!gracePeriod &&
37
+ <Expire>
38
+ <h4>Hey Enterprise, You do not have any active plan</h4>
39
+
40
+ <div
41
+ onClick={() => {
42
+ window.location.href =
43
+ "https://559staging.learngual.com/settings/payment/";
44
+ }}
45
+ >
46
+ <Button
47
+ text="Choose a Plan"
48
+ styles={{
49
+ height: "35px",
50
+ padding: "4px 20px",
51
+ fontSize: "14px",
52
+ }}
53
+ />
54
+ </div>
55
+ </Expire>
56
+ }
28
57
  <div className="gracePeriod_account">
29
58
  <div className="content">
30
59
  <p>Sorry, you can’t access your account</p>
31
60
  </div>
32
61
  </div>
62
+
63
+ <SubscriptionExpiredModal
64
+ subscriptionExpiredModalIsOpen={subscriptionExpiredModalIsOpen}
65
+ setSubscriptionExpiredModalIsOpen={setSubscriptionExpiredModalIsOpen}
66
+ getCurrentSubscriptionData={getCurrentSubscriptionData}
67
+ />
33
68
  </GracePeriodWrapper>
34
69
  );
35
70
  };
@@ -79,4 +114,24 @@ const GracePeriodWrapper = styled.div`
79
114
  }
80
115
  `;
81
116
 
117
+ const Expire = styled.div`
118
+ border-radius: 25px;
119
+ background: rgba(48, 212, 104, 0.15);
120
+ display: flex;
121
+ padding: 15px 26px;
122
+ flex-direction: column;
123
+ align-items: flex-start;
124
+ gap: 10px;
125
+ margin-bottom: 20px;
126
+
127
+ h4 {
128
+ color: var(--warning, #f39b33);
129
+ font-family: Nunito;
130
+ font-size: 16px;
131
+ font-style: normal;
132
+ font-weight: 700;
133
+ line-height: 20px; /* 125% */
134
+ }
135
+ `;
136
+
82
137
  export default GracePeriod;
@@ -0,0 +1,77 @@
1
+ export const BookIcon = ({ width, height, fill }) => (
2
+ <svg
3
+ width={width || "24"}
4
+ height={height || "25"}
5
+ viewBox="0 0 24 25"
6
+ fill="none"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ >
9
+ <path
10
+ d="M22 16.9213V4.85134C22 3.65134 21.02 2.76134 19.83 2.86134H19.77C17.67 3.04134 14.48 4.11134 12.7 5.23134L12.53 5.34134C12.24 5.52134 11.76 5.52134 11.47 5.34134L11.22 5.19134C9.44 4.08134 6.26 3.02134 4.16 2.85134C2.97 2.75134 2 3.65134 2 4.84134V16.9213C2 17.8813 2.78 18.7813 3.74 18.9013L4.03 18.9413C6.2 19.2313 9.55 20.3313 11.47 21.3813L11.51 21.4013C11.78 21.5513 12.21 21.5513 12.47 21.4013C14.39 20.3413 17.75 19.2313 19.93 18.9413L20.26 18.9013C21.22 18.7813 22 17.8813 22 16.9213Z"
11
+ stroke="white"
12
+ strokeWidth="1.5"
13
+ strokeLinecap="round"
14
+ strokeLinejoin="round"
15
+ />
16
+ <path
17
+ d="M12 5.66797V20.668"
18
+ stroke="white"
19
+ strokeWidth="1.5"
20
+ strokeLinecap="round"
21
+ strokeLinejoin="round"
22
+ />
23
+ <path
24
+ d="M7.75 8.66797H5.5"
25
+ stroke="white"
26
+ strokeWidth="1.5"
27
+ strokeLinecap="round"
28
+ strokeLinejoin="round"
29
+ />
30
+ <path
31
+ d="M8.5 11.668H5.5"
32
+ stroke="white"
33
+ strokeWidth="1.5"
34
+ strokeLinecap="round"
35
+ strokeLinejoin="round"
36
+ />
37
+ </svg>
38
+ );
39
+
40
+ export const ErrorBookIcon = ({ width, height, fill }) => (
41
+ <svg
42
+ width={width || "26"}
43
+ height={height || "26"}
44
+ viewBox="0 0 26 26"
45
+ fill="none"
46
+ xmlns="http://www.w3.org/2000/svg"
47
+ >
48
+ <path
49
+ d="M23.2422 17.6216V5.02823C23.2422 3.7762 22.2197 2.84761 20.9781 2.95195H20.9155C18.7245 3.13975 15.3961 4.25615 13.539 5.42471L13.3616 5.53948C13.059 5.72729 12.5582 5.72729 12.2556 5.53948L11.9948 5.38298C10.1376 4.22485 6.81972 3.11889 4.62866 2.94151C3.38706 2.83718 2.375 3.7762 2.375 5.0178V17.6216C2.375 18.6232 3.18882 19.5622 4.19045 19.6874L4.49302 19.7292C6.75711 20.0318 10.2524 21.1795 12.2556 22.275L12.2974 22.2958C12.5791 22.4524 13.0277 22.4524 13.299 22.2958C15.3022 21.1899 18.8079 20.0318 21.0825 19.7292L21.4268 19.6874C22.4284 19.5622 23.2422 18.6232 23.2422 17.6216Z"
50
+ stroke="#F95454"
51
+ stroke-width="1.25203"
52
+ stroke-linecap="round"
53
+ stroke-linejoin="round"
54
+ />
55
+ <path
56
+ d="M12.8125 5.88281V21.5332"
57
+ stroke="#F95454"
58
+ stroke-width="1.25203"
59
+ stroke-linecap="round"
60
+ stroke-linejoin="round"
61
+ />
62
+ <path
63
+ d="M8.371 9.01562H6.02344"
64
+ stroke="#F95454"
65
+ stroke-width="1.25203"
66
+ stroke-linecap="round"
67
+ stroke-linejoin="round"
68
+ />
69
+ <path
70
+ d="M9.15352 12.1445H6.02344"
71
+ stroke="#F95454"
72
+ stroke-width="1.25203"
73
+ stroke-linecap="round"
74
+ stroke-linejoin="round"
75
+ />
76
+ </svg>
77
+ );
@@ -0,0 +1,222 @@
1
+ import styled from "styled-components";
2
+
3
+ export const ModalCardContainer = styled.div`
4
+ /* padding: 25px; */
5
+ font-family: "Nunito";
6
+ width: 100%;
7
+ max-width: 720px;
8
+ margin-left: 40px;
9
+ `;
10
+
11
+ export const CloseModalButton = styled.div`
12
+ background-color: rgba(255, 255, 255, 1);
13
+ width: 40px;
14
+ height: 40px;
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ padding: 10px;
19
+ font-family: "Nunito";
20
+ border-radius: 50%;
21
+ margin-bottom: 8px;
22
+ margin-left: auto;
23
+ `;
24
+
25
+ export const CardContainer = styled.div`
26
+ background-color: rgba(255, 255, 255, 1);
27
+ padding: 25px;
28
+ font-family: "Nunito";
29
+ width: 100%;
30
+ max-width: 700px;
31
+ border-radius: 30px;
32
+ `;
33
+
34
+ export const CardHeader = styled.div`
35
+ width: 100%;
36
+ text-align: center;
37
+
38
+ .cancel-title {
39
+ font-size: 22px;
40
+ color: #313333;
41
+ font-weight: 700px;
42
+ margin-bottom: 30px;
43
+ }
44
+
45
+ .title-icon {
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: center;
49
+ margin-right: 20px;
50
+ border-radius: 12px;
51
+ margin: 0 auto;
52
+ }
53
+ `;
54
+
55
+ export const CardBody = styled.div`
56
+ width: 100%;
57
+ /* display: flex; */
58
+ margin: 20px auto 10px;
59
+ text-align: center;
60
+
61
+ .mdl-title {
62
+ font-size: 22px;
63
+ font-weight: 700;
64
+ color: #313333;
65
+ margin-bottom: 12px;
66
+ }
67
+
68
+ .mdld-title {
69
+ width: 370px;
70
+ font-size: 18px;
71
+ font-weight: 700;
72
+ color: #313333;
73
+ margin: 0 auto 12px;
74
+ }
75
+
76
+ .btn__footer {
77
+ display: flex;
78
+ margin-top: 30px;
79
+ justify-content: center;
80
+
81
+ button {
82
+ width: 171px;
83
+ margin: 0 20px;
84
+ }
85
+ }
86
+ `;
87
+
88
+ export const ExpiryCardContainer = styled.div`
89
+ background-color: rgba(255, 255, 255, 1);
90
+ font-family: "Nunito";
91
+ width: 100%;
92
+ max-width: 700px;
93
+ border-radius: 30px;
94
+
95
+ .expiry_modal_container {
96
+ display: flex;
97
+ /* height: 100%; */
98
+
99
+
100
+ .logo_section {
101
+ background-color: rgba(249, 84, 84, 0.2);
102
+ display: flex;
103
+ align-items: center;
104
+ justify-content: center;
105
+ padding: 25px;
106
+ width: 40%;
107
+ padding: 0 25px;
108
+ }
109
+
110
+ .expiry_details {
111
+ padding: 25px;
112
+ width: 60%;
113
+
114
+ .error-txt {
115
+ color: #f95454;
116
+ font-weight: 800;
117
+ }
118
+ .enterprise_info {
119
+ border-radius: 12px;
120
+ padding: 10px 2px;
121
+ background-color: #f5f7f7;
122
+ width: 66px;
123
+ margin-bottom: 27px;
124
+ text-align: center;
125
+ display: flex;
126
+ flex-direction: column;
127
+ justify-content: center;
128
+ p {
129
+ color: #f95454;
130
+ font-size: 12px;
131
+ font-weight: 800;
132
+ letter-spacing: 0.28px;
133
+ text-align: center;
134
+ }
135
+ }
136
+
137
+ h6 {
138
+ color: #f95454;
139
+ font-size: 20px;
140
+ font-weight: 700;
141
+ letter-spacing: 0.4px;
142
+ margin-bottom: 15px;
143
+ text-align: left;
144
+ }
145
+
146
+ p {
147
+ color: #313333;
148
+ font-size: 16px;
149
+ font-weight: 700;
150
+ letter-spacing: 0.32px;
151
+ text-align: left;
152
+ }
153
+ }
154
+
155
+ .btn__footer {
156
+ display: flex;
157
+ margin-top: 40px;
158
+ justify-content: space-between;
159
+ }
160
+ }
161
+ `;
162
+
163
+ export const NotificationCellCardContainer = styled.div`
164
+ padding: 10px 20px 20px;
165
+ background-color: rgba(255, 255, 255, 1);
166
+ font-family: "Nunito";
167
+ border-radius: 15px;
168
+
169
+ .notification_cell_container {
170
+ display: flex;
171
+
172
+ .logo_section {
173
+ display: flex;
174
+ align-items: self-start;
175
+ justify-content: center;
176
+ width: 75px;
177
+
178
+ p {
179
+ border-radius: 8px;
180
+ background: rgba(254, 191, 16, 0.1);
181
+ padding: 8px;
182
+ }
183
+ }
184
+
185
+ .nc_details {
186
+ padding-left: 15px;
187
+ .error-txt {
188
+ color: #f95454;
189
+ font-weight: 800;
190
+ font-style: italic;
191
+ }
192
+
193
+ h6 {
194
+ color: #f39b33;
195
+ font-size: 16px;
196
+ font-weight: 700;
197
+ margin-bottom: 8px;
198
+ text-align: left;
199
+ }
200
+
201
+ p {
202
+ color: #636666;
203
+ font-size: 14px;
204
+ font-weight: 700;
205
+ text-align: left;
206
+ }
207
+ }
208
+
209
+ .btn__footer {
210
+ display: flex;
211
+ margin-top: 20px;
212
+ justify-content: space-between;
213
+ }
214
+ }
215
+ `;
216
+
217
+ export const NotificationCellModalContainer = styled.div`
218
+ /* padding: 25px; */
219
+ font-family: "Nunito";
220
+ width: 100%;
221
+ max-width: 800px;
222
+ `;
@@ -0,0 +1,210 @@
1
+ import { useState, useEffect } from "react";
2
+ import {
3
+ CardContainer,
4
+ CardBody,
5
+ CardHeader,
6
+ ModalCardContainer,
7
+ CloseModalButton,
8
+ ExpiryCardContainer,
9
+ } from "./index.styled";
10
+ import Modal from "react-modal";
11
+ import ButtonComponent from "../../button";
12
+ import RemoveUser from "./img/removeUser.png"
13
+ import { ErrorBookIcon } from "./img/book";
14
+ import moment from "moment";
15
+ import { toast, ToastContainer } from "react-toastify";
16
+ import "react-toastify/dist/ReactToastify.css";
17
+ import { useNavigate } from "react-router-dom";
18
+
19
+ const SubscriptionExpiredModal = ({
20
+ subscriptionExpiredModalIsOpen,
21
+ setSubscriptionExpiredModalIsOpen,
22
+ getCurrentSubscriptionData,
23
+ }) => {
24
+ const modalCustomStyles = {
25
+ overlay: {
26
+ position: "fixed",
27
+ top: 0,
28
+ left: 0,
29
+ right: 0,
30
+ bottom: 0,
31
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
32
+ zIndex: 9999999999,
33
+ transition: "opacity 1000ms ease-in-out",
34
+ },
35
+ content: {
36
+ position: "absolute",
37
+ overflow: "auto",
38
+ WebkitOverflowScrolling: "scroll",
39
+ outline: "none",
40
+ top: "40%",
41
+ left: "50%",
42
+ right: "auto",
43
+ bottom: "auto",
44
+ marginRight: "-50%",
45
+ transform: "translate(-50%, -50%)",
46
+ borderRadius: "30px",
47
+ border: "none",
48
+ zIndex: 333333333,
49
+ background: "transparent",
50
+ width: "780px",
51
+ },
52
+ };
53
+
54
+ const navigate = useNavigate();
55
+ const [countdown, setCountdown] = useState(null);
56
+
57
+ // useEffect(() => {
58
+ // const targetDate = moment(
59
+ // getCurrentSubscriptionData?.data?.grace_period_end,
60
+ // "YYYY-MM-DD"
61
+ // );
62
+ // const interval = setInterval(() => {
63
+ // const now = moment();
64
+ // const diff = targetDate.diff(now);
65
+ // const hours = Math.floor(diff / 3600000);
66
+ // const minutes = Math.floor((diff % 3600000) / 60000);
67
+ // const seconds = Math.floor((diff % 60000) / 1000);
68
+
69
+ // if (diff <= 0) {
70
+ // setCountdown("0h - 0m - 0s");
71
+ // } else {
72
+ // setCountdown(`${hours}h - ${minutes}m - ${seconds}s`);
73
+ // }
74
+ // }, 1000);
75
+
76
+ // return () => {
77
+ // clearInterval(interval);
78
+ // };
79
+ // }, []);
80
+
81
+ const noSubError = () => {
82
+ toast.error("Error getting your subscription, please try again!");
83
+ };
84
+
85
+ const subId = getCurrentSubscriptionData?.data?.id;
86
+
87
+ const handleNavigateRenewal = () => {
88
+ const host = window.location.hostname;
89
+ const port = window.location.port ? `:${window.location.port}` : "";
90
+ const protocol = window.location.protocol;
91
+ const baseUrl = `${protocol}//${host}${port}`;
92
+ const renewalPath = "/settings/payment/details/renewal";
93
+
94
+ if (subId) {
95
+ const renewalUrl = `${baseUrl}${renewalPath}?subId=${subId}`;
96
+ window.location.href = renewalUrl;
97
+ } else {
98
+ toast.error("Error getting your subscription, please try again!");
99
+ }
100
+ };
101
+
102
+ const expiryDate = moment("2024-05-31",
103
+ "YYYY-MM-DD"); // Replace with your expiry date
104
+
105
+ const isWithin10Days = moment().add(10, 'days').isSameOrBefore(expiryDate);
106
+
107
+ if (isWithin10Days) {
108
+ console.log('Expiry date is within 10 days');
109
+ } else {
110
+ console.log('Expiry date is more than 10 days away');
111
+ }
112
+ console.log(isWithin10Days)
113
+
114
+
115
+ const [daysLeft, setDaysLeft] = useState(null);
116
+
117
+ useEffect(() => {
118
+ const targetDate = moment(expiryDate);
119
+ const now = moment();
120
+ const diff = targetDate.diff(now, 'days');
121
+
122
+ setDaysLeft(diff);
123
+ }, [expiryDate]);
124
+ console.log(daysLeft)
125
+
126
+
127
+ return (
128
+ <Modal
129
+ isOpen={subscriptionExpiredModalIsOpen}
130
+ onRequestClose={() => setSubscriptionExpiredModalIsOpen(false)}
131
+ style={modalCustomStyles}
132
+ closeTimeoutMS={1000}
133
+ ariaHideApp={false}
134
+ contentLabel="Selected Option"
135
+ shouldCloseOnOverlayClick={false}
136
+ >
137
+ <ModalCardContainer>
138
+ {/* <CloseModalButton
139
+ onClick={() => {
140
+ setSubscriptionExpiredModalIsOpen(false);
141
+ }}
142
+ >
143
+ <IoMdClose />
144
+ </CloseModalButton> */}
145
+
146
+ <ExpiryCardContainer>
147
+ <CardBody>
148
+ <div className="expiry_modal_container">
149
+ <div className="logo_section">
150
+ <img src={RemoveUser} alt="shield" />
151
+ </div>
152
+
153
+ <div className="expiry_details">
154
+ <div className="enterprise_info">
155
+ <p>
156
+ <ErrorBookIcon />
157
+ </p>
158
+ <p> Enterprise</p>
159
+ </div>
160
+
161
+ <h6>
162
+ {" "}
163
+ Your subscription to Learngual{" "}
164
+ {getCurrentSubscriptionData?.data?.plan_name} has expired{" "}
165
+ </h6>
166
+ <p>
167
+ Your students and instructors will no longer be able to access
168
+ your courses after <br />
169
+ <span className="error-txt">{countdown}</span>
170
+ </p>
171
+
172
+ <div className="btn__footer">
173
+ <ButtonComponent
174
+ text={"Select Plan"}
175
+ type="secondary"
176
+ height={40}
177
+ styles={{
178
+ fontSize: "14px",
179
+ padding: "14px 9px",
180
+ margin: 0,
181
+ backgroundColor: "transparent",
182
+ }}
183
+ onClick={() =>
184
+ (window.location.href =
185
+ "https://559staging.learngual.com/settings/payment")
186
+ }
187
+ />
188
+ <ButtonComponent
189
+ text={"Renew subscription"}
190
+ type="submit"
191
+ height={40}
192
+ styles={{
193
+ fontSize: "14px",
194
+ padding: "14px 10px",
195
+ margin: 0,
196
+ boxShadow: "0px 7px 15px rgba(254, 191, 16, 0.25)",
197
+ }}
198
+ onClick={() => handleNavigateRenewal()}
199
+ />
200
+ </div>
201
+ </div>
202
+ </div>
203
+ </CardBody>
204
+ </ExpiryCardContainer>
205
+ </ModalCardContainer>
206
+ </Modal>
207
+ );
208
+ };
209
+
210
+ export default SubscriptionExpiredModal;