import React from 'react' import { ChevronRight } from 'lucide-react' import { CardHeader } from './Card' import { useDetailPanel } from '@/contexts/DetailPanelContext' import { timelineConsultations } from '@/data/timeline' import { hexToRgba } from '@/lib/utils' import { DEFAULT_ORG_COLOR } from '@/lib/theme-colors' interface LastConsultationCardProps { highlightedRoleId?: string | null focusRelatedIds?: Set | null } export function LastConsultationCard({ highlightedRoleId, focusRelatedIds }: LastConsultationCardProps) { const { openPanel } = useDetailPanel() const consultation = timelineConsultations.find(c => c.isCurrent) ?? timelineConsultations[0] if (!consultation) { return null } const isHighlighted = highlightedRoleId === consultation.id const isDimmed = focusRelatedIds != null && !focusRelatedIds.has(consultation.id) const handleOpenPanel = () => { openPanel({ type: 'consultation', consultation }) } const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault() handleOpenPanel() } } const formatDate = (dateStr: string): string => { const date = new Date(dateStr) return date.toLocaleDateString('en-GB', { month: 'long', year: 'numeric' }) } const getEmploymentType = (): string => { if (consultation.organization.includes('ICB')) { return 'Permanent · Full-time' } return 'Permanent' } const getBand = (): string => { return consultation.band ?? '—' } const fieldLabelStyle: React.CSSProperties = { fontSize: '12px', textTransform: 'uppercase', letterSpacing: '0.06em', color: 'var(--text-tertiary)', marginBottom: '3px', } const fieldValueStyle: React.CSSProperties = { fontSize: '13px', fontWeight: 600, color: 'var(--text-primary)', } return (
{ e.currentTarget.style.backgroundColor = hexToRgba(consultation.orgColor ?? DEFAULT_ORG_COLOR, 0.04) }} onMouseLeave={(e) => { e.currentTarget.style.backgroundColor = 'transparent' }} aria-label={`View full details for ${consultation.role}`} >
Date
{formatDate(consultation.date)}
Organisation
{consultation.organization}
Type
{getEmploymentType()}
Band
{getBand()}
{consultation.role}
) }