-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.html
More file actions
84 lines (69 loc) · 2.93 KB
/
signup.html
File metadata and controls
84 lines (69 loc) · 2.93 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>StuffSwap | Signup</title>
<link rel="stylesheet" href="css/signup.css">
<script src="js/auth.js"></script>
</head>
<body>
<div class="signup">
<h2>Stuff<span>Swap</span></h2>
<form>
<div class="form-container">
<div class="form">
<label for="username">Username</label><br>
<input type="text" id="username" name="username" required><br><br>
<label for="email">Email</label><br>
<input type="email" id="email" name="email" required><br><br>
<label for="password">Password</label><br>
<input type="password" id="password" name="password" required><br><br>
<label for="confirm-password">Confirm Password</label><br>
<input type="password" id="confirm-password" name="confirm-password" required><br><br>
<label for="zip-code">Zipcode</label><br>
<input type="number" id="zip-code" name="zip-code" required><br><br>
</div>
<div class="btn">
<button type="submit">Become a Swapper</button><br><br>
<img src="/assets/icons/swap_slanted.svg" alt="">
</div>
</div>
<p>Already have an account? <a href="login.html">Login</a></p>
</form>
</div>
<script>
document.addEventListener('DOMContentLoaded', async () => {
const form = document.querySelector('form')
form.addEventListener('submit', async (e) => {
e.preventDefault()
const username = document.getElementById('username').value
const email = document.getElementById('email').value
const password = document.getElementById('password').value
// Show loading state
const submitButton = form.querySelector('button[type="submit"]')
const originalText = submitButton.textContent
submitButton.textContent = 'Creating Account...'
submitButton.disabled = true
try {
console.log("Attempting to sign up user:", email)
const result = await Auth.signUp(email, password, username)
if (result.success) {
alert("Sign up successful! Please login to continue.")
window.location.href = 'login.html'
} else {
alert("Sign up failed: " + result.error)
}
} catch (error) {
console.error("Unexpected error:", error)
alert("An unexpected error occurred. Please try again or contact support.")
} finally {
// Reset button state
submitButton.textContent = originalText
submitButton.disabled = false
}
})
})
</script>
</body>
</html>