"use client"; import { useDesktopPreferences } from "@/hooks/useDesktopPreferences"; import { useActiveSettingsSection, useBackupSettingsController, useGeneralSettingsController, useNotificationSettingsController, useSecuritySettingsController, useUpdatesAutoCheckEffect, } from "@/modules/settings/components/panel/controllers"; import { buildSettingsSectionDefinitions, SETTINGS_SECTIONS, } from "@/modules/settings/components/panel/registry"; import { SETTINGS_BADGE_SURFACE, SETTINGS_PANEL_SHELL, } from "@/modules/settings/components/panel/surface"; import type { SettingsPanelProps, SettingsSectionId } from "@/modules/settings/components/panel/types"; import { useSettingsBackend } from "@/modules/settings/hooks/useSettingsBackend"; import { cn } from "@/lib/utils"; const SIDEBAR_GROUPS: { label: string; ids: SettingsSectionId[] }[] = [ { label: "System", ids: ["general", "appearance", "updates"] }, { label: "Infrastructure", ids: ["network", "storage", "docker"] }, { label: "Integrations", ids: ["integrations"] }, { label: "Automation", ids: ["scheduled-tasks", "backup"] }, { label: "Access", ids: ["users", "security", "notifications"] }, { label: "Danger Zone", ids: ["power", "advanced"] }, ]; export function SettingsPanel({ appearance, wallpaperOptions, accentOptions, onAppearanceChange, wallpaperAccentColor, selectedSection, onOpenDiskManager, }: SettingsPanelProps) { const settingsBackend = useSettingsBackend(); const desktopPreferences = useDesktopPreferences(); const { activeSection, setActiveSection } = useActiveSettingsSection( selectedSection, SETTINGS_SECTIONS.map((section) => section.id), ); const generalController = useGeneralSettingsController( settingsBackend.generalPreferences, settingsBackend.actions.saveGeneralPreferences, ); const securityController = useSecuritySettingsController( settingsBackend.security, settingsBackend.actions.saveSecuritySettings, ); const backupController = useBackupSettingsController( settingsBackend.backup.settings, settingsBackend.actions.saveBackupSettings, ); const notificationController = useNotificationSettingsController(desktopPreferences); useUpdatesAutoCheckEffect({ activeSection, isHydrated: desktopPreferences.isHydrated, autoCheckEnabled: desktopPreferences.preferences.autoCheckUpdates, onCheckForUpdates: settingsBackend.actions.checkForUpdates, }); const sectionDefinitions = buildSettingsSectionDefinitions({ appearance, wallpaperOptions, accentOptions, onAppearanceChange, wallpaperAccentColor, desktopPreferences, settingsBackend, generalController, securityController, notificationController, backupController, onOpenDiskManager, }); const activeDefinition = sectionDefinitions.find((section) => section.id === activeSection) ?? sectionDefinitions[0]; return (

{activeDefinition.label}

{!activeDefinition.liveApply && activeDefinition.save ? ( ) : null}
{activeDefinition.render()}
); }