import React from 'react'; import { Settings, RotateCw, ChevronDown, ChevronRight } from 'lucide-react'; import { ConfigItem } from '../types'; interface SettingsModalProps { isOpen: boolean; onClose: () => void; config: ConfigItem[] | null; isRefreshing: boolean; onSave: (config: ConfigItem[]) => void; } const TechButton = ({ children, onClick, active = false, variant = 'blue', className = '' }: any) => { const colors: any = { blue: 'from-blue-600 to-cyan-600 hover:shadow-glow-blue border-cyan-400/30', red: 'from-red-600 to-pink-600 hover:shadow-glow-red border-red-400/30', amber: 'from-amber-500 to-orange-600 hover:shadow-orange-500/50 border-orange-400/30', green: 'from-emerald-500 to-green-600 hover:shadow-green-500/50 border-green-400/30' }; return ( ); }; export const SettingsModal: React.FC = ({ isOpen, onClose, config, isRefreshing, onSave }) => { const [localConfig, setLocalConfig] = React.useState([]); const [expandedGroups, setExpandedGroups] = React.useState>(new Set()); React.useEffect(() => { if (config) { setLocalConfig(config); // Auto-expand all groups initially const groups = new Set(config.map(c => c.Group)); setExpandedGroups(groups); } }, [config]); const handleChange = (idx: number, newValue: string) => { setLocalConfig(prev => { const next = [...prev]; next[idx] = { ...next[idx], Value: newValue }; return next; }); }; const toggleGroup = (group: string) => { setExpandedGroups(prev => { const next = new Set(prev); if (next.has(group)) next.delete(group); else next.add(group); return next; }); }; // Group items by category const groupedConfig = React.useMemo(() => { const groups: { [key: string]: { item: ConfigItem, originalIdx: number }[] } = {}; localConfig.forEach((item, idx) => { if (!groups[item.Group]) groups[item.Group] = []; groups[item.Group].push({ item, originalIdx: idx }); }); return groups; }, [localConfig]); if (!isOpen) return null; return (

SYSTEM CONFIGURATION

{isRefreshing ? (
FETCHING CONFIGURATION...
) : (
{Object.entries(groupedConfig).map(([groupName, items]) => (
{expandedGroups.has(groupName) && (
{items.map(({ item, originalIdx }) => (
{item.Key}
{item.Description}
{item.Type === 'Boolean' ? (
{item.Value.toUpperCase()}
) : ( handleChange(originalIdx, e.target.value)} className="w-full bg-black/50 border border-slate-700 text-white font-mono text-sm px-3 py-2 focus:border-neon-blue focus:outline-none transition-colors hover:border-slate-500" /> )}
))}
)}
))}
)}
CANCEL { onSave(localConfig); onClose(); }}>SAVE CONFIG
); };