import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { MovementForm } from './MovementForm'; export interface MovementAccordionProps { movements: any[]; onChange: (index: number, field: string, value: any) => void; onAdd: () => void; onRemove: (index: number) => void; onMove: (index: number, direction: 'up' | 'down') => void; disabled?: boolean; } export function MovementAccordion({ movements, onChange, onAdd, onRemove, onMove, disabled = false }: MovementAccordionProps) { const { t } = useTranslation('settings'); const [expandedIndex, setExpandedIndex] = useState(null); const movementNames = movements.map((m) => m.name ?? ''); const toggle = (i: number) => { setExpandedIndex((prev) => (prev === i ? null : i)); }; return (

Movements

{movements.map((movement, i) => { const isExpanded = expandedIndex === i; const toolCount = (movement.allowed_tools ?? []).length; const ruleCount = (movement.rules ?? []).length; return (
{/* Collapsed header */}
toggle(i)} > {isExpanded ? '\u25BC' : '\u25B6'} {movement.name || '(unnamed)'} {movement.persona && ( {movement.persona} )} edit: {movement.edit ? 'on' : 'off'} {toolCount} tools {ruleCount} rules {/* Spacer */}
{/* Controls — hidden in read-only mode */} {!disabled && (
e.stopPropagation()}>
)}
{/* Expanded form */} {isExpanded && (
onChange(i, field, value)} disabled={disabled} />
)}
); })}
{!disabled && ( )}
); }