-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup.html
370 lines (326 loc) · 13.5 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sign Up | TaskMaster AI</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--primary-color: #6C63FF;
--secondary-color: #3F3D56;
--accent-color: #F50057;
--text-color: #F8F9FA;
--bg-color: #121212;
--card-bg: #1E1E1E;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
line-height: 1.6;
color: var(--text-color);
background-color: var(--bg-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.signup-container {
background-color: var(--card-bg);
border-radius: 10px;
padding: 2rem;
width: 100%;
max-width: 400px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
h1 {
font-size: 2rem;
font-weight: 700;
margin-bottom: 1rem;
text-align: center;
}
.description {
text-align: center;
margin-bottom: 1.5rem;
color: #D1D5DB;
}
.google-btn {
display: flex;
align-items: center;
justify-content: center;
background-color: #4285F4;
color: white;
padding: 0.75rem;
border-radius: 5px;
text-decoration: none;
font-weight: 500;
margin-bottom: 1.5rem;
transition: background-color 0.3s ease;
}
.google-btn:hover {
background-color: #3367D6;
}
.google-icon {
margin-right: 10px;
}
.divider {
display: flex;
align-items: center;
text-align: center;
margin-bottom: 1.5rem;
}
.divider::before,
.divider::after {
content: '';
flex: 1;
border-bottom: 1px solid #4B5563;
}
.divider span {
padding: 0 10px;
color: #4B5563;
}
form {
display: flex;
flex-direction: column;
}
.form-group {
margin-bottom: 1rem;
}
label {
display: block;
margin-bottom: 0.5rem;
font-weight: 500;
}
input {
width: 100%;
padding: 0.75rem;
border: 1px solid #4B5563;
border-radius: 5px;
background-color: #374151;
color: var(--text-color);
}
.create-account-btn {
background-color: var(--accent-color);
color: var(--text-color);
padding: 0.75rem;
border: none;
border-radius: 5px;
font-weight: 600;
cursor: pointer;
transition: background-color 0.3s ease;
}
.create-account-btn:hover {
background-color: #0EA5E9;
}
.signin-link {
text-align: center;
margin-top: 1rem;
}
.signin-link a {
color: var(--primary-color);
text-decoration: none;
}
.terms {
text-align: center;
margin-top: 1rem;
font-size: 0.8rem;
color: #9CA3AF;
}
.terms a {
color: var(--primary-color);
text-decoration: none;
}
</style>
</head>
<body>
<div class="signup-container">
<h1>Sign Up</h1>
<p class="description">Create notes in minutes. Free forever. No credit card required.</p>
<a href="#" class="google-btn" id="google-login-btn">
<svg class="google-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="24px" height="24px">
<circle cx="24" cy="24" r="24" fill="white" /> <!-- Increased radius for thicker border -->
<path fill="#FFC107" d="M43.611,20.083H42V20H24v8h11.303c-1.649,4.657-6.08,8-11.303,8c-6.627,0-12-5.373-12-12c0-6.627,5.373-12,12-12c3.059,0,5.842,1.154,7.961,3.039l5.657-5.657C34.046,6.053,29.268,4,24,4C12.955,4,4,12.955,4,24c0,11.045,8.955,20,20,20c11.045,0,20-8.955,20-20C44,22.659,43.862,21.35,43.611,20.083z"/>
<path fill="#FF3D00" d="M6.306,14.691l6.571,4.819C14.655,15.108,18.961,12,24,12c3.059,0,5.842,1.154,7.961,3.039l5.657-5.657C34.046,6.053,29.268,4,24,4C16.318,4,9.656,8.337,6.306,14.691z"/>
<path fill="#4CAF50" d="M24,44c5.166,0,9.86-1.977,13.409-5.192l-6.19-5.238C29.211,35.091,26.715,36,24,36c-5.202,0-9.619-3.317-11.283-7.946l-6.522,5.025C9.505,39.556,16.227,44,24,44z"/>
<path fill="#1976D2" d="M43.611,20.083H42V20H24v8h11.303c-0.792,2.237-2.231,4.166-4.087,5.571c0.001-0.001,0.002-0.001,0.003-0.002l6.19,5.238C36.971,39.205,44,34,44,24C44,22.659,43.862,21.35,43.611,20.083z"/>
</svg>
Continue with Google
</a>
<div class="divider">
<span>OR</span>
</div>
<form id="signup-form">
<div class="form-group">
<label for="firstname">First name</label>
<input type="text" id="firstname" name="firstname" required>
</div>
<div class="form-group">
<label for="lastname">Last name</label>
<input type="text" id="lastname" name="lastname" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit" class="create-account-btn">Create Account</button>
</form>
<div class="signin-link">
<p>Already have an account? <a href="login.html">Sign In</a></p>
</div>
<div class="terms">
<p>By signing up, you agree to our <a href="#">Terms of Service</a> and <a href="privacy-policy.html">Privacy Policy</a>.</p>
</div>
</div>
<script src="https://www.gstatic.com/firebasejs/10.12.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/10.12.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/10.12.1/firebase-firestore.js"></script>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.1/firebase-app.js";
import { getAuth, signInWithEmailAndPassword, GoogleAuthProvider, signInWithPopup, onAuthStateChanged, createUserWithEmailAndPassword, updateProfile } from "https://www.gstatic.com/firebasejs/10.12.1/firebase-auth.js";
import { getFirestore, doc, setDoc, serverTimestamp } from "https://www.gstatic.com/firebasejs/10.12.1/firebase-firestore.js";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyDaMAlQRMXiDsZ4P0b06P18id3y5xBiZ1k",
authDomain: "deepworkai-c3419.firebaseapp.com",
projectId: "deepworkai-c3419",
storageBucket: "deepworkai-c3419.appspot.com",
messagingSenderId: "367439182644",
appId: "1:367439182644:web:304216430df97eff68c361"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);
// Function to save or update user data
const saveUserData = async (user, onlineStatus) => {
try {
await setDoc(doc(db, "users", user.uid), {
uid: user.uid,
email: user.email,
displayName: user.displayName || "Anonymous",
online: onlineStatus,
lastSeen: serverTimestamp() // Use server timestamp
}, { merge: true });
console.log(`User data saved and online status set to ${onlineStatus}`);
} catch (error) {
console.error("Error saving user data:", error);
}
};
// Update online status when the user is logged in
onAuthStateChanged(auth, (user) => {
if (user) {
saveUserData(user, true); // Set status to online
// Set status to offline when the tab or browser is closed
window.addEventListener('beforeunload', () => {
saveUserData(user, false); // Set status to offline
});
// Set status to offline when the user explicitly logs out
const logoutBtn = document.getElementById('logout-btn');
if (logoutBtn) {
logoutBtn.addEventListener('click', async () => {
await saveUserData(user, false);
await auth.signOut();
window.location.href = "signin.html"; // Redirect to sign-in page after logging out
});
}
}
});
// Google Sign-In
const provider = new GoogleAuthProvider();
const googleLoginBtn = document.getElementById('google-login-btn');
if (googleLoginBtn) {
googleLoginBtn.addEventListener('click', () => {
signInWithPopup(auth, provider)
.then(async (result) => {
const user = result.user;
console.log('Google Sign-In successful:', user);
// Save user data and update status
await saveUserData(user, true);
// Redirect to dashboard
window.location.href = "splashscreen.html";
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
console.error('Error with Google Sign-In:', errorCode, errorMessage);
// User-friendly error messages
let userMessage = 'An error occurred during Google Sign-In. Please try again.';
switch (errorCode) {
case 'auth/cancelled-popup-request':
case 'auth/popup-closed-by-user':
userMessage = 'Sign-in was canceled. Please try again and complete the process.';
break;
case 'auth/network-request-failed':
userMessage = 'Network error occurred. Please check your connection and try again.';
break;
case 'auth/operation-not-allowed':
userMessage = 'Google Sign-In is currently not enabled. Please contact support.';
break;
default:
userMessage = 'An unexpected error occurred. Please try again later.';
break;
}
alert(userMessage);
});
});
}
// Sign-Up Form
const signupForm = document.getElementById('signup-form');
if (signupForm) {
signupForm.addEventListener('submit', (e) => {
e.preventDefault();
const firstName = document.getElementById('firstname').value;
const lastName = document.getElementById('lastname').value;
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
createUserWithEmailAndPassword(auth, email, password)
.then(async (userCredential) => {
// Signed up
const user = userCredential.user;
const displayName = `${firstName} ${lastName}`;
// Update user's profile
await updateProfile(user, { displayName: displayName });
console.log('Sign-Up successful:', user);
// Save user data with the new user flag
await saveUserData(user, true);
// Redirect to splash screen
window.location.href = "splashscreen.html";
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
console.error('Error signing up:', errorCode, errorMessage);
// User-friendly error messages
let userMessage = 'An error occurred during sign-up. Please try again.';
switch (errorCode) {
case 'auth/email-already-in-use':
userMessage = 'This email address is already registered. Please use a different email or log in.';
break;
case 'auth/invalid-email':
userMessage = 'The email address is not valid. Please check and try again.';
break;
case 'auth/weak-password':
userMessage = 'Your password is too weak. Please use a stronger password.';
break;
case 'auth/operation-not-allowed':
userMessage = 'Sign-up is currently not allowed. Please contact support.';
break;
default:
userMessage = 'An unexpected error occurred. Please try again later.';
break;
}
alert(userMessage);
});
});
}
</script>
</body>
</html>