'use client' import Link from 'next/link' import { usePathname, useRouter } from 'next/navigation' import { useTranslations } from 'next-intl' import { cn } from '@/lib/utils' import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, } from '@/components/ui/select' import { useSettingsNavItems } from './useSettingsNavItems' interface SettingsRailProps { /** Layout context: 'page' navigates with push (real route), 'modal' replaces * the URL so section-switching keeps a single back-stack entry. */ variant: 'page' | 'modal' /** 'rail' = grouped vertical list (desktop); 'select' = grouped dropdown (mobile). */ display: 'rail' | 'select' /** Explicit active section id. Falls back to the current pathname when omitted * (used by the page variant where the URL is the source of truth). */ activeId?: string } export function SettingsRail({ variant, display, activeId }: SettingsRailProps) { const router = useRouter() const pathname = usePathname() const t = useTranslations('settings_nav') const { items, groups } = useSettingsNavItems() const resolvedActiveId = activeId ?? items.find((i) => pathname.startsWith(i.href))?.id ?? items[0]?.id function navigate(href: string) { if (variant === 'modal') router.replace(href) else router.push(href) } if (display === 'select') { const activeHref = items.find((i) => i.id === resolvedActiveId)?.href ?? items[0]?.href return ( ) } return ( ) }