convert to TS
This commit is contained in:
1 parent
00f6177842
commit
0f11ec641a
2 files changed
+29
No files matched your search
@@ -21,6 +21,7 @@ export interface User {
|
|||||||
|
|
||||||
export interface AuthContextType {
|
export interface AuthContextType {
|
||||||
user: User | null;
|
user: User | null;
|
||||||
|
loading: boolean;
|
||||||
update: () => void;
|
update: () => void;
|
||||||
login: (email: string, password: string) => Promise<{ status: number }>;
|
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