import { useState } from 'react' import { AlertCircle, ChevronDown, ChevronRight, Plus, Trash2, Check, X } from 'lucide-react' import type { ProceduralStep } from '@/types' import { cn } from '@/lib/utils' interface FallbackStepsProps { fallbackSteps: ProceduralStep[] mode: 'edit' | 'execute' // Edit mode onAdd?: () => void onRemove?: (index: number) => void onUpdate?: (index: number, updates: Partial) => void // Execute mode onComplete?: (stepId: string, notes: string | null, outcome: 'resolved' | 'not_resolved' | 'skipped') => void completedIds?: Set } export function FallbackSteps({ fallbackSteps, mode, onAdd, onRemove, onUpdate, onComplete, completedIds, }: FallbackStepsProps) { const [expanded, setExpanded] = useState(false) // In execute mode, hide if no fallback steps if (mode === 'execute' && fallbackSteps.length === 0) { return null } const toggleLabel = mode === 'execute' ? "Didn't work?" : `Fallback branches (${fallbackSteps.length})` return (
{/* Toggle button */} {expanded && (
{fallbackSteps.map((fbStep, index) => { const isCompleted = completedIds?.has(fbStep.id) return (
{mode === 'edit' ? (
onUpdate?.(index, { title: e.target.value })} placeholder="Fallback step title" className="flex-1 rounded border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-hidden focus:ring-1 focus:ring-primary/20" />