import { useParams, Link } from 'react-router-dom'; import { extractApiError } from '@/api/client'; import { useAuth } from '@/hooks/useAuth'; import { useEngagement } from '@/hooks/useEngagements'; import { useHashTab } from '@/hooks/useHashTab'; import { useEngagementSimulations } from '@/hooks/useSimulations'; import { LoadingState } from '@/components/LoadingState'; import { ErrorState } from '@/components/ErrorState'; import { StatusBadge } from '@/components/StatusBadge'; import { SimulationList } from '@/components/SimulationList'; import { ExportEngagementButton } from '@/components/ExportEngagementButton'; import { BackLink } from '@/components/BackLink'; import { Tabs } from '@/components/Tabs'; type TabId = 'description' | 'simulations'; export function EngagementDetailPage(): JSX.Element { const { id } = useParams<{ id: string }>(); const numericId = id ? Number(id) : undefined; const { canEditEngagements } = useAuth(); const detail = useEngagement(numericId); const simsQuery = useEngagementSimulations(numericId); const [activeTabRaw, setActiveTab] = useHashTab('description'); const activeTab = activeTabRaw as TabId; if (detail.isLoading) return ; if (detail.isError) { return ( detail.refetch()} /> ); } if (!detail.data) return ; const eng = detail.data; const simCount = simsQuery.data?.length; const tabs = [ { id: 'description', label: 'Description' }, { id: 'simulations', label: 'Simulations', count: simCount }, ]; return ( Back to engagements {eng.name} Created by {eng.created_by.username} {canEditEngagements ? ( ) : null} {activeTab === 'description' && ( Start date {eng.start_date} End date {eng.end_date ?? '—'} Status Created at {eng.created_at} {canEditEngagements ? ( Edit ) : null} Description {eng.description?.trim() ? eng.description : 'No description provided.'} )} {activeTab === 'simulations' && ( )} ); }
{eng.description?.trim() ? eng.description : 'No description provided.'}