import type { ReactNode } from 'react'; import { ChevronRight } from 'lucide-react'; import { useAuth } from '@/context/AuthContext'; import { useLicense } from '@/context/LicenseContext'; import { useNodes } from '@/context/NodeContext'; import { SETTINGS_GROUPS, SETTINGS_ITEMS, getSettingsItem, getSettingsGroup, isItemVisible, isItemLocked, } from '@/components/settings'; import type { SectionId } from '@/components/settings'; import { SettingsSectionContent } from '@/components/settings/SettingsSectionContent'; import { BackChip, Kicker, Masthead } from './mobile-ui'; interface MobileSettingsProps { headerActions: ReactNode; selectedSection: SectionId | null; onSelectedSectionChange: (section: SectionId | null) => void; } const NOOP = () => {}; export function MobileSettings({ headerActions, selectedSection, onSelectedSectionChange, }: MobileSettingsProps) { const { isAdmin } = useAuth(); const { isPaid } = useLicense(); const { activeNode } = useNodes(); const isRemote = activeNode?.type === 'remote'; const nodeName = activeNode?.name ?? 'local'; const visibility = { isRemote, isAdmin, isPaid }; const visibleItems = SETTINGS_ITEMS.filter( item => isItemVisible(item, visibility) && !isItemLocked(item, visibility), ); const groups = SETTINGS_GROUPS .map(group => ({ ...group, items: visibleItems.filter(item => item.group === group.id) })) .filter(group => group.items.length > 0); const activeSection = selectedSection && visibleItems.some(i => i.id === selectedSection) ? selectedSection : null; const item = activeSection ? getSettingsItem(activeSection) : null; if (activeSection && item) { const group = getSettingsGroup(item.group); return (
onSelectedSectionChange(null)} />
{`settings · ${group?.label ?? ''} · ${item.label}`}
{item.label}
); } return (
{groups.map(group => (
{group.kicker ? `${group.label} · ${group.kicker}` : group.label}
{group.items.map((it, idx) => ( ))}
))}
); }