Sarting auth implementation in front

This commit is contained in:
2025-04-04 15:40:25 +02:00
parent b89bb484b7
commit d5e443a7c4
10 changed files with 102 additions and 40 deletions

View File

@@ -0,0 +1,14 @@
export const Login = () => {
async function handleLogin(e: any) {
e.preventDefault()
}
return (
<form onSubmit={ handleLogin }>
<input type={ "text" } name={ "email" } />
<input type={ "password" } name={ "password" } />
<input type={ "submit" } />
</form>
)
}

View File

@@ -0,0 +1,16 @@
import {Navigate, Outlet} from "react-router";
type AuthUser = { id: string; name: string };
type ProtectedRouteProps = {
user: AuthUser | null;
redirectPath?: string;
};
export const ProtectedRoute = ({ user, redirectPath = "/" }: ProtectedRouteProps) => {
if (!user) {
return <Navigate to={redirectPath} replace />;
}
return <Outlet />;
};

View File

@@ -0,0 +1,15 @@
export const Register = () => {
async function handleRegister(e: any) {
e.preventDefault()
}
return (
<form onSubmit={ handleRegister }>
<input type={ "text" } name={ "email" } />
<input type={ "password" } name={ "password" }/>
<input type={ "password" } name={ "confirm_password" }/>
<input type={ "submit" } />
</form>
)
}

View File

@@ -0,0 +1,7 @@
export const EntityList = () => {
return (
<h1>List des entity: Yoyoyo</h1>
)
}