'use client' import React from 'react' import { WhistleblowerReport, ReportPriority, REPORT_CATEGORY_INFO, REPORT_STATUS_INFO, isAcknowledgmentOverdue, isFeedbackOverdue, getDaysUntilAcknowledgment, getDaysUntilFeedback } from '@/lib/sdk/whistleblower/types' export function ReportCard({ report, onClick }: { report: WhistleblowerReport; onClick?: () => void }) { const categoryInfo = REPORT_CATEGORY_INFO[report.category] const statusInfo = REPORT_STATUS_INFO[report.status] const isClosed = report.status === 'closed' || report.status === 'rejected' const ackOverdue = isAcknowledgmentOverdue(report) const fbOverdue = isFeedbackOverdue(report) const daysAck = getDaysUntilAcknowledgment(report) const daysFb = getDaysUntilFeedback(report) const completedMeasures = report.measures.filter(m => m.status === 'completed').length const totalMeasures = report.measures.length const priorityLabels: Record = { low: 'Niedrig', normal: 'Normal', high: 'Hoch', critical: 'Kritisch' } return (
{/* Header Badges */}
{report.referenceNumber} {categoryInfo.label} {statusInfo.label} {report.isAnonymous && ( Anonym )} {report.priority === 'critical' && ( Kritisch )} {report.priority === 'high' && ( Hoch )}
{/* Title */}

{report.title}

{/* Description Preview */} {report.description && (

{report.description}

)} {/* Deadline Info */} {!isClosed && (
{report.status === 'new' && ( {ackOverdue ? `Bestaetigung ${Math.abs(daysAck)} Tage ueberfaellig` : `Bestaetigung in ${daysAck} Tagen` } )} {fbOverdue ? `Rueckmeldung ${Math.abs(daysFb)} Tage ueberfaellig` : `Rueckmeldung in ${daysFb} Tagen` }
)}
{/* Right Side - Date & Priority */}
{isClosed ? statusInfo.label : ackOverdue ? 'Ueberfaellig' : priorityLabels[report.priority] }
{new Date(report.receivedAt).toLocaleDateString('de-DE')}
{/* Footer */}
{report.assignedTo ? `Zugewiesen: ${report.assignedTo}` : 'Nicht zugewiesen' }
{report.attachments.length > 0 && ( {report.attachments.length} Anhang{report.attachments.length !== 1 ? 'e' : ''} )} {totalMeasures > 0 && ( {completedMeasures}/{totalMeasures} Massnahmen )} {report.messages.length > 0 && ( {report.messages.length} Nachricht{report.messages.length !== 1 ? 'en' : ''} )}
{!isClosed && ( Bearbeiten )} {isClosed && ( Details )}
) }