convert to TS

This commit is contained in:
p2405951
2026-03-13 15:13:16 +01:00
parent 00f6177842
commit 0f11ec641a
2 changed files with 29 additions and 0 deletions
+1
View File
@@ -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 }>;
}
+28
View File
@@ -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;