builded
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import "../styles/layout/login.scss"; // puedes usar los mismos estilos
|
||||
import "../styles/base/globales.scss";
|
||||
import "../../styles/layout/login.scss";
|
||||
import "../../styles/base/globales.scss";
|
||||
|
||||
import Link from "next/link";
|
||||
import axios from "axios";
|
||||
@@ -29,23 +29,21 @@ function CrearCuenta() {
|
||||
setLoading(true);
|
||||
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/auth/register`,
|
||||
{
|
||||
nombre,
|
||||
correo,
|
||||
contraseña: password,
|
||||
}
|
||||
);
|
||||
// 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"
|
||||
);
|
||||
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 {
|
||||
@@ -57,7 +55,6 @@ function CrearCuenta() {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -116,9 +113,7 @@ function CrearCuenta() {
|
||||
<Link href="/">¿Ya tienes cuenta? Inicia sesión</Link>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</section>
|
||||
);
|
||||
}
|
||||
export default CrearCuenta;
|
||||
export default CrearCuenta;
|
||||
|
||||
@@ -4,7 +4,8 @@ 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
|
||||
import "../../styles/base/globales.scss"; // ajusta ruta si tu proyecto la tiene en otro sitio
|
||||
import Link from "next/link";
|
||||
|
||||
export default function ForgotPasswordPage() {
|
||||
const [email, setEmail] = useState("");
|
||||
@@ -26,27 +27,38 @@ export default function ForgotPasswordPage() {
|
||||
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.");
|
||||
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 ) {
|
||||
} catch (error) {
|
||||
// manejar mensajes de error desde el servidor si vienen
|
||||
const msg = error?.response?.data?.message ?? "Error al enviar el correo.";
|
||||
toast.error(msg);
|
||||
console.log(error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="forgot-password-page" style={{ maxWidth: 520, margin: "4rem auto", padding: "1.5rem" }}>
|
||||
<main
|
||||
className="forgot-password-page"
|
||||
style={{ maxWidth: 520, margin: "4rem auto", padding: "1.5rem" }}
|
||||
>
|
||||
<h1>¿Olvidaste tu contraseña?</h1>
|
||||
<p>Escribe el correo asociado a tu cuenta y te enviaremos instrucciones para restablecerla.</p>
|
||||
<p>
|
||||
Escribe el correo asociado a tu cuenta y te enviaremos instrucciones
|
||||
para restablecerla.
|
||||
</p>
|
||||
|
||||
<form onSubmit={handleSubmit} className="forgot-form" style={{ display: "grid", gap: 12 }}>
|
||||
<form
|
||||
onSubmit={handleSubmit}
|
||||
className="forgot-form"
|
||||
style={{ display: "grid", gap: 12 }}
|
||||
>
|
||||
<label htmlFor="email">Correo electrónico</label>
|
||||
<input
|
||||
id="email"
|
||||
@@ -55,7 +67,11 @@ export default function ForgotPasswordPage() {
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
placeholder="tu@correo.com"
|
||||
required
|
||||
style={{ padding: "0.6rem", borderRadius: 8, border: "1px solid #ccc" }}
|
||||
style={{
|
||||
padding: "0.6rem",
|
||||
borderRadius: 8,
|
||||
border: "1px solid #ccc",
|
||||
}}
|
||||
/>
|
||||
|
||||
<button
|
||||
@@ -65,14 +81,14 @@ export default function ForgotPasswordPage() {
|
||||
padding: "0.7rem 1rem",
|
||||
borderRadius: 8,
|
||||
border: "none",
|
||||
cursor: loading ? "not-allowed" : "pointer"
|
||||
cursor: loading ? "not-allowed" : "pointer",
|
||||
}}
|
||||
>
|
||||
{loading ? "Enviando..." : "Enviar instrucciones"}
|
||||
</button>
|
||||
|
||||
<div style={{ marginTop: 8 }}>
|
||||
<a href="/">Recordé mi contraseña — Iniciar sesión</a>
|
||||
<Link href="/">Recordé mi contraseña — Iniciar sesión</Link>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
|
||||
@@ -107,6 +107,7 @@ export default function Page() {
|
||||
setTiposEquipo(tiposEquipoRes.data);
|
||||
setSistemasOperativos(sistemasOperativosRes.data);
|
||||
setProcesadores(procesadoresRes.data);
|
||||
console.log(adscripciones);
|
||||
} catch (err) {
|
||||
if (axios.isAxiosError(err)) {
|
||||
if (err.response) {
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function Dashboard() {
|
||||
toast.error("Equipo no encontrado");
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error("Equipo no encontrado");
|
||||
toast.error(`Equipo no encontrado,${error}`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import { useState } from "react";
|
||||
import "../styles/layout/login.scss";
|
||||
import "../styles/base/globales.scss";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import axios from "axios";
|
||||
import { useRouter } from "next/navigation";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
Reference in New Issue
Block a user