diff --git a/public/css/index.css b/public/css/index.css new file mode 100644 index 0000000..d35502f --- /dev/null +++ b/public/css/index.css @@ -0,0 +1,96 @@ +/* Fondo izquierdo */ +.bg-image { + background-image: url('../img/swimming.png'); /* ajusta la ruta */ + background-size: cover; + background-position: center; + background-repeat: no-repeat; +} + +/* Suavidad en la aparición sin salto */ +.animate-fade-in { + opacity: 0; + animation: appear 0.6s ease-out forwards; +} + +@keyframes appear { + to { + opacity: 1; + } +} + +/* Títulos con azul más claro */ +.text-primary-strong { + color: #49a7ff; + font-weight: 700; +} + +/* Subtexto de sesión */ +.subtext-muted { + font-size: 1rem; + color: #6c757d; + margin-top: 10px; /* más cerca del subtítulo */ + margin-bottom: 20px; /* menos separación del formulario */ +} + +/* Formulario */ +.form-control { + border-radius: 999px; + background-color: #e3f2fd; + border: none; + padding: 12px 20px; + font-size: 0.95rem; +} + +.form-control:focus { + background-color: #d0e9fb; + box-shadow: none; +} + +/* Botón */ +.btn-primary { + background-color: #007BFF; + border: none; + border-radius: 999px; + padding: 10px; + font-weight: 600; + font-size: 1rem; +} + +.btn-success { + border-radius: 999px; + padding: 10px; + font-weight: 600; + font-size: 1rem; +} + +a { + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +/* Estilos ya definidos */ +#languageSelect { + border-radius: 999px; + background-color: #ffffff; + padding: 6px 12px; + font-size: 1rem; /* Aumentado */ + min-width: 100px; + padding-right: 24px; +} + +/* Fondo verde solo para inputs del formulario de registro */ +.green-input { + background-color: #e0f6e9; /* verde claro */ + border: none; + border-radius: 999px; + padding: 12px 20px; + font-size: 0.95rem; +} + +.green-input:focus { + background-color: #c4ecd7; + box-shadow: none; +} diff --git a/public/css/login.css b/public/css/login.css deleted file mode 100644 index c84005e..0000000 --- a/public/css/login.css +++ /dev/null @@ -1,68 +0,0 @@ -/* Fondo general */ -body { - background: linear-gradient(to bottom right, #e0f7fa, #f1f8ff); - font-family: 'Segoe UI', sans-serif; -} - -/* Tarjeta del login */ -.card { - border-radius: 20px; - border: none; - background-color: #ffffffee; - box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); -} - -/* Título principal */ -.card h3 { - font-weight: bold; - color: #0077b6; -} - -/* Input y botones */ -.form-control { - border-radius: 12px; - border: 1px solid #b0bec5; -} - -.form-control:focus { - border-color: #00bcd4; - box-shadow: 0 0 0 0.15rem rgba(0, 188, 212, 0.25); -} - -.btn-primary { - background-color: #0077b6; - border: none; - border-radius: 12px; - transition: background-color 0.3s ease; -} - -.btn-primary:hover { - background-color: #005f8c; -} - -/* Idioma + Enlace de registro */ -.text-center small { - font-size: 0.85rem; - color: #37474f; -} - -a { - color: #0077b6; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -/* Select de idioma */ -#languageSelect { - border-radius: 999px; - background-color: #ffffff; - padding: 2px 10px; - font-size: 0.85rem; - min-width: 90px; /* 👈 da espacio para el texto */ - padding-right: 24px; /* 👈 da espacio para la flechita */ - background-clip: padding-box; /* asegura que no se solape */ -} - diff --git a/public/img/swimming.png b/public/img/swimming.png new file mode 100644 index 0000000..c356207 Binary files /dev/null and b/public/img/swimming.png differ diff --git a/public/index.html b/public/index.html index aabae11..35166d1 100644 --- a/public/index.html +++ b/public/index.html @@ -2,46 +2,64 @@ - Iniciar Sesión - SwimArt + Bienvenido - SwimmingArt - + - + - + +
+
-
-
-

Iniciar Sesión

-
-
- - + +
+ + +
+ +
+

Bienvenidos a SwimmingArt

+

La herramienta para tus rutinas de nado sincronizado

-
- - -
- - -
- ¿No tienes cuenta? Regístrate aquí -
- - +
+
+ +
+ + + + + +

¿No tienes cuenta? Regístrate

+ + +
+ +
+
+
- + - + diff --git a/public/js/index.js b/public/js/index.js new file mode 100644 index 0000000..eabdf36 --- /dev/null +++ b/public/js/index.js @@ -0,0 +1,248 @@ +const translations = { + es: { + title: "Bienvenidos a SwimmingArt", + subtitle: "La herramienta para tus rutinas de nado sincronizado", + login_prompt: "Inicia sesión con tu cuenta para continuar", + email: "Correo electrónico", + password: "Contraseña", + forgot_password: "¿Olvidaste tu contraseña?", + login_button: "Ingresar", + no_account: "¿No tienes cuenta?", + register: "Regístrate", + create_account: "Crear cuenta de SwimmingArt", + name: "Nombre completo", + username: "Nombre de usuario", + register_email: "Correo electrónico", + register_password: "Contraseña", + role: "Rol", + language: "Idioma", + register_button: "Registrarse", + has_account: "¿Ya tienes cuenta?", + login: "Inicia sesión" + }, + en: { + title: "Welcome to SwimmingArt", + subtitle: "The tool for your synchronized swimming routines", + login_prompt: "Log in with your account to continue", + email: "Email", + password: "Password", + forgot_password: "Forgot your password?", + login_button: "Log in", + no_account: "Don't have an account?", + register: "Sign up", + create_account: "Create account in SwimmingArt", + name: "Full name", + username: "Username", + register_email: "Email", + register_password: "Password", + role: "Role", + language: "Language", + register_button: "Sign up", + has_account: "Already have an account?", + login: "Log in" + }, + fr: { + title: "Bienvenue sur SwimmingArt", + subtitle: "L’outil pour vos routines de natation synchronisée", + login_prompt: "Connectez-vous avec votre compte pour continuer", + email: "Courriel", + password: "Mot de passe", + forgot_password: "Mot de passe oublié ?", + login_button: "Connexion", + no_account: "Vous n’avez pas de compte ?", + register: "S’inscrire", + create_account: "Créer un compte sur SwimmingArt", + name: "Nom complet", + username: "Nom d'utilisateur", + register_email: "Courriel", + register_password: "Mot de passe", + role: "Rôle", + language: "Langue", + register_button: "S’inscrire", + has_account: "Vous avez déjà un compte ?", + login: "Connexion" + } +}; + +function getLoginHTML(lang) { + const t = translations[lang]; + return ` +
+

${t.title}

+

${t.subtitle}

+
+
+

${t.login_prompt}

+
+ +
+
+ +
+ + +
+

${t.no_account} ${t.register}

+
+ + +
+ `; +} + +function getRegisterHTML(lang) { + const t = translations[lang]; + return ` +
+

${t.create_account}

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+

${t.has_account} ${t.login}

+
+ + +
+ `; +} + +let currentLang = 'es'; + +function showLogin() { + document.getElementById('rightPanel').innerHTML = getLoginHTML(currentLang); + document.getElementById('languageSelect').value = currentLang; + setupLoginForm(); +} + +function showRegister() { + document.getElementById('rightPanel').innerHTML = getRegisterHTML(currentLang); + document.getElementById('languageSelect').value = currentLang; + setupRegisterForm(); +} + +function changeLanguage(lang) { + currentLang = lang; + const isLogin = document.getElementById('loginForm') !== null; + if (isLogin) { + showLogin(); + } else { + showRegister(); + } +} + +function setupLoginForm() { + const form = document.getElementById('loginForm'); + if (!form) return; + + form.addEventListener('submit', async (e) => { + e.preventDefault(); + + const email = form.querySelector('input[type="email"]').value; + const password = form.querySelector('input[type="password"]').value; + + try { + const res = await fetch('/auth/login', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ email, password }) + }); + + if (!res.ok) { + alert("Credenciales incorrectas."); + return; + } + + const data = await res.json(); + sessionStorage.setItem("userId", data.userId); + sessionStorage.setItem("role", data.role); + + if (data.role === "coach") { + window.location.href = "equipoDisponibles.html"; + } else if (data.role === "athlete") { + window.location.href = "atleta.html"; + } else { + window.location.href = "ventanaPrincipal.html"; + } + } catch (error) { + console.error("Error al iniciar sesión:", error); + alert("Error de red al intentar iniciar sesión."); + } + }); +} + +function setupRegisterForm() { + const form = document.getElementById('registerForm'); + if (!form) return; + + form.addEventListener('submit', async (e) => { + e.preventDefault(); + const data = Object.fromEntries(new FormData(form)); + try { + const response = await fetch('/auth/register', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(data) + }); + + if (response.ok) { + //alert('Registro exitoso. Ahora inicia sesión.'); + showLogin(); + } else { + const errorText = await response.text(); + alert(`Error: ${errorText}`); + } + } catch (err) { + console.error('Error de red:', err); + alert('Ocurrió un error. Intenta más tarde.'); + } + }); +} + +window.onload = () => { + showLogin(); +}; + + + \ No newline at end of file diff --git a/public/js/login.js b/public/js/login.js deleted file mode 100644 index a161ee1..0000000 --- a/public/js/login.js +++ /dev/null @@ -1,30 +0,0 @@ -document.getElementById('loginForm').addEventListener('submit', async function (e) { - e.preventDefault(); - - const email = document.getElementById('email').value; - const password = document.getElementById('password').value; - - const res = await fetch('/auth/login', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ email, password }) - }); - - if (!res.ok) { - alert("Credenciales incorrectas."); - return; - } - - const data = await res.json(); - sessionStorage.setItem("userId", data.userId); - sessionStorage.setItem("role", data.role); - - if (data.role === "coach") { - window.location.href = "equipoDisponibles.html"; - } else if (data.role === "athlete") { - window.location.href = "atleta.html"; - } else { - window.location.href = "ventanaPrincipal.html"; - } - -}); diff --git a/public/register.html b/public/register.html deleted file mode 100644 index 3cc665c..0000000 --- a/public/register.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - Registro - SwimArt - - - - - - -
-
-

Crear cuenta

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
- ¿Ya tienes cuenta? Inicia sesión -
-
-
- - - - - diff --git a/routes/auth.js b/routes/auth.js index 081b80b..541efa9 100644 --- a/routes/auth.js +++ b/routes/auth.js @@ -36,7 +36,9 @@ router.post('/register', async (req, res) => { const user = new User({ name, username, email, passwordHash, role, language }); await user.save(); - res.redirect('/index.html'); + //res.redirect('/index.html'); + res.status(200).send('Usuario registrado correctamente'); + } catch (error) { console.error('Error en registro:', error); res.status(500).send('Error interno del servidor');