feat(auth): finally better auth working as i wanted it to
This commit is contained in:
29
frontend/src/components/navBar/Nav.tsx
Normal file
29
frontend/src/components/navBar/Nav.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import { useAuth, useLogout } from "../../lib/authClient";
|
||||
import { Button } from "../ui/button";
|
||||
|
||||
export default function Nav() {
|
||||
const { session } = useAuth();
|
||||
const logout = useLogout();
|
||||
return (
|
||||
<nav>
|
||||
{session?.session ? (
|
||||
<>
|
||||
<Button
|
||||
onClick={() => {
|
||||
logout();
|
||||
}}
|
||||
>
|
||||
Sign Out
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Button>
|
||||
<Link to="/login">Login</Link>
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user