import React, { useState, useCallback } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { ChevronRight } from 'lucide-react'
import { CardHeader } from './Card'
import { consultations } from '@/data/consultations'
import { useDetailPanel } from '@/contexts/DetailPanelContext'
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches
interface RoleItemProps {
consultation: typeof consultations[0]
isExpanded: boolean
onToggle: () => void
onViewFull: () => void
onHighlight?: (id: string | null) => void
}
function RoleItem({ consultation, isExpanded, onToggle, onViewFull, onHighlight }: RoleItemProps) {
const handleKeyDown = useCallback(
(e: React.KeyboardEvent) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
onToggle()
}
if (e.key === 'Escape' && isExpanded) {
e.preventDefault()
onToggle()
}
},
[onToggle, isExpanded],
)
return (
onHighlight?.(consultation.id)}
onMouseLeave={() => onHighlight?.(null)}
>
{/* Clickable header */}
{
if (!isExpanded) {
e.currentTarget.parentElement!.style.borderColor = 'var(--accent-border)'
e.currentTarget.parentElement!.style.boxShadow = 'var(--shadow-md)'
}
}}
onMouseLeave={(e) => {
if (!isExpanded) {
e.currentTarget.parentElement!.style.borderColor = 'var(--border-light)'
e.currentTarget.parentElement!.style.boxShadow = 'none'
}
}}
>
{/* Teal dot */}
{/* Text content */}
{consultation.role}
{consultation.organization}
{consultation.duration}
{/* Chevron */}
{/* Expandable detail content */}
{isExpanded && (
{/* Examination bullets */}
{consultation.examination.map((bullet, i) => (
-
{bullet}
))}
{/* Coded entries */}
{consultation.codedEntries.map((entry) => (
{entry.code}: {entry.description}
))}
{/* View full record link */}
)}
)
}
interface WorkExperienceSubsectionProps {
onNodeHighlight?: (id: string | null) => void
}
export function WorkExperienceSubsection({ onNodeHighlight }: WorkExperienceSubsectionProps) {
const [expandedId, setExpandedId] = useState(null)
const { openPanel } = useDetailPanel()
const handleToggle = useCallback((id: string) => {
setExpandedId((prev) => (prev === id ? null : id))
}, [])
const handleViewFull = useCallback(
(consultation: typeof consultations[0]) => {
openPanel({ type: 'career-role', consultation })
},
[openPanel],
)
return (
{consultations.map((c) => (
handleToggle(c.id)}
onViewFull={() => handleViewFull(c)}
onHighlight={onNodeHighlight}
/>
))}
)
}