forked from akhtarfaizan20/Blush-Beauty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (29 loc) · 813 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
let loginneduser = JSON.parse(localStorage.getItem("loginneduser"));
console.log(loginneduser);
let logpage = document.getElementById("logpage");
window.onload = () => {
showName();
};
let showName = () => {
if (loginneduser) {
logpage.innerText = "Hi, " + loginneduser.name;
logpage.onclick = () => {
window.location.href = "/profilepage.html";
};
} else {
logpage.innerText = "Login/Register";
logpage.onclick = () => {
window.location.href = "/loginpage.html";
};
}
};
let cart = document.querySelector("#icons>i:nth-child(2)");
cart.onclick = () => {
if (loginneduser) {
console.log(loginneduser);
window.location.href = "/cartpage.html";
} else {
alert("Login before checking into cart!");
window.location.href = "/loginpage.html";
}
};