'use client';

import { AuthedNav } from '@/components/layout/AuthedNav';
import { PublicNav } from '@/components/layout/PublicNav';
import { useCurrentSession } from '@/hooks/auth/useCurrentSession';
import { Box } from '@/ui/Box';
import { DashboardRail } from '@/components/dashboard/DashboardRail';
import { Text } from '@/ui/Text';
import { Surface } from '@/ui/Surface';
import { usePathname } from 'next/navigation';

export interface GlobalSidebarViewData {}

export function GlobalSidebarTemplate(_props: GlobalSidebarViewData) {
  const pathname = usePathname();
  const { data: session } = useCurrentSession();
  const isAuthenticated = !!session;

  return (
    <Surface variant="dark" width="280px" borderRight position="sticky" top="0" height="100vh">
      <DashboardRail>
        <Box py={6} fullWidth>
          <Box px={6} mb={8}>
            <Text size="xs" variant="low" weight="bold" font="mono" letterSpacing="0.2em">
              NAVIGATION
            </Text>
          </Box>
          <Box px={3}>
            {isAuthenticated ? (
              <AuthedNav pathname={pathname} />
            ) : (
              <PublicNav pathname={pathname} />
            )}
          </Box>
        </Box>
      </DashboardRail>
    </Surface>
  );
}
