feat(lst): tan stack routes added with protected routes
This commit is contained in:
42
frontend/src/routes/__root.tsx
Normal file
42
frontend/src/routes/__root.tsx
Normal 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 />
|
||||
</>
|
||||
);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user