/** * ReportsBlock Component * E5.S2: Rapportages laatste 24 uur */ import { FileText, Clock, User } from 'lucide-react'; import type { Report } from '@/lib/types/overdracht'; interface ReportsBlockProps { reports: Report[]; } function getReportTypeLabel(type: string): string { const types: Record = { voortgang: 'Voortgang', observatie: 'Observatie', incident: 'Incident', medicatie: 'Medicatie', contact: 'Contact', crisis: 'Crisis', intake: 'Intake', behandeladvies: 'Behandeladvies', vrije_notitie: 'Vrije notitie', }; return types[type] || type; } function getReportTypeStyle(type: string): { bg: string; text: string } { switch (type) { case 'incident': case 'crisis': return { bg: 'bg-red-100', text: 'text-red-700' }; case 'observatie': return { bg: 'bg-blue-100', text: 'text-blue-700' }; case 'voortgang': return { bg: 'bg-green-100', text: 'text-green-700' }; case 'medicatie': return { bg: 'bg-purple-100', text: 'text-purple-700' }; case 'contact': return { bg: 'bg-amber-100', text: 'text-amber-700' }; case 'intake': return { bg: 'bg-teal-100', text: 'text-teal-700' }; case 'behandeladvies': return { bg: 'bg-indigo-100', text: 'text-indigo-700' }; case 'vrije_notitie': default: return { bg: 'bg-slate-100', text: 'text-slate-700' }; } } function formatDateTime(datetime: string): string { const date = new Date(datetime); const now = new Date(); const isToday = date.toDateString() === now.toDateString(); if (isToday) { return date.toLocaleTimeString('nl-NL', { hour: '2-digit', minute: '2-digit', }); } return date.toLocaleDateString('nl-NL', { day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit', }); } function truncateContent(content: string, maxLength: number = 150): string { if (content.length <= maxLength) return content; return content.substring(0, maxLength).trim() + '...'; } export function ReportsBlock({ reports }: ReportsBlockProps) { const incidentCount = reports.filter(r => r.type === 'incident' || r.type === 'crisis').length; return (
{/* Header */}

Rapportages

{reports.length} rapportages (24u)

{incidentCount > 0 && ( {incidentCount} incident{incidentCount > 1 ? 'en' : ''} )}
{/* Content */} {reports.length === 0 ? (

Geen rapportages in de laatste 24 uur

) : (
{reports.map((report) => { const typeStyle = getReportTypeStyle(report.type); return (
{/* Report header */}
{getReportTypeLabel(report.type)}
{formatDateTime(report.created_at)}
{/* Report content */}

{truncateContent(report.content)}

{/* Author if available */} {report.created_by && (
{report.created_by}
)}
); })}
)}
); }