diff --git a/src/app/(Administrador)/CambiarPass/page.tsx b/src/app/(Administrador)/CambiarPass/page.tsx index 7f86b63..3b4e8f7 100644 --- a/src/app/(Administrador)/CambiarPass/page.tsx +++ b/src/app/(Administrador)/CambiarPass/page.tsx @@ -4,79 +4,82 @@ import { useState } from "react"; import axios from "axios"; import { useRouter } from "next/navigation"; import toast from "react-hot-toast"; -import "../../styles/layout/ForgotPasswordPage.scss"; // ajusta ruta si tu proyecto la tiene en otro sitio +import "../../styles/layout/ForgotPasswordPage.scss"; import Link from "next/link"; export default function Page() { - const [email, setEmail] = useState(""); + const [nombre, setNombre] = useState(""); + const [contraseña, setContraseña] = useState(""); const [loading, setLoading] = useState(false); const router = useRouter(); - const validateEmail = (e: string) => { - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e); - }; - const handleSubmit = async (ev: React.FormEvent) => { ev.preventDefault(); - if (!validateEmail(email)) { - toast.error("Ingresa un correo válido."); + + if (nombre.trim().length < 3) { + toast.error("El nombre debe tener al menos 3 caracteres."); + return; + } + + if (contraseña.trim().length < 6) { + toast.error("La contraseña debe tener al menos 6 caracteres."); return; } try { setLoading(true); - const res = await axios.post("/api/auth/forgot-password", { email }); + const res = await axios.post("/api/admin/change-password", { + nombre, + contraseña, + }); + if (res.status === 200) { - toast.success( - "Si existe esa cuenta, recibirás un correo con instrucciones." - ); - // Opcional: redirigir al login después de enviar - setTimeout(() => router.push("/"), 1200); + toast.success("Contraseña actualizada correctamente."); + setNombre(""); + setContraseña(""); } else { - toast.error("Ocurrió un error. Intenta de nuevo."); + toast.error("No se pudo cambiar la contraseña."); } } catch (error) { - // manejar mensajes de error desde el servidor si vienen - console.log(error); + console.error(error); + toast.error("Ocurrió un error al cambiar la contraseña."); } finally { setLoading(false); } }; return ( -
-

¿Olvidaste tu contraseña?

-

- Escribe el correo asociado a tu cuenta y te enviaremos instrucciones - para restablecerla. -

+
+

Cambiar contraseña

+

Ingresa el nombre del usuario y su nueva contraseña.

