import { useMemo, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { motion } from 'framer-motion'; import { useFlowStore } from '../../store/useFlowStore'; import { PATHS } from '../../data/paths'; import type { PathCategory } from '../../data/types'; import { Icon } from '../shared/Icon'; import { Tooltip } from '../shared/Tooltip'; import { CATEGORY_ICONS } from '../../utils/iconMap'; const CATEGORY_LABELS: Record = { success: 'Success', 'rider-cancel': 'Rider Cancellations', 'driver-cancel': 'Driver Cancellations', timeout: 'Timeouts', ops: 'Ops Actions', 'active-cancel': 'Active Trip Cancels', }; const CATEGORY_ORDER: PathCategory[] = [ 'success', 'rider-cancel', 'timeout', 'driver-cancel', 'ops', 'active-cancel', ]; export const PathSelector = () => { const { selectedPath, selectPath } = useFlowStore(); const navigate = useNavigate(); const [searchQuery, setSearchQuery] = useState(''); const grouped = useMemo(() => { const groups: Record = {}; for (const path of PATHS) { if (searchQuery) { const q = searchQuery.toLowerCase(); if (!path.label.toLowerCase().includes(q) && !path.description.toLowerCase().includes(q)) { continue; } } if (!groups[path.category]) groups[path.category] = []; groups[path.category].push(path); } return groups; }, [searchQuery]); return (

Path Selection

{/* Search */}
setSearchQuery(e.target.value)} className="bg-transparent border-none text-sm text-white w-full placeholder-slate-500 ml-2 p-2 focus:outline-none focus:ring-0" />
{/* Path list */}
{CATEGORY_ORDER.map((cat) => { const paths = grouped[cat]; if (!paths || paths.length === 0) return null; return (
{CATEGORY_LABELS[cat]}
{paths.map((path) => { const isSelected = selectedPath.id === path.id; const iconName = CATEGORY_ICONS[path.category] || 'circle'; return ( selectPath(path.id)} className="w-full flex items-center justify-between gap-3 px-3 py-2.5 rounded-lg text-left transition-all relative overflow-hidden" style={{ background: isSelected ? 'rgba(97,22,218,0.1)' : 'transparent', border: isSelected ? '1px solid rgba(97,22,218,0.2)' : '1px solid transparent', color: isSelected ? 'white' : 'var(--color-text-secondary)', }} whileHover={{ backgroundColor: isSelected ? undefined : 'var(--color-surface-highlight)', }} > {isSelected && (
)}
{path.label}
{isSelected && ( )} {isSelected ? (
) : ( P{path.id} )}
); })}
); })}
); };