refactor(logins): added a proper redirect to the last place you were
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { createFileRoute, Link, Outlet } from "@tanstack/react-router";
|
||||
import {
|
||||
createFileRoute,
|
||||
Link,
|
||||
Outlet,
|
||||
useRouterState,
|
||||
} from "@tanstack/react-router";
|
||||
import Cookies from "js-cookie";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ModeToggle } from "../../../components/mode-toggle";
|
||||
@@ -30,6 +35,8 @@ function RouteComponent() {
|
||||
const sidebarState = Cookies.get("sidebar_state") === "true";
|
||||
const { session } = useAuth();
|
||||
const logout = useLogout();
|
||||
const router = useRouterState();
|
||||
const currentPath = router.location.href;
|
||||
//const { settings } = useSettingStore();
|
||||
//console.log(location.pathname);
|
||||
return (
|
||||
@@ -86,7 +93,9 @@ function RouteComponent() {
|
||||
<DropdownMenuItem>
|
||||
{/* <Link to="/passwordChange">Password Change</Link> */}
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuItem>
|
||||
<Link to="/user/profile">Profile</Link>
|
||||
</DropdownMenuItem>
|
||||
{/* <DropdownMenuItem>Billing</DropdownMenuItem>
|
||||
<DropdownMenuItem>Team</DropdownMenuItem>
|
||||
<DropdownMenuItem>Subscription</DropdownMenuItem> */}
|
||||
@@ -101,7 +110,9 @@ function RouteComponent() {
|
||||
</div>
|
||||
) : (
|
||||
<Button className="m-1">
|
||||
<Link to="/login">Login</Link>
|
||||
<Link to="/login" search={{ redirect: currentPath }}>
|
||||
Login
|
||||
</Link>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user