feat: add optional email field to parent registration form

This commit is contained in:
unknown
2026-10-05 07:05:58 -06:00
parent 980d9bd11a
commit 579f6f7a34
2 changed files with 8 additions and 1 deletions
+5
View File
@@ -74,6 +74,11 @@
<input type="tel" id="regTelefono" class="login-input" placeholder="Ej: 8888-1122" required autocomplete="tel"> <input type="tel" id="regTelefono" class="login-input" placeholder="Ej: 8888-1122" required autocomplete="tel">
</div> </div>
<div class="login-form-group">
<label for="regEmail">Correo Electrónico <span style="font-size: 0.75rem; font-weight: 600; color: #64748b;">(Opcional)</span>:</label>
<input type="email" id="regEmail" class="login-input" placeholder="Ej: [email protected]" autocomplete="email">
</div>
<div class="login-form-group"> <div class="login-form-group">
<label for="regUsername">Nombre de Usuario:</label> <label for="regUsername">Nombre de Usuario:</label>
<input type="text" id="regUsername" class="login-input" placeholder="Ej: carlos_papa" required autocomplete="username"> <input type="text" id="regUsername" class="login-input" placeholder="Ej: carlos_papa" required autocomplete="username">
+3 -1
View File
@@ -173,6 +173,8 @@ async function handleRegisterPadreSubmit(event) {
if (event) event.preventDefault(); if (event) event.preventDefault();
const nombre = document.getElementById('regNombre').value.trim(); const nombre = document.getElementById('regNombre').value.trim();
const telefono = document.getElementById('regTelefono').value.trim(); const telefono = document.getElementById('regTelefono').value.trim();
const emailInput = document.getElementById('regEmail');
const email = emailInput ? emailInput.value.trim() : '';
const username = document.getElementById('regUsername').value.trim(); const username = document.getElementById('regUsername').value.trim();
const password = document.getElementById('regPassword').value.trim(); const password = document.getElementById('regPassword').value.trim();
const errorMsg = document.getElementById('registerErrorMsg'); const errorMsg = document.getElementById('registerErrorMsg');
@@ -186,7 +188,7 @@ async function handleRegisterPadreSubmit(event) {
const res = await fetch('/api/auth/register-padre', { const res = await fetch('/api/auth/register-padre', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ nombre, telefono, username, password }) body: JSON.stringify({ nombre, telefono, email, username, password })
}); });
const data = await res.json(); const data = await res.json();
if (!res.ok) throw new Error(data.error || 'Error al registrar la cuenta'); if (!res.ok) throw new Error(data.error || 'Error al registrar la cuenta');