-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin.html
70 lines (67 loc) · 2.09 KB
/
admin.html
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css"
/>
<link rel="stylesheet" href="login.css" />
<title>login</title>
</head>
<body>
<div class="main">
<div id="left_side">
<h1>Welcome to the world of Clothing Keeda!</h1>
<img
src="https://images.bewakoof.com/web/group-19-1617704502.png"
alt=""
/>
</div>
<div id="right_side">
<h1>Admin Page</h1>
<p>for Latest trends, exciting offers and everything Clothing Keeda!</p>
<form action="">
<input type="text" id="email" name="email" placeholder="Enter your email" required/>
<input type="text" id="password" name="password" placeholder="Enter your password" required/>
<input type="Submit" name="" id="btn" value="Continue"/>
</form>
</div>
</body>
</html>
<script>
let admin=document.querySelector("form")
admin.addEventListener("submit",myfun)
async function myfun(event){
event.preventDefault()
// console.log("Hii")
let adminObj={
email:admin.email.value,
password:admin.password.value
}
let data= await signin(adminObj)
if(data.message=="Login Success"){
localStorage.setItem("token",JSON.stringify(data.AdminToken))
window.location.href="./admin/homepage.html"
alert(data.message)
}else{
alert(data.message)
}
}
async function signin(adminObj){
try {
let result=await fetch("https://vast-lime-giraffe-wrap.cyclic.app/admin/login",{
method:"POST",
headers:{
"Content-Type":"application/json"
},
body:JSON.stringify(adminObj)
})
return await result.json()
} catch (err) {
console.log(err)
}
}
</script>