import React from 'react'
import { Settings, SlidersHorizontal, Paintbrush, Map, Bell, Plug, CloudOff, User, Info, Blocks } from 'lucide-react'
import { useTranslation } from '../i18n'
import PageShell from '../components/Layout/PageShell'
import PageSidebar, { type PageSidebarTab } from '../components/Layout/PageSidebar'
import { SettingsHeader } from '../components/Settings/settingsKit'
import DisplaySettingsTab from '../components/Settings/DisplaySettingsTab'
import AppearanceSettingsTab from '../components/Settings/AppearanceSettingsTab'
import MapSettingsTab from '../components/Settings/MapSettingsTab'
import NotificationsTab from '../components/Settings/NotificationsTab'
import IntegrationsTab from '../components/Settings/IntegrationsTab'
import AccountTab from '../components/Settings/AccountTab'
import AboutTab from '../components/Settings/AboutTab'
import HelpAnchor from '../components/Help/HelpAnchor'
import { getHelpContext } from '../help/registry'
import OfflineTab from '../components/Settings/OfflineTab'
import PluginSettingsTab from '../components/Settings/PluginSettingsTab'
import { useSettings } from './settings/useSettings'
export default function SettingsPage(): React.ReactElement {
// ViewportRoute in App.tsx picks the branch now, so the phone screen is a
// chunk of its own instead of a dead limb in this one.
return
}
function SettingsPageDesktop(): React.ReactElement {
const { t } = useTranslation()
// Page = wiring container: addon/version loading + active-tab state in the hook.
const { hasPlugins, appVersion, activeTab, setActiveTab, managed } = useSettings()
// Every tab is its own help screen; a tab without one falls back to the settings overview.
const helpId = getHelpContext(`settings-${activeTab}`) ? `settings-${activeTab}` : 'settings'
const tabs: PageSidebarTab[] = [
{ id: 'display', label: t('settings.tabs.display'), icon: SlidersHorizontal },
{ id: 'appearance', label: t('settings.tabs.appearance'), icon: Paintbrush },
{ id: 'map', label: t('settings.tabs.map'), icon: Map },
{ id: 'notifications', label: t('settings.tabs.notifications'), icon: Bell },
// Always there: API keys sit in this tab and need no addon. The addon backed
// sections inside it gate themselves.
{ id: 'integrations', label: t('settings.tabs.integrations'), icon: Plug },
...(hasPlugins
? [{ id: 'plugins', label: t('settings.tabs.plugins'), icon: Blocks }]
: []),
{ id: 'offline', label: t('settings.tabs.offline'), icon: CloudOff },
{ id: 'account', label: t('settings.tabs.account'), icon: User },
// About is where the project lives: what TREK is, where to report a bug,
// where to support it. A customer of a hosted instance is the audience for
// none of that, so the tab goes and the sidebar footer below carries the one
// thing that has to stay — the link to the source (AGPL §13).
...(appVersion && !managed
? [{ id: 'about', label: t('settings.tabs.about'), icon: Info }]
: []),
]
return (
{/* Header */}
{/* Sidebar layout */}
v{appVersion}
: `v${appVersion}`
: ''
}
>
{activeTab === 'display' && }
{activeTab === 'appearance' && }
{activeTab === 'map' && }
{activeTab === 'notifications' && }
{activeTab === 'integrations' && }
{activeTab === 'plugins' && hasPlugins && }
{activeTab === 'offline' && }
{activeTab === 'account' && }
{activeTab === 'about' && appVersion && }
)
}