Files
gridpilot.gg/apps/website/templates/layout/RootAppShellTemplate.tsx
2026-01-19 21:30:36 +01:00

53 lines
1.6 KiB
TypeScript

'use client';
import { AppShell } from '@/components/app/AppShell';
import { AppFooter } from '@/components/layout/AppFooter';
import { AppHeader } from '@/components/layout/AppHeader';
import { AppSidebar } from '@/components/layout/AppSidebar';
import { MainContent } from '@/components/layout/MainContent';
import { useCurrentSession } from '@/hooks/auth/useCurrentSession';
import { routes } from '@/lib/routing/RouteConfig';
import { ContentViewport } from '@/ui/ContentViewport';
import { usePathname } from 'next/navigation';
import React from 'react';
export interface RootAppShellViewData {
children: React.ReactNode;
}
/**
* RootAppShellTemplate orchestrates the top-level semantic shells of the application.
* It follows the "Telemetry Workspace" structure:
* - AppHeader = header/control bar
* - AppSidebar = sidebar rail
* - MainContent = content area wrapper
* - AppFooter = footer
*/
export function RootAppShellTemplate({ children }: RootAppShellViewData) {
const pathname = usePathname();
const { data: session } = useCurrentSession();
const isAuthenticated = !!session;
// Hide sidebar on landing page for unauthenticated users
const isLandingPage = pathname === routes.public.home;
const showSidebar = isAuthenticated && !isLandingPage;
return (
<AppShell>
<AppHeader />
{showSidebar && <AppSidebar />}
<MainContent hasSidebar={showSidebar}>
<ContentViewport
fullWidth={!showSidebar || isLandingPage}
padding={isLandingPage ? 'none' : 'md'}
>
{children}
</ContentViewport>
<AppFooter />
</MainContent>
</AppShell>
);
}