Some checks failed
CI / Verify (push) Has been cancelled
API: lists, items and invitations modules (list, create, get, update, set-primary, items create/list, invitation create/accept/list-pending), BetterAuth session helper, list membership, mailer and Prisma schema plus migrations. Web: lists overview, list detail (items) and list management (settings) views, item and invitation forms/hooks, sign-up and invitation accept pages. Shared: shopping list DTOs. Tooling: ignore the generated TanStack Router cache (apps/web/.tanstack).
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { createFileRoute, Navigate, Outlet, useRouterState } from '@tanstack/react-router'
|
|
|
|
import { AppHeader } from '@/components/layout/app-header'
|
|
import { AppSidebar } from '@/components/layout/app-sidebar'
|
|
import { SidebarInset, SidebarProvider } from '@/components/ui/sidebar'
|
|
import { Skeleton } from '@/components/ui/skeleton'
|
|
import { useSession } from '@/lib/auth-client'
|
|
|
|
export const Route = createFileRoute('/_authenticated')({
|
|
component: AuthenticatedLayout,
|
|
})
|
|
|
|
/**
|
|
* Layout for every authenticated page. The session lives in BetterAuth (Hono
|
|
* API); while it resolves we render a loader, and without a session we bounce
|
|
* the user to `/sign-in`, keeping the current URL so we can return after login.
|
|
*/
|
|
function AuthenticatedLayout() {
|
|
const { data: session, isPending } = useSession()
|
|
const href = useRouterState({ select: (state) => state.location.href })
|
|
|
|
if (isPending) {
|
|
return <SessionLoading />
|
|
}
|
|
|
|
if (!session) {
|
|
return <Navigate to="/sign-in" search={{ redirect: href }} replace />
|
|
}
|
|
|
|
return (
|
|
<SidebarProvider>
|
|
<AppSidebar />
|
|
<SidebarInset>
|
|
<AppHeader />
|
|
<div className="flex flex-1 flex-col gap-4 p-4 md:gap-6 md:p-6">
|
|
<Outlet />
|
|
</div>
|
|
</SidebarInset>
|
|
</SidebarProvider>
|
|
)
|
|
}
|
|
|
|
function SessionLoading() {
|
|
return (
|
|
<div className="space-y-4 p-6">
|
|
<Skeleton className="h-8 w-48" />
|
|
<Skeleton className="h-64 w-full" />
|
|
</div>
|
|
)
|
|
}
|