suppression du raccourci
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import {useState, useContext, useEffect} from "react";
|
import { useState, useContext } from "react";
|
||||||
import styles from "./loginForm.module.css";
|
import styles from "./loginForm.module.css";
|
||||||
import Button from "../../../../components/ui/button/button.tsx";
|
import Button from "../../../../components/ui/button/button.tsx";
|
||||||
import Input from "../../../../components/ui/input/input.tsx";
|
import Input from "../../../../components/ui/input/input.tsx";
|
||||||
@@ -9,32 +9,17 @@ import { AuthContext } from "../../../../contexts/auth/AuthContext.js";
|
|||||||
|
|
||||||
function LoginForm({ className }) {
|
function LoginForm({ className }) {
|
||||||
|
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { login } = useContext(AuthContext);
|
const { login } = useContext(AuthContext);
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
const [open , setOpen] = useState(false);
|
const [open , setOpen] = useState(false);
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
const handleSubmit = async () => {
|
|
||||||
const res = await login(email, password);
|
const res = await login(email, password);
|
||||||
if (res.status === 401 || res.status === 422) setOpen(true);
|
if (res.status === 401 || res.status === 422) setOpen(true);
|
||||||
else navigate("/");
|
else navigate("/");
|
||||||
};
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const listener = (e) => {
|
|
||||||
if (e.key === "Enter") {
|
|
||||||
handleSubmit();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
window.addEventListener("keydown", listener);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
window.removeEventListener("keydown", listener);
|
|
||||||
};
|
|
||||||
},);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`${className} glassCard ${styles.inputContainer}`}>
|
<div className={`${className} glassCard ${styles.inputContainer}`}>
|
||||||
|
|||||||
Reference in New Issue
Block a user