added loading and new npm
This commit is contained in:
@@ -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> */}
|
||||
|
||||
Reference in New Issue
Block a user