import * as RadixDialog from '@radix-ui/react-dialog'; import { motion, AnimatePresence } from 'framer-motion'; import { useState } from 'react'; import { classNames } from '~/utils/classNames'; import { DialogTitle } from '~/components/ui/Dialog'; import type { SettingCategory, TabType } from './settings.types'; import { categoryLabels, categoryIcons } from './settings.types'; import ProfileTab from './profile/ProfileTab'; import ProvidersTab from './providers/ProvidersTab'; import { useSettings } from '~/lib/hooks/useSettings'; import FeaturesTab from './features/FeaturesTab'; import DebugTab from './debug/DebugTab'; import EventLogsTab from './event-logs/EventLogsTab'; import ConnectionsTab from './connections/ConnectionsTab'; import DataTab from './data/DataTab'; interface SettingsProps { open: boolean; onClose: () => void; } export const SettingsWindow = ({ open, onClose }: SettingsProps) => { const { debug, eventLogs } = useSettings(); const [searchQuery, setSearchQuery] = useState(''); const [activeTab, setActiveTab] = useState(null); const settingItems = [ { id: 'profile' as const, label: 'Profile Settings', icon: 'i-ph:user-circle', category: 'profile' as const, description: 'Manage your personal information and preferences', component: () => , keywords: ['profile', 'account', 'avatar', 'email', 'name', 'theme', 'notifications'], }, { id: 'data' as const, label: 'Data Management', icon: 'i-ph:database', category: 'file_sharing' as const, description: 'Manage your chat history and application data', component: () => , keywords: ['data', 'export', 'import', 'backup', 'delete'], }, { id: 'providers' as const, label: 'Providers', icon: 'i-ph:key', category: 'file_sharing' as const, description: 'Configure AI providers and API keys', component: () => , keywords: ['api', 'keys', 'providers', 'configuration'], }, { id: 'connection' as const, label: 'Connection', icon: 'i-ph:link', category: 'connectivity' as const, description: 'Manage network and connection settings', component: () => , keywords: ['network', 'connection', 'proxy', 'ssl'], }, { id: 'features' as const, label: 'Features', icon: 'i-ph:star', category: 'system' as const, description: 'Configure application features and preferences', component: () => , keywords: ['features', 'settings', 'options'], }, ] as const; const debugItems = debug ? [ { id: 'debug' as const, label: 'Debug', icon: 'i-ph:bug', category: 'system' as const, description: 'Advanced debugging tools and options', component: () => , keywords: ['debug', 'logs', 'developer'], }, ] : []; const eventLogItems = eventLogs ? [ { id: 'event-logs' as const, label: 'Event Logs', icon: 'i-ph:list-bullets', category: 'system' as const, description: 'View system events and application logs', component: () => , keywords: ['logs', 'events', 'history'], }, ] : []; const allSettingItems = [...settingItems, ...debugItems, ...eventLogItems]; const filteredItems = allSettingItems.filter( (item) => item.label.toLowerCase().includes(searchQuery.toLowerCase()) || item.description?.toLowerCase().includes(searchQuery.toLowerCase()) || item.keywords?.some((keyword) => keyword.toLowerCase().includes(searchQuery.toLowerCase())), ); const groupedItems = filteredItems.reduce( (acc, item) => { if (!acc[item.category]) { acc[item.category] = allSettingItems.filter((i) => i.category === item.category); } return acc; }, {} as Record, ); const handleBackToDashboard = () => { setActiveTab(null); onClose(); }; const activeTabItem = allSettingItems.find((item) => item.id === activeTab); return (
{activeTab ? (
|
{activeTabItem && (

{activeTabItem.label}

{activeTabItem.description}

)}
{allSettingItems.find((item) => item.id === activeTab)?.component()}
) : (
Bolt Control Panel
setSearchQuery(e.target.value)} className={classNames( 'w-full h-10 pl-10 pr-4 rounded-lg text-sm', 'bg-[#F8F8F8] dark:bg-[#1A1A1A]', 'border border-[#E5E5E5] dark:border-[#333333]', 'text-bolt-elements-textPrimary placeholder-bolt-elements-textTertiary', 'focus:outline-none focus:ring-1 focus:ring-purple-500 transition-all', )} />
{(Object.keys(groupedItems) as SettingCategory[]).map((category) => (

{categoryLabels[category]}

{groupedItems[category].map((item) => ( ))}
))}
)}
); };