import type { LucideIcon } from 'lucide-react'; import { Card, CardContent } from './ui/card'; import { Button } from './ui/button'; import { Alert, AlertDescription } from './ui/alert'; import { Badge } from './ui/badge'; import { Textarea } from './ui/textarea'; import { Loader2, CheckCircle, AlertCircle, Play, RotateCw } from 'lucide-react'; import { useCentralStatus } from '../hooks/useCentralStatus'; interface MetadataItem { label: string; value: string | number | undefined; } interface SubsystemPageProps { title: string; description: string; icon: LucideIcon; daemonKey: string; configContent?: string; isLoadingConfig?: boolean; rawStatusLabel?: string; rawStatusContent?: string; onGenerate?: () => void; isGenerating?: boolean; generateLabel?: string; onRestart?: () => void; isRestarting?: boolean; restartLabel?: string; successMessage?: string | null; errorMessage?: string | null; metadata?: MetadataItem[]; } export function SubsystemPage({ title, description, icon: Icon, daemonKey, configContent, isLoadingConfig, rawStatusLabel, rawStatusContent, onGenerate, isGenerating, generateLabel = 'Generate & Apply', onRestart, isRestarting, restartLabel = 'Restart', successMessage, errorMessage, metadata, }: SubsystemPageProps) { const { data: centralStatus } = useCentralStatus(); const active = centralStatus?.daemons?.[daemonKey]?.active; return (
{/* Header */}

{title}

{description}

{active !== undefined && ( {active ? : } {active ? 'Active' : 'Inactive'} )}
{/* Alerts */} {successMessage && ( {successMessage} )} {errorMessage && ( {errorMessage} )} {/* Actions + Metadata */} {(onGenerate || onRestart || metadata?.length) && ( {(onGenerate || onRestart) && (
{onGenerate && ( )} {onRestart && ( )}
)} {metadata && metadata.length > 0 && (
{metadata.map(m => (
{m.label}
{m.value ?? '--'}
))}
)}
)} {/* Config */} {isLoadingConfig ? (

Loading configuration...

) : configContent !== undefined ? (