feat(lst): tan stack routes added with protected routes
This commit is contained in:
29
frontend/src/routes/index.tsx
Normal file
29
frontend/src/routes/index.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import {createFileRoute} from "@tanstack/react-router";
|
||||
import LoginForm from "../components/auth/LoginForm";
|
||||
import {Button} from "../components/ui/button";
|
||||
import {useLogout} from "../lib/hooks/useLogout";
|
||||
import {useSession} from "../lib/hooks/useSession";
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: Index,
|
||||
});
|
||||
|
||||
function Index() {
|
||||
const {session} = useSession();
|
||||
const logout = useLogout();
|
||||
return (
|
||||
<div className="p-2">
|
||||
<h3>Welcome Home!</h3>
|
||||
<br></br>
|
||||
<p>
|
||||
{session ? (
|
||||
<>
|
||||
<Button onClick={() => logout()}>Logout</Button>{" "}
|
||||
</>
|
||||
) : (
|
||||
<LoginForm />
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user