-
- + + setEmail(e.target.value)} - placeholder="tu@correo.com" + id="nombre" + type="text" + value={nombre} + onChange={(e) => setNombre(e.target.value)} + placeholder="Nombre de usuario" required /> -
- Recordé mi contraseña — Iniciar sesión + Regresar al inicio
diff --git a/src/app/styles/layout/BarNavigationAdmin.scss b/src/app/styles/layout/BarNavigationAdmin.scss new file mode 100644 index 0000000..2291f9b --- /dev/null +++ b/src/app/styles/layout/BarNavigationAdmin.scss @@ -0,0 +1,186 @@ +.barNavigation { + text-align: center; + justify-content: end; + background-color: #ffffff; + display: flex; + width: 100%; + top: 0; + height: 45px; + max-height: 40px; +} + +.barNavigation ul { + display: flex; + justify-content: space-around; + width: 90%; + gap: 10px; +} + +.barNavigation li { + transition: all 0.3s ease; + cursor: pointer; + width: auto; + transition: background-color 0.3s ease; + font-size: 1.5rem; +} + +.menuToggle { + display: none; + flex-direction: column; + align-items: center; + gap: 4px; + cursor: pointer; + padding: 10px; + margin-right: 10px; +} + +.menuToggle div { + width: 25px; + height: 3px; + background-color: black; + border-radius: 4px; +} + +.subMenu { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + width: 100%; + position: relative; + z-index: 1; + border-radius: 4px 4px 0 0; +} + +.subMenu ul { + opacity: 0; + max-height: 0; + position: absolute; + flex-direction: column; + min-width: 200px; + max-width: 300px; + left: 0; + background-color: #003e79; + transition: opacity 0.4s ease, max-height 0.4s ease; +} + +.subMenu ul a { + display: none; +} + +.subMenu:hover ul { + opacity: 1; + max-height: 500px; +} + +.subMenu:hover ul a { + display: flex; +} + +.subMenu li { + padding: 10px 0; +} + +.subMenu span { + display: flex; + width: 100%; + height: 100%; + align-items: center; + justify-content: center; + color: #383838; + font-size: 2rem; +} + +.links { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; + font-size: 1.5rem; +} + +/* Estilo del botón de cierre de sesión */ +.logout-button { + background-color: #ff4d4d; + color: white; + border: none; + padding: 8px 16px; + border-radius: 6px; + cursor: pointer; + font-weight: bold; + font-size: 2rem; + display: flex; + align-items: center; + justify-content: center; + width: 100%; + max-width: 200px; + + &:hover { + background-color: #e63939; + } +} + +@media (max-width: 1000px) { + .menuToggle { + display: flex; + position: relative; + align-items: end; + transition: transform 0.3s ease; + } + + .barNavigation { + font-size: 15px; + display: block; + padding: 0; + width: 100%; + } + + .barNavigation ul { + position: absolute; + background-color: #f4f5f7; + flex-direction: column; + padding: 10px 0; + align-items: center; + display: none; + z-index: 1; + height: auto; + width: 100%; + } + + .barNavigation ul.active { + left: 0; + display: flex; + width: 100vw; + } + + .barNavigation li:hover { + background-color: #d59f0f; + color: black; + border-radius: 0; + border: none; + } + + .subMenu ul { + width: 100%; + border-radius: 4px; + position: relative; + background-color: rgb(1, 92, 184); + } + + .logout-button { + margin-top: 10px; + font-size: 1.75rem; + padding: 6px 12px; + max-width: 180px; + } + + thead, + tbody { + font-size: 1rem; + } + + .subMenu a span { + color: black; + } +} diff --git a/src/app/styles/layout/ForgotPasswordPage.scss b/src/app/styles/layout/ForgotPasswordPage.scss index 58baa87..93651e9 100644 --- a/src/app/styles/layout/ForgotPasswordPage.scss +++ b/src/app/styles/layout/ForgotPasswordPage.scss @@ -38,7 +38,8 @@ color: #222; } - input[type="email"] { + input[type="text"], + input[type="password"] { padding: 1rem 0.8rem; border: 1px solid #ccc; border-radius: 8px; @@ -95,7 +96,8 @@ background: #1e1e1e; color: #eee; - input[type="email"] { + input[type="text"], + input[type="password"] { background: #2a2a2a; border-color: #444; color: #f3f3f3; @@ -129,7 +131,7 @@ margin: 15rem auto; padding: 1.5rem; width: 92%; - box-shadow: none; // para evitar saturar pantallas pequeñas + box-shadow: none; h1 { font-size: 1.6rem; @@ -141,7 +143,8 @@ } .forgot-form { - input[type="email"] { + input[type="text"], + input[type="password"] { font-size: 0.95rem; padding: 0.9rem; } @@ -174,7 +177,8 @@ .forgot-form { gap: 1.2rem; - input[type="email"] { + input[type="text"], + input[type="password"] { font-size: 1.05rem; padding: 1rem; } diff --git a/src/components/BarNavigationAdmin.tsx b/src/components/BarNavigationAdmin.tsx new file mode 100644 index 0000000..3906c51 --- /dev/null +++ b/src/components/BarNavigationAdmin.tsx @@ -0,0 +1,57 @@ +"use client"; + +import { useState } from "react"; +import { useRouter } from "next/navigation"; +import "../app/styles/layout/BarNavigation.scss"; +import Link from "next/link"; + +function BarNavigation() { + const router = useRouter(); + const [openMenu, setOpenMenu] = useState(false); + + const toggleMenu = () => setOpenMenu(!openMenu); + + const cerrarSesion = () => { + if (typeof window !== "undefined") { + localStorage.removeItem("loggedIn"); + router.push("/"); + } + setOpenMenu(false); + }; + + return ( + + ); +} + +export default BarNavigation; +//IO diff --git a/src/components/header.tsx b/src/components/header.tsx index df18e34..de69ec6 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -3,6 +3,7 @@ import Image from "next/image"; import header from "../app/styles/layout/header.module.scss"; import Link from "next/link"; import BarNavigation from "./BarNavigation"; +import BarNavigationAdmin from "./BarNavigationAdmin"; import { usePathname } from "next/navigation"; function Header() { @@ -42,7 +43,7 @@ function Header() { }} > {publicNav.includes(pathname) && } - {privateNav.includes(pathname) && } + {privateNav.includes(pathname) && } );