refactor(admin): split whistleblower page.tsx + restore scope helpers
Whistleblower (1220 -> 349 LOC) split into 6 colocated components:
TabNavigation, StatCard, FilterBar, ReportCard, WhistleblowerCreateModal,
CaseDetailPanel. All under the 300 LOC soft target.
Drive-by fix: the earlier fc6a330 split of compliance-scope-types.ts
dropped several helper exports that downstream consumers still import
(lib/sdk/index.ts, compliance-scope-engine.ts, obligations page,
compliance-scope page, constraint-enforcer, drafting-engine validate).
Restored them in the appropriate domain modules:
- core-levels.ts: maxDepthLevel, getDepthLevelNumeric, depthLevelFromNumeric
- state.ts: createEmptyScopeState
- decisions.ts: createEmptyScopeDecision + ApplicableRegulation,
RegulationObligation, RegulationAssessmentResult, SupervisoryAuthorityInfo
Verification: next build clean (142 pages generated), /sdk/whistleblower
still builds at ~11.5 kB.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,296 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import React, { useState } from 'react'
|
||||||
|
import {
|
||||||
|
WhistleblowerReport,
|
||||||
|
ReportStatus,
|
||||||
|
REPORT_CATEGORY_INFO,
|
||||||
|
REPORT_STATUS_INFO
|
||||||
|
} from '@/lib/sdk/whistleblower/types'
|
||||||
|
|
||||||
|
export function CaseDetailPanel({
|
||||||
|
report,
|
||||||
|
onClose,
|
||||||
|
onUpdated,
|
||||||
|
onDeleted,
|
||||||
|
}: {
|
||||||
|
report: WhistleblowerReport
|
||||||
|
onClose: () => void
|
||||||
|
onUpdated: () => void
|
||||||
|
onDeleted?: () => void
|
||||||
|
}) {
|
||||||
|
const [officerName, setOfficerName] = useState(report.assignedTo || '')
|
||||||
|
const [commentText, setCommentText] = useState('')
|
||||||
|
const [isSavingOfficer, setIsSavingOfficer] = useState(false)
|
||||||
|
const [isSavingStatus, setIsSavingStatus] = useState(false)
|
||||||
|
const [isSendingComment, setIsSendingComment] = useState(false)
|
||||||
|
const [isDeleting, setIsDeleting] = useState(false)
|
||||||
|
const [actionError, setActionError] = useState<string | null>(null)
|
||||||
|
|
||||||
|
const handleDeleteReport = async () => {
|
||||||
|
if (!window.confirm(`Meldung "${report.title}" wirklich löschen?`)) return
|
||||||
|
setIsDeleting(true)
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/sdk/v1/whistleblower/reports/${report.id}`, { method: 'DELETE' })
|
||||||
|
if (!res.ok) throw new Error(`Fehler: ${res.status}`)
|
||||||
|
onDeleted ? onDeleted() : onClose()
|
||||||
|
} catch (err: unknown) {
|
||||||
|
setActionError(err instanceof Error ? err.message : 'Löschen fehlgeschlagen.')
|
||||||
|
} finally {
|
||||||
|
setIsDeleting(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const categoryInfo = REPORT_CATEGORY_INFO[report.category]
|
||||||
|
const statusInfo = REPORT_STATUS_INFO[report.status]
|
||||||
|
|
||||||
|
const statusTransitions: Partial<Record<ReportStatus, { label: string; next: string }[]>> = {
|
||||||
|
new: [{ label: 'Bestaetigen', next: 'acknowledged' }],
|
||||||
|
acknowledged: [{ label: 'Pruefung starten', next: 'under_review' }],
|
||||||
|
under_review: [{ label: 'Untersuchung starten', next: 'investigation' }],
|
||||||
|
investigation: [{ label: 'Massnahmen eingeleitet', next: 'measures_taken' }],
|
||||||
|
measures_taken: [{ label: 'Abschliessen', next: 'closed' }]
|
||||||
|
}
|
||||||
|
|
||||||
|
const transitions = statusTransitions[report.status] || []
|
||||||
|
|
||||||
|
const handleStatusChange = async (newStatus: string) => {
|
||||||
|
setIsSavingStatus(true)
|
||||||
|
setActionError(null)
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/sdk/v1/whistleblower/reports/${report.id}`, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ status: newStatus })
|
||||||
|
})
|
||||||
|
if (!res.ok) {
|
||||||
|
const data = await res.json().catch(() => ({}))
|
||||||
|
throw new Error(data?.detail || data?.message || `Fehler ${res.status}`)
|
||||||
|
}
|
||||||
|
onUpdated()
|
||||||
|
} catch (err: unknown) {
|
||||||
|
setActionError(err instanceof Error ? err.message : 'Unbekannter Fehler')
|
||||||
|
} finally {
|
||||||
|
setIsSavingStatus(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSaveOfficer = async () => {
|
||||||
|
setIsSavingOfficer(true)
|
||||||
|
setActionError(null)
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/sdk/v1/whistleblower/reports/${report.id}`, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ assignedTo: officerName })
|
||||||
|
})
|
||||||
|
if (!res.ok) {
|
||||||
|
const data = await res.json().catch(() => ({}))
|
||||||
|
throw new Error(data?.detail || data?.message || `Fehler ${res.status}`)
|
||||||
|
}
|
||||||
|
onUpdated()
|
||||||
|
} catch (err: unknown) {
|
||||||
|
setActionError(err instanceof Error ? err.message : 'Unbekannter Fehler')
|
||||||
|
} finally {
|
||||||
|
setIsSavingOfficer(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSendComment = async () => {
|
||||||
|
if (!commentText.trim()) return
|
||||||
|
setIsSendingComment(true)
|
||||||
|
setActionError(null)
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/sdk/v1/whistleblower/reports/${report.id}/messages`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ senderRole: 'ombudsperson', message: commentText.trim() })
|
||||||
|
})
|
||||||
|
if (!res.ok) {
|
||||||
|
const data = await res.json().catch(() => ({}))
|
||||||
|
throw new Error(data?.detail || data?.message || `Fehler ${res.status}`)
|
||||||
|
}
|
||||||
|
setCommentText('')
|
||||||
|
onUpdated()
|
||||||
|
} catch (err: unknown) {
|
||||||
|
setActionError(err instanceof Error ? err.message : 'Unbekannter Fehler')
|
||||||
|
} finally {
|
||||||
|
setIsSendingComment(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{/* Backdrop */}
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-40 bg-black/30"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Drawer */}
|
||||||
|
<div className="fixed right-0 top-0 bottom-0 z-50 w-[600px] bg-white shadow-2xl overflow-y-auto">
|
||||||
|
{/* Header */}
|
||||||
|
<div className="sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<p className="text-xs text-gray-500 font-mono">{report.referenceNumber}</p>
|
||||||
|
<h2 className="text-lg font-semibold text-gray-900 mt-0.5">{report.title}</h2>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={onClose}
|
||||||
|
className="p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="p-6 space-y-6">
|
||||||
|
{actionError && (
|
||||||
|
<div className="p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700">
|
||||||
|
{actionError}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Badges */}
|
||||||
|
<div className="flex items-center gap-2 flex-wrap">
|
||||||
|
<span className={`px-2 py-1 text-xs rounded-full ${categoryInfo.bgColor} ${categoryInfo.color}`}>
|
||||||
|
{categoryInfo.label}
|
||||||
|
</span>
|
||||||
|
<span className={`px-2 py-1 text-xs rounded-full ${statusInfo.bgColor} ${statusInfo.color}`}>
|
||||||
|
{statusInfo.label}
|
||||||
|
</span>
|
||||||
|
{report.isAnonymous && (
|
||||||
|
<span className="px-2 py-1 text-xs bg-gray-100 text-gray-700 rounded-full">
|
||||||
|
Anonym
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span className={`px-2 py-1 text-xs rounded-full ${
|
||||||
|
report.priority === 'critical' ? 'bg-red-100 text-red-700' :
|
||||||
|
report.priority === 'high' ? 'bg-orange-100 text-orange-700' :
|
||||||
|
'bg-gray-100 text-gray-600'
|
||||||
|
}`}>
|
||||||
|
{report.priority === 'critical' ? 'Kritisch' :
|
||||||
|
report.priority === 'high' ? 'Hoch' :
|
||||||
|
report.priority === 'normal' ? 'Normal' : 'Niedrig'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Description */}
|
||||||
|
<div>
|
||||||
|
<h3 className="text-sm font-medium text-gray-700 mb-2">Beschreibung</h3>
|
||||||
|
<p className="text-sm text-gray-600 whitespace-pre-wrap">{report.description}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Details */}
|
||||||
|
<div className="grid grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<p className="text-xs text-gray-500">Eingegangen am</p>
|
||||||
|
<p className="text-sm font-medium text-gray-900">
|
||||||
|
{new Date(report.receivedAt).toLocaleDateString('de-DE')}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="text-xs text-gray-500">Zugewiesen an</p>
|
||||||
|
<p className="text-sm font-medium text-gray-900">
|
||||||
|
{report.assignedTo || '—'}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Status Transitions */}
|
||||||
|
{transitions.length > 0 && (
|
||||||
|
<div>
|
||||||
|
<h3 className="text-sm font-medium text-gray-700 mb-3">Status aendern</h3>
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
{transitions.map((t) => (
|
||||||
|
<button
|
||||||
|
key={t.next}
|
||||||
|
onClick={() => handleStatusChange(t.next)}
|
||||||
|
disabled={isSavingStatus}
|
||||||
|
className="px-4 py-2 text-sm bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||||
|
>
|
||||||
|
{isSavingStatus ? 'Wird gespeichert...' : t.label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Assign Officer */}
|
||||||
|
<div>
|
||||||
|
<h3 className="text-sm font-medium text-gray-700 mb-2">Zuweisen an:</h3>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={officerName}
|
||||||
|
onChange={(e) => setOfficerName(e.target.value)}
|
||||||
|
className="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
||||||
|
placeholder="Name der zustaendigen Person"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
onClick={handleSaveOfficer}
|
||||||
|
disabled={isSavingOfficer}
|
||||||
|
className="px-4 py-2 text-sm bg-gray-800 text-white rounded-lg hover:bg-gray-900 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||||
|
>
|
||||||
|
{isSavingOfficer ? 'Speichern...' : 'Speichern'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Comment Section */}
|
||||||
|
<div>
|
||||||
|
<h3 className="text-sm font-medium text-gray-700 mb-2">Kommentar senden</h3>
|
||||||
|
<textarea
|
||||||
|
value={commentText}
|
||||||
|
onChange={(e) => setCommentText(e.target.value)}
|
||||||
|
rows={3}
|
||||||
|
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm resize-none"
|
||||||
|
placeholder="Kommentar eingeben..."
|
||||||
|
/>
|
||||||
|
<div className="mt-2 flex justify-end">
|
||||||
|
<button
|
||||||
|
onClick={handleSendComment}
|
||||||
|
disabled={isSendingComment || !commentText.trim()}
|
||||||
|
className="px-4 py-2 text-sm bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||||
|
>
|
||||||
|
{isSendingComment ? 'Wird gesendet...' : 'Kommentar senden'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Message History */}
|
||||||
|
{report.messages.length > 0 && (
|
||||||
|
<div>
|
||||||
|
<h3 className="text-sm font-medium text-gray-700 mb-3">Nachrichten ({report.messages.length})</h3>
|
||||||
|
<div className="space-y-3">
|
||||||
|
{report.messages.map((msg, idx) => (
|
||||||
|
<div key={idx} className="p-3 bg-gray-50 rounded-lg text-sm">
|
||||||
|
<div className="flex items-center justify-between mb-1">
|
||||||
|
<span className="font-medium text-gray-700">{msg.senderRole}</span>
|
||||||
|
<span className="text-xs text-gray-400">
|
||||||
|
{new Date(msg.sentAt).toLocaleDateString('de-DE')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p className="text-gray-600">{msg.message}</p>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Delete */}
|
||||||
|
<div className="pt-2 border-t border-gray-100">
|
||||||
|
<button
|
||||||
|
onClick={handleDeleteReport}
|
||||||
|
disabled={isDeleting}
|
||||||
|
className="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 text-sm transition-colors disabled:opacity-50"
|
||||||
|
>
|
||||||
|
{isDeleting ? 'Löschen...' : 'Löschen'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import React from 'react'
|
||||||
|
import {
|
||||||
|
ReportCategory,
|
||||||
|
ReportStatus,
|
||||||
|
ReportPriority,
|
||||||
|
REPORT_CATEGORY_INFO,
|
||||||
|
REPORT_STATUS_INFO
|
||||||
|
} from '@/lib/sdk/whistleblower/types'
|
||||||
|
|
||||||
|
export function FilterBar({
|
||||||
|
selectedCategory,
|
||||||
|
selectedStatus,
|
||||||
|
selectedPriority,
|
||||||
|
onCategoryChange,
|
||||||
|
onStatusChange,
|
||||||
|
onPriorityChange,
|
||||||
|
onClear
|
||||||
|
}: {
|
||||||
|
selectedCategory: ReportCategory | 'all'
|
||||||
|
selectedStatus: ReportStatus | 'all'
|
||||||
|
selectedPriority: ReportPriority | 'all'
|
||||||
|
onCategoryChange: (category: ReportCategory | 'all') => void
|
||||||
|
onStatusChange: (status: ReportStatus | 'all') => void
|
||||||
|
onPriorityChange: (priority: ReportPriority | 'all') => void
|
||||||
|
onClear: () => void
|
||||||
|
}) {
|
||||||
|
const hasFilters = selectedCategory !== 'all' || selectedStatus !== 'all' || selectedPriority !== 'all'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-4 flex-wrap">
|
||||||
|
<span className="text-sm text-gray-500">Filter:</span>
|
||||||
|
|
||||||
|
{/* Category Filter */}
|
||||||
|
<select
|
||||||
|
value={selectedCategory}
|
||||||
|
onChange={(e) => onCategoryChange(e.target.value as ReportCategory | 'all')}
|
||||||
|
className="px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500"
|
||||||
|
>
|
||||||
|
<option value="all">Alle Kategorien</option>
|
||||||
|
{Object.entries(REPORT_CATEGORY_INFO).map(([key, info]) => (
|
||||||
|
<option key={key} value={key}>{info.label}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
{/* Status Filter */}
|
||||||
|
<select
|
||||||
|
value={selectedStatus}
|
||||||
|
onChange={(e) => onStatusChange(e.target.value as ReportStatus | 'all')}
|
||||||
|
className="px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500"
|
||||||
|
>
|
||||||
|
<option value="all">Alle Status</option>
|
||||||
|
{Object.entries(REPORT_STATUS_INFO).map(([status, info]) => (
|
||||||
|
<option key={status} value={status}>{info.label}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
{/* Priority Filter */}
|
||||||
|
<select
|
||||||
|
value={selectedPriority}
|
||||||
|
onChange={(e) => onPriorityChange(e.target.value as ReportPriority | 'all')}
|
||||||
|
className="px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500"
|
||||||
|
>
|
||||||
|
<option value="all">Alle Prioritaeten</option>
|
||||||
|
<option value="critical">Kritisch</option>
|
||||||
|
<option value="high">Hoch</option>
|
||||||
|
<option value="normal">Normal</option>
|
||||||
|
<option value="low">Niedrig</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
{/* Clear Filters */}
|
||||||
|
{hasFilters && (
|
||||||
|
<button
|
||||||
|
onClick={onClear}
|
||||||
|
className="px-3 py-1.5 text-sm text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
Filter zuruecksetzen
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
'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<ReportPriority, string> = {
|
||||||
|
low: 'Niedrig',
|
||||||
|
normal: 'Normal',
|
||||||
|
high: 'Hoch',
|
||||||
|
critical: 'Kritisch'
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
onClick={onClick}
|
||||||
|
className={`
|
||||||
|
bg-white rounded-xl border-2 p-6 hover:shadow-md transition-all cursor-pointer
|
||||||
|
${ackOverdue || fbOverdue ? 'border-red-300 hover:border-red-400' :
|
||||||
|
report.priority === 'critical' ? 'border-orange-300 hover:border-orange-400' :
|
||||||
|
isClosed ? 'border-green-200 hover:border-green-300' :
|
||||||
|
'border-gray-200 hover:border-purple-300'
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
<div className="flex items-start justify-between">
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
{/* Header Badges */}
|
||||||
|
<div className="flex items-center gap-2 mb-2 flex-wrap">
|
||||||
|
<span className="text-xs text-gray-500 font-mono">
|
||||||
|
{report.referenceNumber}
|
||||||
|
</span>
|
||||||
|
<span className={`px-2 py-1 text-xs rounded-full ${categoryInfo.bgColor} ${categoryInfo.color}`}>
|
||||||
|
{categoryInfo.label}
|
||||||
|
</span>
|
||||||
|
<span className={`px-2 py-1 text-xs rounded-full ${statusInfo.bgColor} ${statusInfo.color}`}>
|
||||||
|
{statusInfo.label}
|
||||||
|
</span>
|
||||||
|
{report.isAnonymous && (
|
||||||
|
<span className="px-2 py-1 text-xs bg-gray-100 text-gray-700 rounded-full flex items-center gap-1">
|
||||||
|
<svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
||||||
|
</svg>
|
||||||
|
Anonym
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{report.priority === 'critical' && (
|
||||||
|
<span className="px-2 py-1 text-xs bg-red-100 text-red-700 rounded-full flex items-center gap-1">
|
||||||
|
<svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
|
||||||
|
</svg>
|
||||||
|
Kritisch
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{report.priority === 'high' && (
|
||||||
|
<span className="px-2 py-1 text-xs bg-orange-100 text-orange-700 rounded-full">
|
||||||
|
Hoch
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Title */}
|
||||||
|
<h3 className="text-lg font-semibold text-gray-900 truncate">
|
||||||
|
{report.title}
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
{/* Description Preview */}
|
||||||
|
{report.description && (
|
||||||
|
<p className="text-sm text-gray-500 mt-1 line-clamp-2">
|
||||||
|
{report.description}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Deadline Info */}
|
||||||
|
{!isClosed && (
|
||||||
|
<div className="flex items-center gap-4 mt-3 text-xs">
|
||||||
|
{report.status === 'new' && (
|
||||||
|
<span className={`flex items-center gap-1 ${ackOverdue ? 'text-red-600 font-medium' : daysAck <= 2 ? 'text-orange-600' : 'text-gray-500'}`}>
|
||||||
|
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||||
|
</svg>
|
||||||
|
{ackOverdue
|
||||||
|
? `Bestaetigung ${Math.abs(daysAck)} Tage ueberfaellig`
|
||||||
|
: `Bestaetigung in ${daysAck} Tagen`
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span className={`flex items-center gap-1 ${fbOverdue ? 'text-red-600 font-medium' : daysFb <= 14 ? 'text-orange-600' : 'text-gray-500'}`}>
|
||||||
|
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
||||||
|
</svg>
|
||||||
|
{fbOverdue
|
||||||
|
? `Rueckmeldung ${Math.abs(daysFb)} Tage ueberfaellig`
|
||||||
|
: `Rueckmeldung in ${daysFb} Tagen`
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Right Side - Date & Priority */}
|
||||||
|
<div className={`text-right ml-4 ${
|
||||||
|
ackOverdue || fbOverdue ? 'text-red-600' :
|
||||||
|
report.priority === 'critical' ? 'text-orange-600' :
|
||||||
|
'text-gray-500'
|
||||||
|
}`}>
|
||||||
|
<div className="text-sm font-medium">
|
||||||
|
{isClosed
|
||||||
|
? statusInfo.label
|
||||||
|
: ackOverdue
|
||||||
|
? 'Ueberfaellig'
|
||||||
|
: priorityLabels[report.priority]
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div className="text-xs mt-0.5">
|
||||||
|
{new Date(report.receivedAt).toLocaleDateString('de-DE')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Footer */}
|
||||||
|
<div className="mt-4 pt-4 border-t border-gray-100 flex items-center justify-between">
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<div className="text-sm text-gray-500">
|
||||||
|
{report.assignedTo
|
||||||
|
? `Zugewiesen: ${report.assignedTo}`
|
||||||
|
: 'Nicht zugewiesen'
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
{report.attachments.length > 0 && (
|
||||||
|
<span className="flex items-center gap-1 text-xs text-gray-400">
|
||||||
|
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13" />
|
||||||
|
</svg>
|
||||||
|
{report.attachments.length} Anhang{report.attachments.length !== 1 ? 'e' : ''}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{totalMeasures > 0 && (
|
||||||
|
<span className={`flex items-center gap-1 text-xs ${completedMeasures === totalMeasures ? 'text-green-600' : 'text-yellow-600'}`}>
|
||||||
|
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4" />
|
||||||
|
</svg>
|
||||||
|
{completedMeasures}/{totalMeasures} Massnahmen
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{report.messages.length > 0 && (
|
||||||
|
<span className="flex items-center gap-1 text-xs text-gray-400">
|
||||||
|
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" />
|
||||||
|
</svg>
|
||||||
|
{report.messages.length} Nachricht{report.messages.length !== 1 ? 'en' : ''}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
{!isClosed && (
|
||||||
|
<span className="px-3 py-1 text-sm text-purple-600 hover:bg-purple-50 rounded-lg transition-colors">
|
||||||
|
Bearbeiten
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{isClosed && (
|
||||||
|
<span className="px-3 py-1 text-sm text-gray-600 hover:bg-gray-100 rounded-lg transition-colors">
|
||||||
|
Details
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export function StatCard({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
color = 'gray',
|
||||||
|
icon,
|
||||||
|
trend
|
||||||
|
}: {
|
||||||
|
label: string
|
||||||
|
value: number | string
|
||||||
|
color?: 'gray' | 'blue' | 'yellow' | 'red' | 'green' | 'purple'
|
||||||
|
icon?: React.ReactNode
|
||||||
|
trend?: { value: number; label: string }
|
||||||
|
}) {
|
||||||
|
const colorClasses = {
|
||||||
|
gray: 'border-gray-200 text-gray-900',
|
||||||
|
blue: 'border-blue-200 text-blue-600',
|
||||||
|
yellow: 'border-yellow-200 text-yellow-600',
|
||||||
|
red: 'border-red-200 text-red-600',
|
||||||
|
green: 'border-green-200 text-green-600',
|
||||||
|
purple: 'border-purple-200 text-purple-600'
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`bg-white rounded-xl border ${colorClasses[color]} p-6`}>
|
||||||
|
<div className="flex items-start justify-between">
|
||||||
|
<div>
|
||||||
|
<div className={`text-sm ${color === 'gray' ? 'text-gray-500' : `text-${color}-600`}`}>
|
||||||
|
{label}
|
||||||
|
</div>
|
||||||
|
<div className={`text-3xl font-bold mt-1 ${colorClasses[color].split(' ')[1]}`}>
|
||||||
|
{value}
|
||||||
|
</div>
|
||||||
|
{trend && (
|
||||||
|
<div className={`text-xs mt-1 ${trend.value >= 0 ? 'text-green-600' : 'text-red-600'}`}>
|
||||||
|
{trend.value >= 0 ? '+' : ''}{trend.value} {trend.label}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{icon && (
|
||||||
|
<div className={`w-10 h-10 rounded-lg flex items-center justify-center bg-${color}-50`}>
|
||||||
|
{icon}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export type TabId = 'overview' | 'new_reports' | 'investigation' | 'closed' | 'settings'
|
||||||
|
|
||||||
|
export interface Tab {
|
||||||
|
id: TabId
|
||||||
|
label: string
|
||||||
|
count?: number
|
||||||
|
countColor?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TabNavigation({
|
||||||
|
tabs,
|
||||||
|
activeTab,
|
||||||
|
onTabChange
|
||||||
|
}: {
|
||||||
|
tabs: Tab[]
|
||||||
|
activeTab: TabId
|
||||||
|
onTabChange: (tab: TabId) => void
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="border-b border-gray-200">
|
||||||
|
<nav className="flex gap-1 -mb-px" aria-label="Tabs">
|
||||||
|
{tabs.map(tab => (
|
||||||
|
<button
|
||||||
|
key={tab.id}
|
||||||
|
onClick={() => onTabChange(tab.id)}
|
||||||
|
className={`
|
||||||
|
px-4 py-3 text-sm font-medium border-b-2 transition-colors
|
||||||
|
${activeTab === tab.id
|
||||||
|
? 'border-purple-600 text-purple-600'
|
||||||
|
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
{tab.label}
|
||||||
|
{tab.count !== undefined && tab.count > 0 && (
|
||||||
|
<span className={`
|
||||||
|
px-2 py-0.5 text-xs rounded-full
|
||||||
|
${tab.countColor || 'bg-gray-100 text-gray-600'}
|
||||||
|
`}>
|
||||||
|
{tab.count}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
|
export function WhistleblowerCreateModal({
|
||||||
|
onClose,
|
||||||
|
onSuccess
|
||||||
|
}: {
|
||||||
|
onClose: () => void
|
||||||
|
onSuccess: () => void
|
||||||
|
}) {
|
||||||
|
const [title, setTitle] = useState('')
|
||||||
|
const [description, setDescription] = useState('')
|
||||||
|
const [category, setCategory] = useState<string>('corruption')
|
||||||
|
const [priority, setPriority] = useState<string>('normal')
|
||||||
|
const [isAnonymous, setIsAnonymous] = useState(true)
|
||||||
|
const [reporterName, setReporterName] = useState('')
|
||||||
|
const [reporterEmail, setReporterEmail] = useState('')
|
||||||
|
const [isSaving, setIsSaving] = useState(false)
|
||||||
|
const [error, setError] = useState<string | null>(null)
|
||||||
|
|
||||||
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
if (!title.trim() || !description.trim()) return
|
||||||
|
|
||||||
|
setIsSaving(true)
|
||||||
|
setError(null)
|
||||||
|
try {
|
||||||
|
const body: Record<string, unknown> = {
|
||||||
|
title: title.trim(),
|
||||||
|
description: description.trim(),
|
||||||
|
category,
|
||||||
|
priority,
|
||||||
|
isAnonymous,
|
||||||
|
status: 'new'
|
||||||
|
}
|
||||||
|
if (!isAnonymous) {
|
||||||
|
body.reporterName = reporterName.trim()
|
||||||
|
body.reporterEmail = reporterEmail.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await fetch('/api/sdk/v1/whistleblower/reports', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(body)
|
||||||
|
})
|
||||||
|
if (!res.ok) {
|
||||||
|
const data = await res.json().catch(() => ({}))
|
||||||
|
throw new Error(data?.detail || data?.message || `Fehler ${res.status}`)
|
||||||
|
}
|
||||||
|
onSuccess()
|
||||||
|
} catch (err: unknown) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Unbekannter Fehler')
|
||||||
|
} finally {
|
||||||
|
setIsSaving(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="fixed inset-0 z-50 flex items-center justify-center">
|
||||||
|
{/* Backdrop */}
|
||||||
|
<div
|
||||||
|
className="absolute inset-0 bg-black/50"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Modal */}
|
||||||
|
<div className="relative bg-white rounded-2xl shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto">
|
||||||
|
<div className="p-6">
|
||||||
|
<div className="flex items-center justify-between mb-6">
|
||||||
|
<h2 className="text-xl font-semibold text-gray-900">Neue Meldung erfassen</h2>
|
||||||
|
<button
|
||||||
|
onClick={onClose}
|
||||||
|
className="p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<div className="mb-4 p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700">
|
||||||
|
{error}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
|
{/* Title */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
Titel <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={title}
|
||||||
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
|
required
|
||||||
|
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
||||||
|
placeholder="Kurze Beschreibung des Vorfalls"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Description */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
Beschreibung <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
value={description}
|
||||||
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
|
required
|
||||||
|
rows={4}
|
||||||
|
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm resize-none"
|
||||||
|
placeholder="Detaillierte Beschreibung des Vorfalls..."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Category */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
Kategorie
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
value={category}
|
||||||
|
onChange={(e) => setCategory(e.target.value)}
|
||||||
|
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
||||||
|
>
|
||||||
|
<option value="corruption">Korruption</option>
|
||||||
|
<option value="fraud">Betrug</option>
|
||||||
|
<option value="data_protection">Datenschutz</option>
|
||||||
|
<option value="discrimination">Diskriminierung</option>
|
||||||
|
<option value="environment">Umwelt</option>
|
||||||
|
<option value="competition">Wettbewerb</option>
|
||||||
|
<option value="product_safety">Produktsicherheit</option>
|
||||||
|
<option value="tax_evasion">Steuerhinterziehung</option>
|
||||||
|
<option value="other">Sonstiges</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Priority */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
Prioritaet
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
value={priority}
|
||||||
|
onChange={(e) => setPriority(e.target.value)}
|
||||||
|
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
||||||
|
>
|
||||||
|
<option value="normal">Normal</option>
|
||||||
|
<option value="high">Hoch</option>
|
||||||
|
<option value="critical">Kritisch</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Anonymous */}
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="isAnonymous"
|
||||||
|
checked={isAnonymous}
|
||||||
|
onChange={(e) => setIsAnonymous(e.target.checked)}
|
||||||
|
className="w-4 h-4 text-purple-600 border-gray-300 rounded focus:ring-purple-500"
|
||||||
|
/>
|
||||||
|
<label htmlFor="isAnonymous" className="text-sm font-medium text-gray-700">
|
||||||
|
Anonyme Einreichung
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Reporter fields (only if not anonymous) */}
|
||||||
|
{!isAnonymous && (
|
||||||
|
<>
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
Name des Hinweisgebers
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={reporterName}
|
||||||
|
onChange={(e) => setReporterName(e.target.value)}
|
||||||
|
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
||||||
|
placeholder="Vor- und Nachname"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
|
E-Mail des Hinweisgebers
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="email"
|
||||||
|
value={reporterEmail}
|
||||||
|
onChange={(e) => setReporterEmail(e.target.value)}
|
||||||
|
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
||||||
|
placeholder="email@beispiel.de"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Buttons */}
|
||||||
|
<div className="flex items-center justify-end gap-3 pt-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onClose}
|
||||||
|
className="px-4 py-2 text-sm text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
Abbrechen
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={isSaving || !title.trim() || !description.trim()}
|
||||||
|
className="px-4 py-2 text-sm bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||||
|
>
|
||||||
|
{isSaving ? 'Wird eingereicht...' : 'Einreichen'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -9,887 +9,16 @@ import {
|
|||||||
ReportCategory,
|
ReportCategory,
|
||||||
ReportStatus,
|
ReportStatus,
|
||||||
ReportPriority,
|
ReportPriority,
|
||||||
REPORT_CATEGORY_INFO,
|
|
||||||
REPORT_STATUS_INFO,
|
|
||||||
isAcknowledgmentOverdue,
|
isAcknowledgmentOverdue,
|
||||||
isFeedbackOverdue,
|
isFeedbackOverdue,
|
||||||
getDaysUntilAcknowledgment,
|
|
||||||
getDaysUntilFeedback
|
|
||||||
} from '@/lib/sdk/whistleblower/types'
|
} from '@/lib/sdk/whistleblower/types'
|
||||||
import { fetchSDKWhistleblowerList } from '@/lib/sdk/whistleblower/api'
|
import { fetchSDKWhistleblowerList } from '@/lib/sdk/whistleblower/api'
|
||||||
|
import { TabNavigation, type Tab, type TabId } from './_components/TabNavigation'
|
||||||
// =============================================================================
|
import { StatCard } from './_components/StatCard'
|
||||||
// TYPES
|
import { FilterBar } from './_components/FilterBar'
|
||||||
// =============================================================================
|
import { ReportCard } from './_components/ReportCard'
|
||||||
|
import { WhistleblowerCreateModal } from './_components/WhistleblowerCreateModal'
|
||||||
type TabId = 'overview' | 'new_reports' | 'investigation' | 'closed' | 'settings'
|
import { CaseDetailPanel } from './_components/CaseDetailPanel'
|
||||||
|
|
||||||
interface Tab {
|
|
||||||
id: TabId
|
|
||||||
label: string
|
|
||||||
count?: number
|
|
||||||
countColor?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
// COMPONENTS
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
function TabNavigation({
|
|
||||||
tabs,
|
|
||||||
activeTab,
|
|
||||||
onTabChange
|
|
||||||
}: {
|
|
||||||
tabs: Tab[]
|
|
||||||
activeTab: TabId
|
|
||||||
onTabChange: (tab: TabId) => void
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<div className="border-b border-gray-200">
|
|
||||||
<nav className="flex gap-1 -mb-px" aria-label="Tabs">
|
|
||||||
{tabs.map(tab => (
|
|
||||||
<button
|
|
||||||
key={tab.id}
|
|
||||||
onClick={() => onTabChange(tab.id)}
|
|
||||||
className={`
|
|
||||||
px-4 py-3 text-sm font-medium border-b-2 transition-colors
|
|
||||||
${activeTab === tab.id
|
|
||||||
? 'border-purple-600 text-purple-600'
|
|
||||||
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<span className="flex items-center gap-2">
|
|
||||||
{tab.label}
|
|
||||||
{tab.count !== undefined && tab.count > 0 && (
|
|
||||||
<span className={`
|
|
||||||
px-2 py-0.5 text-xs rounded-full
|
|
||||||
${tab.countColor || 'bg-gray-100 text-gray-600'}
|
|
||||||
`}>
|
|
||||||
{tab.count}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function StatCard({
|
|
||||||
label,
|
|
||||||
value,
|
|
||||||
color = 'gray',
|
|
||||||
icon,
|
|
||||||
trend
|
|
||||||
}: {
|
|
||||||
label: string
|
|
||||||
value: number | string
|
|
||||||
color?: 'gray' | 'blue' | 'yellow' | 'red' | 'green' | 'purple'
|
|
||||||
icon?: React.ReactNode
|
|
||||||
trend?: { value: number; label: string }
|
|
||||||
}) {
|
|
||||||
const colorClasses = {
|
|
||||||
gray: 'border-gray-200 text-gray-900',
|
|
||||||
blue: 'border-blue-200 text-blue-600',
|
|
||||||
yellow: 'border-yellow-200 text-yellow-600',
|
|
||||||
red: 'border-red-200 text-red-600',
|
|
||||||
green: 'border-green-200 text-green-600',
|
|
||||||
purple: 'border-purple-200 text-purple-600'
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={`bg-white rounded-xl border ${colorClasses[color]} p-6`}>
|
|
||||||
<div className="flex items-start justify-between">
|
|
||||||
<div>
|
|
||||||
<div className={`text-sm ${color === 'gray' ? 'text-gray-500' : `text-${color}-600`}`}>
|
|
||||||
{label}
|
|
||||||
</div>
|
|
||||||
<div className={`text-3xl font-bold mt-1 ${colorClasses[color].split(' ')[1]}`}>
|
|
||||||
{value}
|
|
||||||
</div>
|
|
||||||
{trend && (
|
|
||||||
<div className={`text-xs mt-1 ${trend.value >= 0 ? 'text-green-600' : 'text-red-600'}`}>
|
|
||||||
{trend.value >= 0 ? '+' : ''}{trend.value} {trend.label}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{icon && (
|
|
||||||
<div className={`w-10 h-10 rounded-lg flex items-center justify-center bg-${color}-50`}>
|
|
||||||
{icon}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function FilterBar({
|
|
||||||
selectedCategory,
|
|
||||||
selectedStatus,
|
|
||||||
selectedPriority,
|
|
||||||
onCategoryChange,
|
|
||||||
onStatusChange,
|
|
||||||
onPriorityChange,
|
|
||||||
onClear
|
|
||||||
}: {
|
|
||||||
selectedCategory: ReportCategory | 'all'
|
|
||||||
selectedStatus: ReportStatus | 'all'
|
|
||||||
selectedPriority: ReportPriority | 'all'
|
|
||||||
onCategoryChange: (category: ReportCategory | 'all') => void
|
|
||||||
onStatusChange: (status: ReportStatus | 'all') => void
|
|
||||||
onPriorityChange: (priority: ReportPriority | 'all') => void
|
|
||||||
onClear: () => void
|
|
||||||
}) {
|
|
||||||
const hasFilters = selectedCategory !== 'all' || selectedStatus !== 'all' || selectedPriority !== 'all'
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex items-center gap-4 flex-wrap">
|
|
||||||
<span className="text-sm text-gray-500">Filter:</span>
|
|
||||||
|
|
||||||
{/* Category Filter */}
|
|
||||||
<select
|
|
||||||
value={selectedCategory}
|
|
||||||
onChange={(e) => onCategoryChange(e.target.value as ReportCategory | 'all')}
|
|
||||||
className="px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500"
|
|
||||||
>
|
|
||||||
<option value="all">Alle Kategorien</option>
|
|
||||||
{Object.entries(REPORT_CATEGORY_INFO).map(([key, info]) => (
|
|
||||||
<option key={key} value={key}>{info.label}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
{/* Status Filter */}
|
|
||||||
<select
|
|
||||||
value={selectedStatus}
|
|
||||||
onChange={(e) => onStatusChange(e.target.value as ReportStatus | 'all')}
|
|
||||||
className="px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500"
|
|
||||||
>
|
|
||||||
<option value="all">Alle Status</option>
|
|
||||||
{Object.entries(REPORT_STATUS_INFO).map(([status, info]) => (
|
|
||||||
<option key={status} value={status}>{info.label}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
{/* Priority Filter */}
|
|
||||||
<select
|
|
||||||
value={selectedPriority}
|
|
||||||
onChange={(e) => onPriorityChange(e.target.value as ReportPriority | 'all')}
|
|
||||||
className="px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500"
|
|
||||||
>
|
|
||||||
<option value="all">Alle Prioritaeten</option>
|
|
||||||
<option value="critical">Kritisch</option>
|
|
||||||
<option value="high">Hoch</option>
|
|
||||||
<option value="normal">Normal</option>
|
|
||||||
<option value="low">Niedrig</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
{/* Clear Filters */}
|
|
||||||
{hasFilters && (
|
|
||||||
<button
|
|
||||||
onClick={onClear}
|
|
||||||
className="px-3 py-1.5 text-sm text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-colors"
|
|
||||||
>
|
|
||||||
Filter zuruecksetzen
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
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<ReportPriority, string> = {
|
|
||||||
low: 'Niedrig',
|
|
||||||
normal: 'Normal',
|
|
||||||
high: 'Hoch',
|
|
||||||
critical: 'Kritisch'
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
onClick={onClick}
|
|
||||||
className={`
|
|
||||||
bg-white rounded-xl border-2 p-6 hover:shadow-md transition-all cursor-pointer
|
|
||||||
${ackOverdue || fbOverdue ? 'border-red-300 hover:border-red-400' :
|
|
||||||
report.priority === 'critical' ? 'border-orange-300 hover:border-orange-400' :
|
|
||||||
isClosed ? 'border-green-200 hover:border-green-300' :
|
|
||||||
'border-gray-200 hover:border-purple-300'
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<div className="flex items-start justify-between">
|
|
||||||
<div className="flex-1 min-w-0">
|
|
||||||
{/* Header Badges */}
|
|
||||||
<div className="flex items-center gap-2 mb-2 flex-wrap">
|
|
||||||
<span className="text-xs text-gray-500 font-mono">
|
|
||||||
{report.referenceNumber}
|
|
||||||
</span>
|
|
||||||
<span className={`px-2 py-1 text-xs rounded-full ${categoryInfo.bgColor} ${categoryInfo.color}`}>
|
|
||||||
{categoryInfo.label}
|
|
||||||
</span>
|
|
||||||
<span className={`px-2 py-1 text-xs rounded-full ${statusInfo.bgColor} ${statusInfo.color}`}>
|
|
||||||
{statusInfo.label}
|
|
||||||
</span>
|
|
||||||
{report.isAnonymous && (
|
|
||||||
<span className="px-2 py-1 text-xs bg-gray-100 text-gray-700 rounded-full flex items-center gap-1">
|
|
||||||
<svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
|
||||||
</svg>
|
|
||||||
Anonym
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{report.priority === 'critical' && (
|
|
||||||
<span className="px-2 py-1 text-xs bg-red-100 text-red-700 rounded-full flex items-center gap-1">
|
|
||||||
<svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
|
|
||||||
</svg>
|
|
||||||
Kritisch
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{report.priority === 'high' && (
|
|
||||||
<span className="px-2 py-1 text-xs bg-orange-100 text-orange-700 rounded-full">
|
|
||||||
Hoch
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Title */}
|
|
||||||
<h3 className="text-lg font-semibold text-gray-900 truncate">
|
|
||||||
{report.title}
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
{/* Description Preview */}
|
|
||||||
{report.description && (
|
|
||||||
<p className="text-sm text-gray-500 mt-1 line-clamp-2">
|
|
||||||
{report.description}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Deadline Info */}
|
|
||||||
{!isClosed && (
|
|
||||||
<div className="flex items-center gap-4 mt-3 text-xs">
|
|
||||||
{report.status === 'new' && (
|
|
||||||
<span className={`flex items-center gap-1 ${ackOverdue ? 'text-red-600 font-medium' : daysAck <= 2 ? 'text-orange-600' : 'text-gray-500'}`}>
|
|
||||||
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
||||||
</svg>
|
|
||||||
{ackOverdue
|
|
||||||
? `Bestaetigung ${Math.abs(daysAck)} Tage ueberfaellig`
|
|
||||||
: `Bestaetigung in ${daysAck} Tagen`
|
|
||||||
}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<span className={`flex items-center gap-1 ${fbOverdue ? 'text-red-600 font-medium' : daysFb <= 14 ? 'text-orange-600' : 'text-gray-500'}`}>
|
|
||||||
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
|
||||||
</svg>
|
|
||||||
{fbOverdue
|
|
||||||
? `Rueckmeldung ${Math.abs(daysFb)} Tage ueberfaellig`
|
|
||||||
: `Rueckmeldung in ${daysFb} Tagen`
|
|
||||||
}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right Side - Date & Priority */}
|
|
||||||
<div className={`text-right ml-4 ${
|
|
||||||
ackOverdue || fbOverdue ? 'text-red-600' :
|
|
||||||
report.priority === 'critical' ? 'text-orange-600' :
|
|
||||||
'text-gray-500'
|
|
||||||
}`}>
|
|
||||||
<div className="text-sm font-medium">
|
|
||||||
{isClosed
|
|
||||||
? statusInfo.label
|
|
||||||
: ackOverdue
|
|
||||||
? 'Ueberfaellig'
|
|
||||||
: priorityLabels[report.priority]
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<div className="text-xs mt-0.5">
|
|
||||||
{new Date(report.receivedAt).toLocaleDateString('de-DE')}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Footer */}
|
|
||||||
<div className="mt-4 pt-4 border-t border-gray-100 flex items-center justify-between">
|
|
||||||
<div className="flex items-center gap-4">
|
|
||||||
<div className="text-sm text-gray-500">
|
|
||||||
{report.assignedTo
|
|
||||||
? `Zugewiesen: ${report.assignedTo}`
|
|
||||||
: 'Nicht zugewiesen'
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
{report.attachments.length > 0 && (
|
|
||||||
<span className="flex items-center gap-1 text-xs text-gray-400">
|
|
||||||
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13" />
|
|
||||||
</svg>
|
|
||||||
{report.attachments.length} Anhang{report.attachments.length !== 1 ? 'e' : ''}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{totalMeasures > 0 && (
|
|
||||||
<span className={`flex items-center gap-1 text-xs ${completedMeasures === totalMeasures ? 'text-green-600' : 'text-yellow-600'}`}>
|
|
||||||
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4" />
|
|
||||||
</svg>
|
|
||||||
{completedMeasures}/{totalMeasures} Massnahmen
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{report.messages.length > 0 && (
|
|
||||||
<span className="flex items-center gap-1 text-xs text-gray-400">
|
|
||||||
<svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" />
|
|
||||||
</svg>
|
|
||||||
{report.messages.length} Nachricht{report.messages.length !== 1 ? 'en' : ''}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{!isClosed && (
|
|
||||||
<span className="px-3 py-1 text-sm text-purple-600 hover:bg-purple-50 rounded-lg transition-colors">
|
|
||||||
Bearbeiten
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{isClosed && (
|
|
||||||
<span className="px-3 py-1 text-sm text-gray-600 hover:bg-gray-100 rounded-lg transition-colors">
|
|
||||||
Details
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
// WHISTLEBLOWER CREATE MODAL
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
function WhistleblowerCreateModal({
|
|
||||||
onClose,
|
|
||||||
onSuccess
|
|
||||||
}: {
|
|
||||||
onClose: () => void
|
|
||||||
onSuccess: () => void
|
|
||||||
}) {
|
|
||||||
const [title, setTitle] = useState('')
|
|
||||||
const [description, setDescription] = useState('')
|
|
||||||
const [category, setCategory] = useState<string>('corruption')
|
|
||||||
const [priority, setPriority] = useState<string>('normal')
|
|
||||||
const [isAnonymous, setIsAnonymous] = useState(true)
|
|
||||||
const [reporterName, setReporterName] = useState('')
|
|
||||||
const [reporterEmail, setReporterEmail] = useState('')
|
|
||||||
const [isSaving, setIsSaving] = useState(false)
|
|
||||||
const [error, setError] = useState<string | null>(null)
|
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
|
||||||
e.preventDefault()
|
|
||||||
if (!title.trim() || !description.trim()) return
|
|
||||||
|
|
||||||
setIsSaving(true)
|
|
||||||
setError(null)
|
|
||||||
try {
|
|
||||||
const body: Record<string, unknown> = {
|
|
||||||
title: title.trim(),
|
|
||||||
description: description.trim(),
|
|
||||||
category,
|
|
||||||
priority,
|
|
||||||
isAnonymous,
|
|
||||||
status: 'new'
|
|
||||||
}
|
|
||||||
if (!isAnonymous) {
|
|
||||||
body.reporterName = reporterName.trim()
|
|
||||||
body.reporterEmail = reporterEmail.trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await fetch('/api/sdk/v1/whistleblower/reports', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify(body)
|
|
||||||
})
|
|
||||||
if (!res.ok) {
|
|
||||||
const data = await res.json().catch(() => ({}))
|
|
||||||
throw new Error(data?.detail || data?.message || `Fehler ${res.status}`)
|
|
||||||
}
|
|
||||||
onSuccess()
|
|
||||||
} catch (err: unknown) {
|
|
||||||
setError(err instanceof Error ? err.message : 'Unbekannter Fehler')
|
|
||||||
} finally {
|
|
||||||
setIsSaving(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="fixed inset-0 z-50 flex items-center justify-center">
|
|
||||||
{/* Backdrop */}
|
|
||||||
<div
|
|
||||||
className="absolute inset-0 bg-black/50"
|
|
||||||
onClick={onClose}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Modal */}
|
|
||||||
<div className="relative bg-white rounded-2xl shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto">
|
|
||||||
<div className="p-6">
|
|
||||||
<div className="flex items-center justify-between mb-6">
|
|
||||||
<h2 className="text-xl font-semibold text-gray-900">Neue Meldung erfassen</h2>
|
|
||||||
<button
|
|
||||||
onClick={onClose}
|
|
||||||
className="p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
|
|
||||||
>
|
|
||||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{error && (
|
|
||||||
<div className="mb-4 p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700">
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
|
||||||
{/* Title */}
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
||||||
Titel <span className="text-red-500">*</span>
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={title}
|
|
||||||
onChange={(e) => setTitle(e.target.value)}
|
|
||||||
required
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
|
||||||
placeholder="Kurze Beschreibung des Vorfalls"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Description */}
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
||||||
Beschreibung <span className="text-red-500">*</span>
|
|
||||||
</label>
|
|
||||||
<textarea
|
|
||||||
value={description}
|
|
||||||
onChange={(e) => setDescription(e.target.value)}
|
|
||||||
required
|
|
||||||
rows={4}
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm resize-none"
|
|
||||||
placeholder="Detaillierte Beschreibung des Vorfalls..."
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Category */}
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
||||||
Kategorie
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
value={category}
|
|
||||||
onChange={(e) => setCategory(e.target.value)}
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
|
||||||
>
|
|
||||||
<option value="corruption">Korruption</option>
|
|
||||||
<option value="fraud">Betrug</option>
|
|
||||||
<option value="data_protection">Datenschutz</option>
|
|
||||||
<option value="discrimination">Diskriminierung</option>
|
|
||||||
<option value="environment">Umwelt</option>
|
|
||||||
<option value="competition">Wettbewerb</option>
|
|
||||||
<option value="product_safety">Produktsicherheit</option>
|
|
||||||
<option value="tax_evasion">Steuerhinterziehung</option>
|
|
||||||
<option value="other">Sonstiges</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Priority */}
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
||||||
Prioritaet
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
value={priority}
|
|
||||||
onChange={(e) => setPriority(e.target.value)}
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
|
||||||
>
|
|
||||||
<option value="normal">Normal</option>
|
|
||||||
<option value="high">Hoch</option>
|
|
||||||
<option value="critical">Kritisch</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Anonymous */}
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
id="isAnonymous"
|
|
||||||
checked={isAnonymous}
|
|
||||||
onChange={(e) => setIsAnonymous(e.target.checked)}
|
|
||||||
className="w-4 h-4 text-purple-600 border-gray-300 rounded focus:ring-purple-500"
|
|
||||||
/>
|
|
||||||
<label htmlFor="isAnonymous" className="text-sm font-medium text-gray-700">
|
|
||||||
Anonyme Einreichung
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Reporter fields (only if not anonymous) */}
|
|
||||||
{!isAnonymous && (
|
|
||||||
<>
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
||||||
Name des Hinweisgebers
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={reporterName}
|
|
||||||
onChange={(e) => setReporterName(e.target.value)}
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
|
||||||
placeholder="Vor- und Nachname"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
||||||
E-Mail des Hinweisgebers
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="email"
|
|
||||||
value={reporterEmail}
|
|
||||||
onChange={(e) => setReporterEmail(e.target.value)}
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
|
||||||
placeholder="email@beispiel.de"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Buttons */}
|
|
||||||
<div className="flex items-center justify-end gap-3 pt-2">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={onClose}
|
|
||||||
className="px-4 py-2 text-sm text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
|
|
||||||
>
|
|
||||||
Abbrechen
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
disabled={isSaving || !title.trim() || !description.trim()}
|
|
||||||
className="px-4 py-2 text-sm bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
|
||||||
>
|
|
||||||
{isSaving ? 'Wird eingereicht...' : 'Einreichen'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
// CASE DETAIL PANEL
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
function CaseDetailPanel({
|
|
||||||
report,
|
|
||||||
onClose,
|
|
||||||
onUpdated,
|
|
||||||
onDeleted,
|
|
||||||
}: {
|
|
||||||
report: WhistleblowerReport
|
|
||||||
onClose: () => void
|
|
||||||
onUpdated: () => void
|
|
||||||
onDeleted?: () => void
|
|
||||||
}) {
|
|
||||||
const [officerName, setOfficerName] = useState(report.assignedTo || '')
|
|
||||||
const [commentText, setCommentText] = useState('')
|
|
||||||
const [isSavingOfficer, setIsSavingOfficer] = useState(false)
|
|
||||||
const [isSavingStatus, setIsSavingStatus] = useState(false)
|
|
||||||
const [isSendingComment, setIsSendingComment] = useState(false)
|
|
||||||
const [isDeleting, setIsDeleting] = useState(false)
|
|
||||||
const [actionError, setActionError] = useState<string | null>(null)
|
|
||||||
|
|
||||||
const handleDeleteReport = async () => {
|
|
||||||
if (!window.confirm(`Meldung "${report.title}" wirklich löschen?`)) return
|
|
||||||
setIsDeleting(true)
|
|
||||||
try {
|
|
||||||
const res = await fetch(`/api/sdk/v1/whistleblower/reports/${report.id}`, { method: 'DELETE' })
|
|
||||||
if (!res.ok) throw new Error(`Fehler: ${res.status}`)
|
|
||||||
onDeleted ? onDeleted() : onClose()
|
|
||||||
} catch (err: unknown) {
|
|
||||||
setActionError(err instanceof Error ? err.message : 'Löschen fehlgeschlagen.')
|
|
||||||
} finally {
|
|
||||||
setIsDeleting(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const categoryInfo = REPORT_CATEGORY_INFO[report.category]
|
|
||||||
const statusInfo = REPORT_STATUS_INFO[report.status]
|
|
||||||
|
|
||||||
const statusTransitions: Partial<Record<ReportStatus, { label: string; next: string }[]>> = {
|
|
||||||
new: [{ label: 'Bestaetigen', next: 'acknowledged' }],
|
|
||||||
acknowledged: [{ label: 'Pruefung starten', next: 'under_review' }],
|
|
||||||
under_review: [{ label: 'Untersuchung starten', next: 'investigation' }],
|
|
||||||
investigation: [{ label: 'Massnahmen eingeleitet', next: 'measures_taken' }],
|
|
||||||
measures_taken: [{ label: 'Abschliessen', next: 'closed' }]
|
|
||||||
}
|
|
||||||
|
|
||||||
const transitions = statusTransitions[report.status] || []
|
|
||||||
|
|
||||||
const handleStatusChange = async (newStatus: string) => {
|
|
||||||
setIsSavingStatus(true)
|
|
||||||
setActionError(null)
|
|
||||||
try {
|
|
||||||
const res = await fetch(`/api/sdk/v1/whistleblower/reports/${report.id}`, {
|
|
||||||
method: 'PUT',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ status: newStatus })
|
|
||||||
})
|
|
||||||
if (!res.ok) {
|
|
||||||
const data = await res.json().catch(() => ({}))
|
|
||||||
throw new Error(data?.detail || data?.message || `Fehler ${res.status}`)
|
|
||||||
}
|
|
||||||
onUpdated()
|
|
||||||
} catch (err: unknown) {
|
|
||||||
setActionError(err instanceof Error ? err.message : 'Unbekannter Fehler')
|
|
||||||
} finally {
|
|
||||||
setIsSavingStatus(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSaveOfficer = async () => {
|
|
||||||
setIsSavingOfficer(true)
|
|
||||||
setActionError(null)
|
|
||||||
try {
|
|
||||||
const res = await fetch(`/api/sdk/v1/whistleblower/reports/${report.id}`, {
|
|
||||||
method: 'PUT',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ assignedTo: officerName })
|
|
||||||
})
|
|
||||||
if (!res.ok) {
|
|
||||||
const data = await res.json().catch(() => ({}))
|
|
||||||
throw new Error(data?.detail || data?.message || `Fehler ${res.status}`)
|
|
||||||
}
|
|
||||||
onUpdated()
|
|
||||||
} catch (err: unknown) {
|
|
||||||
setActionError(err instanceof Error ? err.message : 'Unbekannter Fehler')
|
|
||||||
} finally {
|
|
||||||
setIsSavingOfficer(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSendComment = async () => {
|
|
||||||
if (!commentText.trim()) return
|
|
||||||
setIsSendingComment(true)
|
|
||||||
setActionError(null)
|
|
||||||
try {
|
|
||||||
const res = await fetch(`/api/sdk/v1/whistleblower/reports/${report.id}/messages`, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ senderRole: 'ombudsperson', message: commentText.trim() })
|
|
||||||
})
|
|
||||||
if (!res.ok) {
|
|
||||||
const data = await res.json().catch(() => ({}))
|
|
||||||
throw new Error(data?.detail || data?.message || `Fehler ${res.status}`)
|
|
||||||
}
|
|
||||||
setCommentText('')
|
|
||||||
onUpdated()
|
|
||||||
} catch (err: unknown) {
|
|
||||||
setActionError(err instanceof Error ? err.message : 'Unbekannter Fehler')
|
|
||||||
} finally {
|
|
||||||
setIsSendingComment(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{/* Backdrop */}
|
|
||||||
<div
|
|
||||||
className="fixed inset-0 z-40 bg-black/30"
|
|
||||||
onClick={onClose}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Drawer */}
|
|
||||||
<div className="fixed right-0 top-0 bottom-0 z-50 w-[600px] bg-white shadow-2xl overflow-y-auto">
|
|
||||||
{/* Header */}
|
|
||||||
<div className="sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between">
|
|
||||||
<div>
|
|
||||||
<p className="text-xs text-gray-500 font-mono">{report.referenceNumber}</p>
|
|
||||||
<h2 className="text-lg font-semibold text-gray-900 mt-0.5">{report.title}</h2>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
onClick={onClose}
|
|
||||||
className="p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
|
|
||||||
>
|
|
||||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="p-6 space-y-6">
|
|
||||||
{actionError && (
|
|
||||||
<div className="p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700">
|
|
||||||
{actionError}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Badges */}
|
|
||||||
<div className="flex items-center gap-2 flex-wrap">
|
|
||||||
<span className={`px-2 py-1 text-xs rounded-full ${categoryInfo.bgColor} ${categoryInfo.color}`}>
|
|
||||||
{categoryInfo.label}
|
|
||||||
</span>
|
|
||||||
<span className={`px-2 py-1 text-xs rounded-full ${statusInfo.bgColor} ${statusInfo.color}`}>
|
|
||||||
{statusInfo.label}
|
|
||||||
</span>
|
|
||||||
{report.isAnonymous && (
|
|
||||||
<span className="px-2 py-1 text-xs bg-gray-100 text-gray-700 rounded-full">
|
|
||||||
Anonym
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<span className={`px-2 py-1 text-xs rounded-full ${
|
|
||||||
report.priority === 'critical' ? 'bg-red-100 text-red-700' :
|
|
||||||
report.priority === 'high' ? 'bg-orange-100 text-orange-700' :
|
|
||||||
'bg-gray-100 text-gray-600'
|
|
||||||
}`}>
|
|
||||||
{report.priority === 'critical' ? 'Kritisch' :
|
|
||||||
report.priority === 'high' ? 'Hoch' :
|
|
||||||
report.priority === 'normal' ? 'Normal' : 'Niedrig'}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Description */}
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-medium text-gray-700 mb-2">Beschreibung</h3>
|
|
||||||
<p className="text-sm text-gray-600 whitespace-pre-wrap">{report.description}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Details */}
|
|
||||||
<div className="grid grid-cols-2 gap-4">
|
|
||||||
<div>
|
|
||||||
<p className="text-xs text-gray-500">Eingegangen am</p>
|
|
||||||
<p className="text-sm font-medium text-gray-900">
|
|
||||||
{new Date(report.receivedAt).toLocaleDateString('de-DE')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p className="text-xs text-gray-500">Zugewiesen an</p>
|
|
||||||
<p className="text-sm font-medium text-gray-900">
|
|
||||||
{report.assignedTo || '—'}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Status Transitions */}
|
|
||||||
{transitions.length > 0 && (
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-medium text-gray-700 mb-3">Status aendern</h3>
|
|
||||||
<div className="flex flex-wrap gap-2">
|
|
||||||
{transitions.map((t) => (
|
|
||||||
<button
|
|
||||||
key={t.next}
|
|
||||||
onClick={() => handleStatusChange(t.next)}
|
|
||||||
disabled={isSavingStatus}
|
|
||||||
className="px-4 py-2 text-sm bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
|
||||||
>
|
|
||||||
{isSavingStatus ? 'Wird gespeichert...' : t.label}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Assign Officer */}
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-medium text-gray-700 mb-2">Zuweisen an:</h3>
|
|
||||||
<div className="flex gap-2">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={officerName}
|
|
||||||
onChange={(e) => setOfficerName(e.target.value)}
|
|
||||||
className="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm"
|
|
||||||
placeholder="Name der zustaendigen Person"
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
onClick={handleSaveOfficer}
|
|
||||||
disabled={isSavingOfficer}
|
|
||||||
className="px-4 py-2 text-sm bg-gray-800 text-white rounded-lg hover:bg-gray-900 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
|
||||||
>
|
|
||||||
{isSavingOfficer ? 'Speichern...' : 'Speichern'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Comment Section */}
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-medium text-gray-700 mb-2">Kommentar senden</h3>
|
|
||||||
<textarea
|
|
||||||
value={commentText}
|
|
||||||
onChange={(e) => setCommentText(e.target.value)}
|
|
||||||
rows={3}
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm resize-none"
|
|
||||||
placeholder="Kommentar eingeben..."
|
|
||||||
/>
|
|
||||||
<div className="mt-2 flex justify-end">
|
|
||||||
<button
|
|
||||||
onClick={handleSendComment}
|
|
||||||
disabled={isSendingComment || !commentText.trim()}
|
|
||||||
className="px-4 py-2 text-sm bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
|
||||||
>
|
|
||||||
{isSendingComment ? 'Wird gesendet...' : 'Kommentar senden'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Message History */}
|
|
||||||
{report.messages.length > 0 && (
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-medium text-gray-700 mb-3">Nachrichten ({report.messages.length})</h3>
|
|
||||||
<div className="space-y-3">
|
|
||||||
{report.messages.map((msg, idx) => (
|
|
||||||
<div key={idx} className="p-3 bg-gray-50 rounded-lg text-sm">
|
|
||||||
<div className="flex items-center justify-between mb-1">
|
|
||||||
<span className="font-medium text-gray-700">{msg.senderRole}</span>
|
|
||||||
<span className="text-xs text-gray-400">
|
|
||||||
{new Date(msg.sentAt).toLocaleDateString('de-DE')}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p className="text-gray-600">{msg.message}</p>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Delete */}
|
|
||||||
<div className="pt-2 border-t border-gray-100">
|
|
||||||
<button
|
|
||||||
onClick={handleDeleteReport}
|
|
||||||
disabled={isDeleting}
|
|
||||||
className="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 text-sm transition-colors disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{isDeleting ? 'Löschen...' : 'Löschen'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// MAIN PAGE
|
// MAIN PAGE
|
||||||
|
|||||||
@@ -27,3 +27,42 @@ export interface ComplianceScores {
|
|||||||
/** Zusammengesetzter Score (0-100): Gewichtete Kombination aller Scores */
|
/** Zusammengesetzter Score (0-100): Gewichtete Kombination aller Scores */
|
||||||
composite_score: number;
|
composite_score: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt das höhere von zwei Depth Levels zurück.
|
||||||
|
*/
|
||||||
|
export function maxDepthLevel(
|
||||||
|
a: ComplianceDepthLevel,
|
||||||
|
b: ComplianceDepthLevel
|
||||||
|
): ComplianceDepthLevel {
|
||||||
|
const levels: ComplianceDepthLevel[] = ['L1', 'L2', 'L3', 'L4'];
|
||||||
|
const indexA = levels.indexOf(a);
|
||||||
|
const indexB = levels.indexOf(b);
|
||||||
|
return levels[Math.max(indexA, indexB)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Konvertiert Depth Level zu numerischem Wert (1-4).
|
||||||
|
*/
|
||||||
|
export function getDepthLevelNumeric(level: ComplianceDepthLevel): number {
|
||||||
|
const map: Record<ComplianceDepthLevel, number> = {
|
||||||
|
L1: 1,
|
||||||
|
L2: 2,
|
||||||
|
L3: 3,
|
||||||
|
L4: 4,
|
||||||
|
};
|
||||||
|
return map[level];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Konvertiert numerischen Wert (1-4) zu Depth Level.
|
||||||
|
*/
|
||||||
|
export function depthLevelFromNumeric(n: number): ComplianceDepthLevel {
|
||||||
|
const map: Record<number, ComplianceDepthLevel> = {
|
||||||
|
1: 'L1',
|
||||||
|
2: 'L2',
|
||||||
|
3: 'L3',
|
||||||
|
4: 'L4',
|
||||||
|
};
|
||||||
|
return map[Math.max(1, Math.min(4, Math.round(n)))] || 'L1';
|
||||||
|
}
|
||||||
|
|||||||
@@ -109,3 +109,79 @@ export interface ScopeReasoning {
|
|||||||
/** Auswirkung */
|
/** Auswirkung */
|
||||||
impact: string;
|
impact: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erstellt eine leere ScopeDecision mit Default-Werten.
|
||||||
|
*/
|
||||||
|
export function createEmptyScopeDecision(): ScopeDecision {
|
||||||
|
return {
|
||||||
|
id: `decision_${Date.now()}`,
|
||||||
|
determinedLevel: 'L1',
|
||||||
|
scores: {
|
||||||
|
risk_score: 0,
|
||||||
|
complexity_score: 0,
|
||||||
|
assurance_need: 0,
|
||||||
|
composite_score: 0,
|
||||||
|
},
|
||||||
|
triggeredHardTriggers: [],
|
||||||
|
requiredDocuments: [],
|
||||||
|
riskFlags: [],
|
||||||
|
gaps: [],
|
||||||
|
nextActions: [],
|
||||||
|
reasoning: [],
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
updatedAt: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// Regulation Assessment Types (from Go AI SDK /assess-from-scope)
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
/** Eine anwendbare Regulierung (aus Go SDK ApplicableRegulation). */
|
||||||
|
export interface ApplicableRegulation {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
classification: string
|
||||||
|
reason: string
|
||||||
|
obligation_count: number
|
||||||
|
control_count: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Einzelne Pflicht aus dem Go SDK. */
|
||||||
|
export interface RegulationObligation {
|
||||||
|
id: string
|
||||||
|
regulation_id: string
|
||||||
|
title: string
|
||||||
|
description: string
|
||||||
|
category: string
|
||||||
|
responsible: string
|
||||||
|
priority: string
|
||||||
|
legal_basis?: Array<{ article: string; name: string }>
|
||||||
|
how_to_implement?: string
|
||||||
|
breakpilot_feature?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ergebnis der Regulierungs-Bewertung vom Go AI SDK. */
|
||||||
|
export interface RegulationAssessmentResult {
|
||||||
|
applicable_regulations: ApplicableRegulation[]
|
||||||
|
obligations: RegulationObligation[]
|
||||||
|
executive_summary: {
|
||||||
|
total_regulations: number
|
||||||
|
total_obligations: number
|
||||||
|
critical_obligations: number
|
||||||
|
compliance_score: number
|
||||||
|
key_risks: string[]
|
||||||
|
recommended_actions: string[]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Aufsichtsbehoerden-Ergebnis. */
|
||||||
|
export interface SupervisoryAuthorityInfo {
|
||||||
|
domain: string
|
||||||
|
authority: {
|
||||||
|
name: string
|
||||||
|
abbreviation: string
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,3 +20,15 @@ export interface ComplianceScopeState {
|
|||||||
/** Sind alle Pflichtfragen beantwortet? */
|
/** Sind alle Pflichtfragen beantwortet? */
|
||||||
isComplete: boolean;
|
isComplete: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erstellt einen leeren ComplianceScopeState mit Default-Werten.
|
||||||
|
*/
|
||||||
|
export function createEmptyScopeState(): ComplianceScopeState {
|
||||||
|
return {
|
||||||
|
answers: [],
|
||||||
|
decision: null,
|
||||||
|
lastEvaluatedAt: null,
|
||||||
|
isComplete: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user