refactor(logins): added a proper redirect to the last place you were
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import { Link, useRouterState } from "@tanstack/react-router";
|
||||
import { useAuth, useLogout } from "../../lib/authClient";
|
||||
import { ModeToggle } from "../mode-toggle";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar";
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
export default function Nav() {
|
||||
const { session } = useAuth();
|
||||
const logout = useLogout();
|
||||
const router = useRouterState();
|
||||
const currentPath = router.location.href;
|
||||
return (
|
||||
<nav className="flex justify-end w-full shadow ">
|
||||
<div className="m-2 flex flex-row gap-1">
|
||||
@@ -67,7 +69,9 @@ export default function Nav() {
|
||||
) : (
|
||||
<div className="m-1">
|
||||
<Button>
|
||||
<Link to="/login">Login</Link>
|
||||
<Link to="/login" search={{ redirect: currentPath }}>
|
||||
Login
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user