convert to TS
This commit is contained in:
@@ -21,6 +21,7 @@ export interface User {
|
||||
|
||||
export interface AuthContextType {
|
||||
user: User | null;
|
||||
loading: boolean;
|
||||
update: () => void;
|
||||
login: (email: string, password: string) => Promise<{ status: number }>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import styles from "./LoginPage.module.css";
|
||||
import LoginForm from "./components/LoginForm/LoginForm";
|
||||
import Background from "../../components/Background/Background.jsx";
|
||||
import { useEffect, useContext } from "react";
|
||||
import { AuthContext, AuthContextType } from "../../../src/contexts/Auth/AuthContext";
|
||||
import { useNavigate } from "react-router";
|
||||
|
||||
function LoginPage() {
|
||||
const { user, loading } = useContext(AuthContext) as AuthContextType;
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
if (!loading && user) {
|
||||
navigate("/");
|
||||
}
|
||||
}, [loading, user, navigate]);
|
||||
|
||||
return (
|
||||
<Background className="">
|
||||
<div className={styles.container}>
|
||||
<h1 className={styles.title}>Connexion</h1>
|
||||
<LoginForm />
|
||||
</div>
|
||||
</Background>
|
||||
);
|
||||
}
|
||||
|
||||
export default LoginPage;
|
||||
Reference in New Issue
Block a user