import { useDesktopNavPreferences, type NavTab } from '@/hooks/useNavPreferences'; import { useTranslation } from '@/contexts/language'; import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; import { ArrowUp, ArrowDown, Eye, EyeOff, Lock, RotateCcw, Monitor } from 'lucide-react'; /** * Desktop top-nav customizer (Settings). * * A lightweight list: reorder the primary top-nav tabs with up/down controls * and toggle items shown/hidden. Map is the fixed first tab (locked). Hidden * items still live in the header's "More" dropdown, so nothing is ever lost. * Persists via useDesktopNavPreferences (localStorage). */ export function DesktopNavManager() { const { primaryIds, hiddenIds, setPrimaryIds, reset, catalog, fixedMapTab } = useDesktopNavPreferences(); const { t } = useTranslation(); const label = (tab: NavTab) => (tab.labelKey ? t(tab.labelKey) : tab.label); const byId = (id: string) => catalog.find((c) => c.id === id); const move = (id: string, dir: -1 | 1) => { const idx = primaryIds.indexOf(id); const next = idx + dir; if (idx < 0 || next < 0 || next >= primaryIds.length) return; const copy = [...primaryIds]; [copy[idx], copy[next]] = [copy[next], copy[idx]]; setPrimaryIds(copy); }; const hide = (id: string) => setPrimaryIds(primaryIds.filter((x) => x !== id)); const show = (id: string) => setPrimaryIds([...primaryIds, id]); return (
{t('desktopNav.desc')}
{t('desktopNav.shownInTopBar', { count: primaryIds.length })}
{primaryIds.length === 0 && ({t('desktopNav.noExtraTabs')}
)} {primaryIds.map((id, i) => { const tab = byId(id); if (!tab) return null; return ({t('desktopNav.inMoreMenu', { count: hiddenIds.length })}
{hiddenIds.map((id) => { const tab = byId(id); if (!tab) return null; return (