Scaffold @forte/admin package with React, Vite, shadcn/ui, TanStack Router
Sets up the admin frontend with login page, auth guard, API client, Zustand auth store, and all shadcn/ui components. Vite proxies /v1 to backend in dev.
This commit is contained in:
30
packages/admin/src/routes/_authenticated.tsx
Normal file
30
packages/admin/src/routes/_authenticated.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { createFileRoute, Outlet, redirect } from '@tanstack/react-router'
|
||||
import { useAuthStore } from '@/stores/auth.store'
|
||||
|
||||
export const Route = createFileRoute('/_authenticated')({
|
||||
beforeLoad: () => {
|
||||
const { token } = useAuthStore.getState()
|
||||
if (!token) {
|
||||
throw redirect({ to: '/login' })
|
||||
}
|
||||
},
|
||||
component: AuthenticatedLayout,
|
||||
})
|
||||
|
||||
function AuthenticatedLayout() {
|
||||
return (
|
||||
<div className="min-h-screen bg-background text-foreground">
|
||||
<div className="flex">
|
||||
<nav className="w-56 border-r border-border bg-sidebar min-h-screen p-4 space-y-2">
|
||||
<h2 className="text-lg font-semibold text-sidebar-foreground mb-4">Forte</h2>
|
||||
<a href="/accounts" className="block px-3 py-2 rounded-md text-sm text-sidebar-foreground hover:bg-sidebar-accent">
|
||||
Accounts
|
||||
</a>
|
||||
</nav>
|
||||
<main className="flex-1 p-6">
|
||||
<Outlet />
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user