l-min-components 1.0.1018 → 1.0.1022

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.1018",
3
+ "version": "1.0.1022",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -0,0 +1,33 @@
1
+ import Cookies from "js-cookie";
2
+
3
+ const deleteCookies = (name) => {
4
+ const date = new Date();
5
+ date.setHours(date.getHours() - 1);
6
+ const { host } = window.location;
7
+ const env = host.includes("localhost")
8
+ ? "local"
9
+ : host.includes("test") || host.includes("staging")
10
+ ? "staging"
11
+ : "production";
12
+ if (env === "staging") {
13
+ Cookies.remove(name, {
14
+ domain: ".learngual.com",
15
+ expires: date,
16
+ path: "/",
17
+ });
18
+ } else if (env === "local") {
19
+ Cookies.remove(name, {
20
+ domain: ".localhost",
21
+ expires: date,
22
+ path: "/",
23
+ });
24
+ } else {
25
+ Cookies.remove(name, {
26
+ domain: ".learngual.com",
27
+ expires: date,
28
+ path: "/",
29
+ });
30
+ }
31
+ };
32
+
33
+ export default deleteCookies;
@@ -8,7 +8,7 @@ import RenewModal from "./components/renew modal";
8
8
  import useHeader from "../header/getHeaderDetails";
9
9
  import OutsideAlerter from "../outsideEventChecker";
10
10
  import FullPageLoader from "../fullPageLoader";
11
- import deleteCookies from "../../utils/deleteCookies";
11
+ import deleteCookies from "./deleteCookies";
12
12
 
13
13
  const InstructorAccountSwitcher = ({
14
14
  setAccountType,
@@ -34,6 +34,22 @@ const InstructorAccountSwitcher = ({
34
34
 
35
35
  const [dropdown, setDropdown] = useState(false);
36
36
 
37
+ const getCookie = () => {
38
+ let cookieValue = null;
39
+ const cookieName = "affiliateAccount";
40
+
41
+ const cookies = document.cookie.split(";");
42
+ for (let i = 0; i < cookies.length; i++) {
43
+ const cookie = cookies[i].trim();
44
+ if (cookie.startsWith(cookieName + "=")) {
45
+ cookieValue = cookie.substring(cookieName.length + 1);
46
+ break;
47
+ }
48
+ }
49
+
50
+ return cookieValue;
51
+ };
52
+
37
53
  const setCookie = (id) => {
38
54
  const date = new Date();
39
55
  date.setDate(date.getDate() + 20);
@@ -54,23 +70,14 @@ const InstructorAccountSwitcher = ({
54
70
  }
55
71
  } else {
56
72
  setSwitchValue(false);
57
- deleteCookies("affiliateAccount");
73
+ let cookieValue = getCookie();
74
+ if (cookieValue) deleteCookies("affiliateAccount");
58
75
  }
59
76
  window.location.href = "/instructor/dashboard";
60
77
  };
61
78
 
62
79
  useEffect(() => {
63
- let cookieValue = null;
64
- const cookieName = "affiliateAccount";
65
-
66
- const cookies = document.cookie.split(";");
67
- for (let i = 0; i < cookies.length; i++) {
68
- const cookie = cookies[i].trim();
69
- if (cookie.startsWith(cookieName + "=")) {
70
- cookieValue = cookie.substring(cookieName.length + 1);
71
- break;
72
- }
73
- }
80
+ let cookieValue = getCookie();
74
81
  if (cookieValue) {
75
82
  setSwitchValue("affiliates");
76
83
  } else {