Move loginPage components
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
import { useState, useContext } from "react";
|
||||
import styles from "./loginForm.module.css";
|
||||
import Button from "../ui/button/button.jsx";
|
||||
import Input from "../ui/input/input.jsx";
|
||||
import Modal from "../ui/modal/modal.jsx";
|
||||
import { useNavigate } from "react-router";
|
||||
import { AuthContext } from "../../contexts/auth/AuthContext.js";
|
||||
|
||||
|
||||
function LoginForm({ className }) {
|
||||
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { login } = useContext(AuthContext);
|
||||
const [email, setEmail] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const [open , setOpen] = useState(false);
|
||||
|
||||
async function handleSubmit() {
|
||||
const res = await login(email, password);
|
||||
if (res.status === 401 || res.status === 422) setOpen(true);
|
||||
else navigate("/");
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`${className} glassCard ${styles.inputContainer}`}>
|
||||
<div className={styles.formgroup}>
|
||||
<Input
|
||||
type="email"
|
||||
value={email}
|
||||
placeholder="Adresse mail"
|
||||
onChange={e => setEmail(e.target.value)}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.formgroup}>
|
||||
<Input password={true} onChange={e => setPassword(e.target.value)} value={password} placeholder={"Mot de passe"} />
|
||||
</div>
|
||||
|
||||
<div className={styles.logButton}>
|
||||
<Button variant={"transparent"} onClick={() => navigate("/register")}>Vous n'avez pas de compte ?</Button>
|
||||
<Button onClick={handleSubmit} variant={"default"}> Se connecter </Button>
|
||||
</div>
|
||||
|
||||
<Modal title={"Impossible de se connecter"} open={open} onClose={() => setOpen(false)}>
|
||||
<p>L'Email ou le mot de passe est incorrect</p>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default LoginForm;
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
:global(.glassCard) {
|
||||
--glass-bg: #ffffff9f;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
padding: 0 10px;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
font-size: 19px;
|
||||
color: #111;
|
||||
background: var(--glass-bg);
|
||||
box-shadow: 0 2px 6px rgba(91, 90, 90, 0.06) inset;
|
||||
}
|
||||
|
||||
input::placeholder{
|
||||
font-size: 20px;
|
||||
color: rgba(0,0,0,0.45);
|
||||
}
|
||||
|
||||
.formgroup{
|
||||
margin-top:23px;
|
||||
}
|
||||
|
||||
.logButton{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.inputContainer {
|
||||
padding: 15px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.loginButton {
|
||||
display: inline-block;
|
||||
height: 50px;
|
||||
width:90%;
|
||||
border-radius: 16px;
|
||||
margin-bottom:3%;
|
||||
margin-top:3%;
|
||||
background-color: rgba(255, 255, 255, 0.335);
|
||||
color: #000000;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: background-color 160ms ease, transform 120ms ease, box-shadow 160ms ease;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.loginButton:hover {
|
||||
background-color: #54585e;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 14px rgba(43,108,176,0.18);
|
||||
}
|
||||
|
||||
.loginButton:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 3px 8px rgba(43,108,176,0.12);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user