added loading and new npm

This commit is contained in:
2025-11-12 16:35:22 -06:00
parent c04fb22d07
commit b581b6d22e
5 changed files with 992 additions and 384 deletions
+8 -1
View File
@@ -11,12 +11,15 @@ import toast from "react-hot-toast";
export default function Login() {
const [nombre, setNombre] = useState("");
const [password, setPassword] = useState("");
const [loading, setLoading] = useState(false);
const router = useRouter();
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
setLoading(true);
try {
const response = await axios.post(
`${process.env.NEXT_PUBLIC_API_URL}/auth/login`,
@@ -43,6 +46,8 @@ export default function Login() {
} else {
toast.error("Ocurrió un error inesperado");
}
} finally {
setLoading(false);
}
};
@@ -71,7 +76,9 @@ export default function Login() {
required
/>
</div>
<button type="submit">Iniciar sesión</button>
<button type="submit" disabled={loading}>
{loading ? "Buscando..." : "Iniciar sesión"}
</button>
{/* <Link href={"/forgotPassword"}>Olvidaste Contraseña?</Link> */}
{/* <Link href={"/crearCuenta"}>Crear Cuenta</Link> */}