import { useState } from 'react'; import { Settings, Check, X } from 'lucide-react'; interface IndicatorConfig { id: string; name: string; enabled: boolean; color: string; params: Record; } interface IndicatorPanelProps { indicators: IndicatorConfig[]; onChange: (indicators: IndicatorConfig[]) => void; } export default function IndicatorPanel({ indicators, onChange }: IndicatorPanelProps) { const [isOpen, setIsOpen] = useState(false); const toggleIndicator = (id: string) => { const updated = indicators.map((ind) => ind.id === id ? { ...ind, enabled: !ind.enabled } : ind ); onChange(updated); }; const updateParam = (id: string, param: string, value: number) => { // Validate input if (isNaN(value) || value <= 0) { return; // Don't update with invalid values } const updated = indicators.map((ind) => ind.id === id ? { ...ind, params: { ...ind.params, [param]: value } } : ind ); onChange(updated); }; return (
{isOpen && ( <> {/* Backdrop */}
setIsOpen(false)} /> {/* Panel */}

Technical Indicators

{indicators.map((indicator) => (
{indicator.name}
{indicator.enabled && Object.keys(indicator.params).length > 0 && (
{Object.entries(indicator.params).map(([param, value]) => (
updateParam(indicator.id, param, Number(e.target.value)) } min="1" step="1" className="w-full px-2 py-1 text-sm bg-dark-bg border border-dark-border rounded focus:ring-2 focus:ring-blue-500 focus:outline-none" />
))}
)}
))}
)}
); }