feat(lst): tan stack routes added with protected routes

This commit is contained in:
2025-02-19 20:11:40 -06:00
parent 83f6fbf760
commit 5f8943492e
23 changed files with 608 additions and 74 deletions

View File

@@ -0,0 +1,42 @@
import {createRootRouteWithContext, Link, Outlet} from "@tanstack/react-router";
import {TanStackRouterDevtools} from "@tanstack/router-devtools";
import {SessionType} from "../lib/hooks/useSession";
type RouterContext = {
sessionType: SessionType;
};
// same as the layout
export const Route = createRootRouteWithContext<RouterContext>()({
component: () => {
return (
<>
<div className="p-2 flex gap-2">
<Link to="/" className="[&.active]:font-bold">
Home
</Link>{" "}
<Link to="/about" className="[&.active]:font-bold">
About
</Link>
<Link to="/dashboard" className="[&.active]:font-bold">
dashboard
</Link>
<Link to="/profile" className="[&.active]:font-bold">
{({isActive}) => <>Profile {isActive && "~"}</>}
</Link>
<Link
to="/ocp"
search={{q: "1"}}
activeProps={{style: {fontWeight: "bold"}}}
className="[&.active]:font-bold"
>
{({isActive}) => <>OCP {isActive && "~"}</>}
</Link>
</div>
<hr />
<Outlet />
<TanStackRouterDevtools />
</>
);
},
});