import { useParams } 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'; import { Link } from 'react-router-dom'; 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 [activeTab, setActiveTab] = useHashTab('schedule'); 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: 'schedule', label: 'Schedule' }, { id: 'description', label: 'Description' }, { id: 'simulations', label: 'Simulations', count: simCount }, ]; return (
Back to engagements

{eng.name}

Created by {eng.created_by.username}
{canEditEngagements ? (
Edit
) : null}
{activeTab === 'schedule' && (

Schedule

Start date
{eng.start_date}
End date
{eng.end_date ?? '—'}
Status
{eng.status}
Created at
{eng.created_at}
)} {activeTab === 'description' && (

Description

{eng.description?.trim() ? eng.description : 'No description provided.'}

)} {activeTab === 'simulations' && ( )}
); }