-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
218 lines (152 loc) · 5.71 KB
/
signup.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!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/5.15.2/css/all.min.css"
integrity="sha512-HK5fgLBL+xu6dm/Ii3z4xhlSUyZgTT9tuc/hSrtw6uzJOvgRr2a9jyxxT1ely+B+xFAmJKVSTbpM/CuL7qxO8w=="
crossorigin="anonymous" />
<title>Document</title>
<link rel="stylesheet" href="styles/navbar.css">
<link rel="stylesheet" href="styles/footer.css">
<link rel="stylesheet" href="styles/normalize.css">
</head>
<style>
.create_account {
display: grid;
grid-template-columns: 46% 46%;
padding: 1%;
gap: 2%;
color: rgb(87, 84, 84);
padding: 2%;
}
.account {
margin-left: 80px;
}
.account>input {
width: 70%;
height: 14%;
border: 1px solid grey;
border-radius: 5px;
margin: 6px 20px;
}
.account>button {
width: 71.5%;
margin: 40px 20px;
height: 14%;
background-color: orange;
border-radius: 5px;
border: 1px solid orange;
color: white;
font-size: 20px;
}
.text {
font-size: large;
line-height: 25px;
}
</style>
<body>
<!-- top section -->
<div id="navbar"></div>
<div style="display: grid; grid-template-columns: 50% 50%; text-align: center; color: orange;">
<h2>NEW USER</h2>
<h2>REGISTRATION</h2>
</div>
<hr style="width: 100%; border:1px solid orange;">
<div class="create_account">
<div class="text">
<p>At Sportsjam.in, buy your favourite brand and sportsgear at great prices. Don't forget to use our welcome
gift vouchers (worth Rs.2000)* for more savings!
Register online and and enjoy the following benefits:</p>
<ul>
<li>Get Discount Vouchers, Special Promotions & Offers</li>
<li>Checkout faster while making your purchases</li>
<li>View your Order History and track your Order Status</li>
<li>Make changes to your account information or password</li>
</ul>
</div>
<div class="account">
<label>Name</label>
<input style="margin-left: 50px;" id="name" type="text" placeholder="Name" required>
<br>
<label>UserName</label>
<input style="margin-left: 20px;" id="username" type="text" placeholder="User Name" required>
<br>
<label>Mobile No</label>
<input style="margin-left: 20px;" id="mobile" type="tel" placeholder="Mobile Number" required>
<br>
<label>Email</label>
<input style="margin-left: 50px;" id="email" type="email" placeholder="Email" required>
<br>
<label> Password</label>
<input style="margin-left: 26px;" id="password" type="password" placeholder="Password" required>
<br>
<button id="RegisterBtn" style="margin-left: 90px;">Submit</button>
<p style="font-size: small; margin:-30px 0 0 100px ;">By clicking "Register" button, you confirm that you
accept our <a style="text-decoration: none;" href=""> terms and conditions.</a> </p>
</div>
</div>
<div id="footer"></div>
</body>
</html>
<script type="module">
import categories from "./categories.js"
import {navbar,createDropdown,updateCart,checkLogStatus} from "./components/navbar.js"
import footer from "./components/footer.js"
document.getElementById("navbar").innerHTML = navbar()
createDropdown(categories)
updateCart()
checkLogStatus()
document.getElementById("footer").innerHTML = footer()
document.getElementById("RegisterBtn").addEventListener("click", signUp);
var usersData = JSON.parse(localStorage.getItem("usersData")) ?? []
async function signUp() {
// e.preventDefault()
try{
let register_data = {
name:document.getElementById("name").value,
email:document.getElementById("email").value,
password:document.getElementById("password").value,
username:document.getElementById("username").value,
mobile:document.getElementById("mobile").value,
description:"sportsjam.in user",
};
register_data = JSON.stringify(register_data)
let url = `https://masai-api-mocker.herokuapp.com/auth/register`;
let response =await fetch(url,{
method:"POST",
body:register_data,
headers:{
"Content-Type":"application/json"
}
});
let data = await response.json()
if(data.error==true) {
alert("User Already exist")
} else{
window.location.href = "signin.html"
console.log(data)
}
}
catch(err) {
alert("Something went wrong")
}
}
document.getElementById("logInBtn").addEventListener("click",()=>{
let logInBtn = document.getElementById("logInBtn")
if(logInBtn.innerText=="Log Out") {
localStorage.setItem("userData",JSON.stringify({}))
window.location.reload();
} else{
window.location.href = "signin.html"
checkLogStatus()
}
})
document.getElementById("createUser").addEventListener("click",()=>{
let createUserBtn = document.getElementById("createUser");
if(createUserBtn.innerText=="Create Account") {
window.location.href = "signup.html"
}
})
</script>