'use client' import React, { useMemo } from 'react' import GapAnalysisView from '@/components/sdk/obligations/GapAnalysisView' import { ObligationDocumentTab } from '@/components/sdk/obligations/ObligationDocumentTab' import { useObligations } from './_hooks/useObligations' import ObligationModal from './_components/ObligationModal' import ObligationDetail from './_components/ObligationDetail' import ObligationCard from './_components/ObligationCard' import StatsGrid from './_components/StatsGrid' import FilterBar from './_components/FilterBar' import { ApplicableRegsBanner, NoProfileWarning, OverdueAlert, EmptyList } from './_components/InfoBanners' import ObligationsHeader from './_components/ObligationsHeader' // Tab definitions type Tab = 'uebersicht' | 'editor' | 'profiling' | 'gap-analyse' | 'pflichtenregister' const TABS: { key: Tab; label: string }[] = [ { key: 'uebersicht', label: 'Uebersicht' }, { key: 'editor', label: 'Detail-Editor' }, { key: 'profiling', label: 'Profiling' }, { key: 'gap-analyse', label: 'Gap-Analyse' }, { key: 'pflichtenregister', label: 'Pflichtenregister' }, ] export default function ObligationsPage() { const o = useObligations() const complianceScore = o.complianceResult ? o.complianceResult.score : null const renderUebersichtTab = () => ( <> {o.error && (
{o.error}
)} {!o.sdkState.companyProfile && } {o.complianceResult && o.complianceResult.issues.length > 0 && (

Compliance-Befunde ({o.complianceResult.issues.length})

{o.complianceResult.issues.map((issue, i) => (
{issue.severity === 'CRITICAL' ? 'Kritisch' : issue.severity === 'HIGH' ? 'Hoch' : issue.severity === 'MEDIUM' ? 'Mittel' : 'Niedrig'} {issue.message}
))}
)} {o.loading &&
Lade Pflichten...
} {!o.loading && (
{o.filteredObligations.map(obl => ( o.setDetailObligation(obl)} /> ))} {o.filteredObligations.length === 0 && o.setShowModal(true)} />}
)} ) const renderEditorTab = () => (

Pflichten bearbeiten ({o.obligations.length})

{o.loading &&

Lade...

} {!o.loading && o.obligations.length === 0 && (

Noch keine Pflichten vorhanden. Erstellen Sie eine neue Pflicht oder nutzen Sie Auto-Profiling.

)} {!o.loading && o.obligations.length > 0 && (
{o.obligations.map(obl => (
o.setEditObligation(obl)} >
{obl.title}
{obl.source}
))}
)}
) const renderProfilingTab = () => ( <> {o.error &&
{o.error}
} {!o.sdkState.companyProfile && (
Kein Unternehmensprofil vorhanden. Auto-Profiling verwendet Beispieldaten.{' '} Profil anlegen →
)}

Auto-Profiling

Ermittelt automatisch anwendbare Regulierungen und Pflichten aus dem Unternehmensprofil und Compliance-Scope.

{o.applicableRegs.length > 0 && (

Anwendbare Regulierungen

{o.applicableRegs.map(reg => ( {reg.name} {reg.classification && ({reg.classification})} {reg.obligation_count} Pflichten ))}
)} ) const renderTabContent = () => { switch (o.activeTab) { case 'uebersicht': return renderUebersichtTab() case 'editor': return renderEditorTab() case 'profiling': return renderProfilingTab() case 'gap-analyse': return case 'pflichtenregister': return } } return (
{/* Modals */} {(o.showModal || o.editObligation) && !o.detailObligation && ( { o.setShowModal(false); o.setEditObligation(null) }} onSave={async (form) => { if (o.editObligation) { await o.handleUpdate(o.editObligation.id, form) o.setEditObligation(null) } else { await o.handleCreate(form) o.setShowModal(false) } }} /> )} {o.detailObligation && ( o.setDetailObligation(null)} onStatusChange={o.handleStatusChange} onDelete={o.handleDelete} onEdit={() => { o.setEditObligation(o.detailObligation) o.setDetailObligation(null) }} /> )} {/* Header */} o.setActiveTab(o.activeTab === 'gap-analyse' ? 'uebersicht' : 'gap-analyse')} onAdd={() => o.setShowModal(true)} /> {/* Tab Navigation */}
{TABS.map(tab => ( ))}
{/* Tab Content */} {renderTabContent()}
) }