Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +17 -14
templates/index.html
CHANGED
@@ -61,7 +61,6 @@
|
|
61 |
<h2 class="text-xl font-semibold text-center mb-4">User Registration</h2>
|
62 |
<input type="text" id="name" placeholder="Full Name" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300">
|
63 |
<input type="tel" id="phone" placeholder="Phone Number" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300">
|
64 |
-
<!-- <input type="text" id="aadhar" placeholder="Aadhar Number" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300"> -->
|
65 |
<input type="text" id="state" placeholder="State" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300">
|
66 |
<input type="text" id="town" placeholder="Town/City" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300">
|
67 |
<input type="text" id="pincode" placeholder="Pincode" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300">
|
@@ -148,7 +147,6 @@
|
|
148 |
async function registerUser() {
|
149 |
const name = document.getElementById("name").value;
|
150 |
const phone = document.getElementById("phone").value;
|
151 |
-
// const aadhar = document.getElementById("aadhar").value;
|
152 |
const state = document.getElementById("state").value;
|
153 |
const town = document.getElementById("town").value;
|
154 |
const pincode = document.getElementById("pincode").value;
|
@@ -167,24 +165,29 @@ async function registerUser() {
|
|
167 |
}
|
168 |
|
169 |
// Validate password strength
|
170 |
-
if (password.length <
|
171 |
alert("Password must be at least 6 characters long!");
|
172 |
return;
|
173 |
}
|
174 |
|
175 |
try {
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
}
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
// Show success message first
|
190 |
alert("User registered successfully!");
|
|
|
61 |
<h2 class="text-xl font-semibold text-center mb-4">User Registration</h2>
|
62 |
<input type="text" id="name" placeholder="Full Name" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300">
|
63 |
<input type="tel" id="phone" placeholder="Phone Number" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300">
|
|
|
64 |
<input type="text" id="state" placeholder="State" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300">
|
65 |
<input type="text" id="town" placeholder="Town/City" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300">
|
66 |
<input type="text" id="pincode" placeholder="Pincode" class="w-full p-3 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-300">
|
|
|
147 |
async function registerUser() {
|
148 |
const name = document.getElementById("name").value;
|
149 |
const phone = document.getElementById("phone").value;
|
|
|
150 |
const state = document.getElementById("state").value;
|
151 |
const town = document.getElementById("town").value;
|
152 |
const pincode = document.getElementById("pincode").value;
|
|
|
165 |
}
|
166 |
|
167 |
// Validate password strength
|
168 |
+
if (password.length < 4) {
|
169 |
alert("Password must be at least 6 characters long!");
|
170 |
return;
|
171 |
}
|
172 |
|
173 |
try {
|
174 |
+
// Check if user already exists
|
175 |
+
const existingUserQuery = await getDocs(query(collection(db, "users"), where("phone", "==", phone)));
|
176 |
+
if (!existingUserQuery.empty) {
|
177 |
+
alert("Phone number already registered!");
|
178 |
+
return;
|
179 |
+
}
|
|
|
180 |
|
181 |
+
// Register User (save to Firestore)
|
182 |
+
await setDoc(doc(db, "users", phone), {
|
183 |
+
name: name,
|
184 |
+
phone: phone,
|
185 |
+
state: state,
|
186 |
+
town: town,
|
187 |
+
pincode: pincode,
|
188 |
+
password: password,
|
189 |
+
registeredAt: new Date().toISOString()
|
190 |
+
});
|
191 |
|
192 |
// Show success message first
|
193 |
alert("User registered successfully!");
|