import { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { useFlowStore } from '../../store/useFlowStore'; import type { ActorType } from '../../data/types'; import { Icon } from '../shared/Icon'; import { ACTOR_ICONS } from '../../utils/iconMap'; const ACTOR_COLORS: Record = { rider: '#fb2576', driver: '#6316db', ops: '#06b6d4', system: '#f59e0b', }; export const StepList = () => { const { selectedPath, activeSubPathId, activeStepIndex, setActiveStep, selectSubPath, getCurrentSteps, } = useFlowStore(); const [expandedIndex, setExpandedIndex] = useState(null); const hasSubPaths = selectedPath.subPaths && selectedPath.subPaths.length > 0; const steps = getCurrentSteps(); // Sync expanded state: auto-expand the active step, allow user to close it const isExpanded = (index: number) => { if (expandedIndex !== null) return expandedIndex === index; return index === activeStepIndex; }; const handleStepClick = (index: number) => { setActiveStep(index); // Toggle: if already expanded, close it; otherwise expand it if (isExpanded(index)) { setExpandedIndex(-1); // -1 means "nothing expanded" } else { setExpandedIndex(index); } }; return (

Sequence Timeline

Path {selectedPath.id}
{/* Sub-path selector */} {hasSubPaths && (
{selectedPath.subPaths!.map((sub) => ( ))}
)} {/* Timeline — uses absolute line to avoid overflow clipping */}
{/* Vertical timeline line */}
{steps.map((step, index) => { const isCurrent = index === activeStepIndex; const isCompleted = index < activeStepIndex; const expanded = isExpanded(index); const actorColor = ACTOR_COLORS[step.actor]; const actorIcon = ACTOR_ICONS[step.actor] || 'person'; return (
{/* Timeline dot — centered on the line at left:15px */}
{isCurrent ? ( ) : isCompleted ? (
) : (
)}
{/* Clickable step area */} {/* Expandable detail card */} {expanded && (

{step.description}

{step.actor}
{step.bookingStatus}
)}
); })}
); };