From 54ef8c6157749e27f18dd4df7727f347101b89fa Mon Sep 17 00:00:00 2001 From: jls846 Date: Thu, 30 Oct 2025 14:07:58 -0600 Subject: [PATCH] pull lino --- src/app/crearCuenta/page.tsx | 124 -------------------------------- src/app/forgotPassword/page.tsx | 80 --------------------- 2 files changed, 204 deletions(-) delete mode 100644 src/app/crearCuenta/page.tsx delete mode 100644 src/app/forgotPassword/page.tsx diff --git a/src/app/crearCuenta/page.tsx b/src/app/crearCuenta/page.tsx deleted file mode 100644 index 5cd4415..0000000 --- a/src/app/crearCuenta/page.tsx +++ /dev/null @@ -1,124 +0,0 @@ -"use client"; - -import { useState } from "react"; -import "../styles/layout/login.scss"; // puedes usar los mismos estilos -import "../styles/base/globales.scss"; - -import Link from "next/link"; -import axios from "axios"; -import { useRouter } from "next/navigation"; -import toast from "react-hot-toast"; - -function CrearCuenta() { - const [nombre, setNombre] = useState(""); - const [correo, setCorreo] = useState(""); - const [password, setPassword] = useState(""); - const [confirmarPassword, setConfirmarPassword] = useState(""); - const [loading, setLoading] = useState(false); - - const router = useRouter(); - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - - if (password !== confirmarPassword) { - toast.error("Las contraseñas no coinciden"); - return; - } - - setLoading(true); - - try { - const response = await axios.post( - `${process.env.NEXT_PUBLIC_API_URL}/auth/register`, - { - nombre, - correo, - contraseña: password, - } - ); - - toast.success("Cuenta creada correctamente"); - router.push("/"); // redirige al login - } catch (err: unknown) { - if (axios.isAxiosError(err)) { - if (err.response) { - toast.error( - err.response.data?.message || "Error al crear la cuenta" - ); - } else if (err.request) { - toast.error("No se pudo conectar con el servidor"); - } else { - toast.error("Ocurrió un error inesperado"); - } - } else { - toast.error("Ocurrió un error inesperado"); - } - } finally { - setLoading(false); - } - - }; - - return ( -
-
-

Crear cuenta

-
-
- - setNombre(e.target.value)} - required - /> -
- -
- - setCorreo(e.target.value)} - required - /> -
- -
- - setPassword(e.target.value)} - required - /> -
- -
- - setConfirmarPassword(e.target.value)} - required - /> -
- - - - ¿Ya tienes cuenta? Inicia sesión -
-
- - -
- ); -} -export default CrearCuenta; \ No newline at end of file diff --git a/src/app/forgotPassword/page.tsx b/src/app/forgotPassword/page.tsx deleted file mode 100644 index 98e3cf1..0000000 --- a/src/app/forgotPassword/page.tsx +++ /dev/null @@ -1,80 +0,0 @@ -"use client"; - -import { useState } from "react"; -import axios from "axios"; -import { useRouter } from "next/navigation"; -import toast from "react-hot-toast"; -import "../styles/base/globales.scss"; // ajusta ruta si tu proyecto la tiene en otro sitio - -export default function ForgotPasswordPage() { - const [email, setEmail] = 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."); - return; - } - - try { - setLoading(true); - const res = await axios.post("/api/auth/forgot-password", { email }); - 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); - } else { - toast.error("Ocurrió un error. Intenta de nuevo."); - } - } catch (error:any ) { - // manejar mensajes de error desde el servidor si vienen - const msg = error?.response?.data?.message ?? "Error al enviar el correo."; - toast.error(msg); - } finally { - setLoading(false); - } - }; - - return ( -
-

¿Olvidaste tu contraseña?

-

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

- -
- - setEmail(e.target.value)} - placeholder="tu@correo.com" - required - style={{ padding: "0.6rem", borderRadius: 8, border: "1px solid #ccc" }} - /> - - - - -
-
- ); -}