import { useMemo, useState, useCallback } from 'react' import { ChevronRight } from 'lucide-react' import { ExpandableCardShell } from './ExpandableCardShell' import { useDetailPanel } from '@/contexts/DetailPanelContext' import { timelineEntities, timelineConsultations } from '@/data/timeline' import { getExperienceEducationUICopy } from '@/lib/profile-content' import type { TimelineEntity } from '@/types/pmr' import { hexToRgba } from '@/lib/utils' interface TimelineInterventionItemProps { entity: TimelineEntity isExpanded: boolean isHighlightedFromGraph: boolean isEducationAnchor: boolean onToggle: () => void onViewFull: () => void onHighlight?: (id: string | null) => void } function TimelineInterventionItem({ entity, isExpanded, isHighlightedFromGraph, isEducationAnchor, onToggle, onViewFull, onHighlight, }: TimelineInterventionItemProps) { const experienceEducationCopy = getExperienceEducationUICopy() const isEducation = entity.kind === 'education' const interventionLabel = isEducation ? experienceEducationCopy.educationLabel : experienceEducationCopy.employmentLabel return ( onHighlight?.(entity.id)} onMouseLeave={() => onHighlight?.(null)} renderHeader={() => ( <>
{interventionLabel}
{entity.title}
{entity.organization} {entity.dateRange.display}
)} renderBody={() => ( <> {!!entity.codedEntries?.length && (
{entity.codedEntries.map((entry) => ( {entry.code}: {entry.description} ))}
)} )} /> ) } interface TimelineInterventionsSubsectionProps { onNodeHighlight?: (id: string | null) => void highlightedRoleId?: string | null } export function TimelineInterventionsSubsection({ onNodeHighlight, highlightedRoleId }: TimelineInterventionsSubsectionProps) { const [expandedId, setExpandedId] = useState(null) const { openPanel } = useDetailPanel() const consultationsById = useMemo( () => new Map(timelineConsultations.map((consultation) => [consultation.id, consultation])), [], ) const firstEducationId = useMemo( () => timelineEntities.find((entity) => entity.kind === 'education')?.id ?? null, [], ) const handleToggle = useCallback((id: string) => { setExpandedId((prev) => (prev === id ? null : id)) }, []) const handleViewFull = useCallback((entity: TimelineEntity) => { const consultation = consultationsById.get(entity.id) if (!consultation) return openPanel({ type: 'career-role', consultation }) }, [consultationsById, openPanel]) return (
{timelineEntities.map((entity) => ( handleToggle(entity.id)} onViewFull={() => handleViewFull(entity)} onHighlight={onNodeHighlight} /> ))}
) }