feat: Data Management (DSGVO Art. 15/20/30 — export, inventory, retention)
- Data Management API: inventory (Art. 30 Verarbeitungsverzeichnis) + export - JSON export with SHA-256 checksum (GoBD Jahresarchiv) - CSV export (DATEV/Excel-compatible) - Export history (audit-logged) - Retention periods (8/6 years per GoBD) - Art. 17 erasure notice (pseudonymization, legal precedence) - 159 records across 10 categories with legal basis per category
This commit is contained in:
1 parent
1dd2563172
commit
6c42c6525a
8 files changed
+491
No files matched your search
@@ -0,0 +1,136 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { db } from '@/lib/db'
|
||||
import { createHash } from 'crypto'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
// GET /api/aos/data-management/export?format=json|csv&scope=all|company:<id>
|
||||
// DSGVO Art. 15 (right of access) + Art. 20 (data portability).
|
||||
// Returns all data (or a specific company's data) as JSON or CSV,
|
||||
// with a SHA-256 checksum for integrity verification.
|
||||
export async function GET(req: Request) {
|
||||
try {
|
||||
const { searchParams } = new URL(req.url)
|
||||
const format = searchParams.get('format') ?? 'json'
|
||||
const scope = searchParams.get('scope') ?? 'all'
|
||||
|
||||
let companyFilter: string | null = null
|
||||
if (scope.startsWith('company:')) {
|
||||
companyFilter = scope.split(':')[1]!
|
||||
}
|
||||
|
||||
// Fetch all data (or company-scoped)
|
||||
const companies = await db.company.findMany({
|
||||
where: companyFilter ? { id: companyFilter } : undefined,
|
||||
include: { persons: true, deals: true, projects: true, invoices: true, licenses: true, leads: true },
|
||||
})
|
||||
|
||||
const auditLogs = await db.auditLog.findMany({
|
||||
where: companyFilter
|
||||
? { OR: [{ entity: 'Company', entityId: companyFilter }] }
|
||||
: undefined,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
take: 500,
|
||||
})
|
||||
|
||||
const tickets = await db.ticket.findMany({
|
||||
where: companyFilter ? { companyId: companyFilter } : undefined,
|
||||
include: { messages: true },
|
||||
})
|
||||
|
||||
const contracts = await db.contract.findMany({
|
||||
where: companyFilter ? { companyId: companyFilter } : undefined,
|
||||
})
|
||||
|
||||
const expenses = await db.expense.findMany({
|
||||
where: companyFilter ? { companyId: companyFilter } : undefined,
|
||||
})
|
||||
|
||||
const portalApprovals = companyFilter
|
||||
? await db.portalApproval.findMany({
|
||||
where: { project: { companyId: companyFilter } },
|
||||
})
|
||||
: await db.portalApproval.findMany()
|
||||
|
||||
const exportData = {
|
||||
metadata: {
|
||||
exportedAt: new Date().toISOString(),
|
||||
scope: scope,
|
||||
format: format,
|
||||
version: '1.0.0',
|
||||
legalBasis: companyFilter
|
||||
? 'DSGVO Art. 15 (Auskunftsrecht) + Art. 20 (Datenübertragbarkeit)'
|
||||
: 'GoBD Jahresarchiv (Vollständiger Datenexport)',
|
||||
agency: 'Nordlicht Digital GmbH',
|
||||
},
|
||||
companies: companies.map((c) => ({
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
legalForm: c.legalForm,
|
||||
vatId: c.vatId,
|
||||
website: c.website,
|
||||
city: c.city,
|
||||
source: c.source,
|
||||
createdAt: c.createdAt,
|
||||
persons: c.persons.map((p) => ({ firstName: p.firstName, lastName: p.lastName, email: p.email, role: p.role })),
|
||||
deals: c.deals.map((d) => ({ title: d.title, stage: d.stage, valueCents: d.valueCents, probability: d.probability })),
|
||||
projects: c.projects.map((p) => ({ name: p.name, type: p.type, status: p.status, progress: p.progress })),
|
||||
invoices: c.invoices.map((i) => ({ number: i.number, status: i.status, grossCents: i.grossCents, issueDate: i.issueDate })),
|
||||
licenses: c.licenses.map((l) => ({ product: l.product, plan: l.plan, status: l.status })),
|
||||
})),
|
||||
tickets: tickets.map((t) => ({
|
||||
number: t.number,
|
||||
subject: t.subject,
|
||||
status: t.status,
|
||||
priority: t.priority,
|
||||
messages: t.messages.map((m) => ({ from: m.fromName, fromType: m.fromType, body: m.body, createdAt: m.createdAt })),
|
||||
})),
|
||||
contracts: contracts.map((c) => ({ number: c.number, type: c.type, title: c.title, status: c.status, valueCents: c.valueCents })),
|
||||
expenses: expenses.map((e) => ({ number: e.number, description: e.description, amountCents: e.amountCents, date: e.date, billable: e.billable })),
|
||||
portalApprovals: portalApprovals.map((a) => ({ title: a.title, status: a.status, decidedAt: a.decidedAt, decidedBy: a.decidedBy })),
|
||||
auditLog: auditLogs.map((a) => ({ action: a.action, entity: a.entity, actor: a.actor, createdAt: a.createdAt })),
|
||||
}
|
||||
|
||||
// Compute SHA-256 checksum of the export
|
||||
const jsonStr = JSON.stringify(exportData)
|
||||
const checksum = createHash('sha256').update(jsonStr).digest('hex')
|
||||
|
||||
// Audit the export
|
||||
await db.auditLog.create({
|
||||
data: {
|
||||
actor: 'max@nordlicht.digital',
|
||||
action: 'data.export:' + (companyFilter ? 'company' : 'full'),
|
||||
entity: 'DataExport',
|
||||
entityId: checksum.slice(0, 16),
|
||||
after: JSON.stringify({ format, scope, checksum, sizeBytes: jsonStr.length, recordCount: exportData.companies.length + exportData.tickets.length + exportData.contracts.length }),
|
||||
hash: 'sha256:' + checksum,
|
||||
},
|
||||
})
|
||||
|
||||
if (format === 'csv') {
|
||||
// Simple CSV export (companies only for CSV — full export is JSON)
|
||||
const headers = ['id', 'name', 'legalForm', 'vatId', 'city', 'website', 'createdAt']
|
||||
const rows = companies.map((c) => [c.id, c.name, c.legalForm ?? '', c.vatId ?? '', c.city ?? '', c.website ?? '', c.createdAt.toISOString()])
|
||||
const csv = [headers.join(','), ...rows.map((r) => r.map((c) => `"${String(c).replace(/"/g, '""')}"`).join(','))].join('\n')
|
||||
return new Response(csv, {
|
||||
headers: {
|
||||
'content-type': 'text/csv; charset=utf-8',
|
||||
'content-disposition': `attachment; filename="aos-export-${scope}-${new Date().toISOString().slice(0, 10)}.csv"`,
|
||||
'x-aos-checksum': `sha256=${checksum}`,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// JSON export with checksum in header
|
||||
return new Response(JSON.stringify(exportData, null, 2), {
|
||||
headers: {
|
||||
'content-type': 'application/json; charset=utf-8',
|
||||
'content-disposition': `attachment; filename="aos-export-${scope}-${new Date().toISOString().slice(0, 10)}.json"`,
|
||||
'x-aos-checksum': `sha256=${checksum}`,
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : 'internal server error'
|
||||
return NextResponse.json({ error: msg }, { status: 500 })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { db } from '@/lib/db'
|
||||
import { createHash } from 'crypto'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
// GET /api/aos/data-management — overview of data inventory + retention status
|
||||
export async function GET() {
|
||||
try {
|
||||
const [
|
||||
companies, persons, deals, leads, projects, tasks, timeEntries,
|
||||
invoices, licenses, assets, contracts, expenses, tickets, articles,
|
||||
auditLogs, bankTx, vatReturns, apiTokens, webhooks, portalApprovals,
|
||||
] = await Promise.all([
|
||||
db.company.count(), db.person.count(), db.deal.count(), db.lead.count(),
|
||||
db.project.count(), db.task.count(), db.timeEntry.count(),
|
||||
db.invoice.count(), db.license.count(), db.asset.count(),
|
||||
db.contract.count(), db.expense.count(), db.ticket.count(), db.article.count(),
|
||||
db.auditLog.count(), db.bankTransaction.count(), db.vatReturn.count(),
|
||||
db.apiToken.count({ where: { revokedAt: null } }), db.webhook.count({ where: { active: true } }),
|
||||
db.portalApproval.count(),
|
||||
])
|
||||
|
||||
// Data inventory by category (DSGVO Art. 30 — records of processing)
|
||||
const inventory = [
|
||||
{ category: 'Stammdaten (Kunden)', models: ['Company', 'Person'], count: companies + persons, retentionYears: 6, legalBasis: 'Art. 6 Abs. 1 lit. b (Vertrag)' },
|
||||
{ category: 'Vertriebsdaten', models: ['Deal', 'Lead'], count: deals + leads, retentionYears: 6, legalBasis: 'Art. 6 Abs. 1 lit. f (berechtigtes Interesse)' },
|
||||
{ category: 'Projektdaten', models: ['Project', 'Task', 'TimeEntry'], count: projects + tasks + timeEntries, retentionYears: 6, legalBasis: 'Art. 6 Abs. 1 lit. b (Vertrag)' },
|
||||
{ category: 'Finanzdaten', models: ['Invoice', 'Expense', 'BankTransaction', 'VatReturn'], count: invoices + expenses + bankTx + vatReturns, retentionYears: 8, legalBasis: 'Art. 6 Abs. 1 lit. c (gesetzl. Pflicht, GoBD)' },
|
||||
{ category: 'Vertragsdaten', models: ['Contract'], count: contracts, retentionYears: 6, legalBasis: 'Art. 6 Abs. 1 lit. b (Vertrag)' },
|
||||
{ category: 'Lizenzdaten', models: ['License', 'Asset'], count: licenses + assets, retentionYears: 6, legalBasis: 'Art. 6 Abs. 1 lit. b (Vertrag)' },
|
||||
{ category: 'Supportdaten', models: ['Ticket'], count: tickets, retentionYears: 6, legalBasis: 'Art. 6 Abs. 1 lit. f (berechtigtes Interesse)' },
|
||||
{ category: 'Audit-Log', models: ['AuditLog'], count: auditLogs, retentionYears: 8, legalBasis: 'Art. 6 Abs. 1 lit. c (GoBD)' },
|
||||
{ category: 'Wissensdatenbank', models: ['Article'], count: articles, retentionYears: null, legalBasis: 'Art. 6 Abs. 1 lit. f (berechtigtes Interesse)' },
|
||||
{ category: 'Portal-Freigaben', models: ['PortalApproval'], count: portalApprovals, retentionYears: 6, legalBasis: 'Art. 6 Abs. 1 lit. b (Vertrag)' },
|
||||
]
|
||||
|
||||
const totalRecords = inventory.reduce((s, i) => s + i.count, 0)
|
||||
|
||||
// Export history (from audit log)
|
||||
const exports = await db.auditLog.findMany({
|
||||
where: { action: { startsWith: 'data.export' } },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
take: 10,
|
||||
})
|
||||
|
||||
return NextResponse.json({
|
||||
inventory,
|
||||
stats: {
|
||||
totalRecords,
|
||||
activeTokens: apiTokens,
|
||||
activeWebhooks: webhooks,
|
||||
exportCount: exports.length,
|
||||
},
|
||||
exports: exports.map((e) => ({
|
||||
id: e.id,
|
||||
action: e.action,
|
||||
detail: e.after ? JSON.parse(e.after) : null,
|
||||
actor: e.actor,
|
||||
createdAt: e.createdAt,
|
||||
})),
|
||||
})
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : 'internal server error'
|
||||
return NextResponse.json({ error: msg }, { status: 500 })
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import { ExpensesView } from './views/expenses'
|
||||
import { FinanceView } from './views/finance'
|
||||
import { AccountingView } from './views/accounting'
|
||||
import { AuditView } from './views/audit'
|
||||
import { DataView } from './views/data'
|
||||
import { KbView } from './views/kb'
|
||||
import { ApiView } from './views/api'
|
||||
import { SettingsView } from './views/settings'
|
||||
@@ -73,6 +74,7 @@ export function AppShell() {
|
||||
{view === 'finance' && <FinanceView />}
|
||||
{view === 'accounting' && <AccountingView />}
|
||||
{view === 'audit' && <AuditView />}
|
||||
{view === 'data' && <DataView />}
|
||||
{view === 'kb' && <KbView />}
|
||||
{view === 'api' && <ApiView />}
|
||||
{view === 'settings' && <SettingsView />}
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
HelpCircle,
|
||||
SlidersHorizontal,
|
||||
CalendarDays,
|
||||
Database,
|
||||
} from 'lucide-react'
|
||||
import { useAos, type ViewId } from '@/store/aos'
|
||||
import {
|
||||
@@ -53,6 +54,7 @@ const VIEWS: { id: ViewId; label: string; icon: typeof LayoutDashboard; hint: st
|
||||
{ id: 'finance', label: 'Finanzen', icon: Receipt, hint: 'Rechnungen & E-Rechnung' },
|
||||
{ id: 'accounting', label: 'Buchhaltung', icon: BookOpen, hint: 'USt-Voranmeldung, EÜR, Bank' },
|
||||
{ id: 'audit', label: 'Audit-Protokoll', icon: ScrollText, hint: 'Hash-Kette & GoBD' },
|
||||
{ id: 'data', label: 'Datenverwaltung', icon: Database, hint: 'Export, DSGVO, Aufbewahrung' },
|
||||
{ id: 'kb', label: 'Wissensdatenbank', icon: HelpCircle, hint: 'Dokumente & Vorlagen' },
|
||||
{ id: 'api', label: 'API & Webhooks', icon: Webhook, hint: 'Tokens, Scopes, HMAC' },
|
||||
{ id: 'settings', label: 'Erweiterungen', icon: Settings2, hint: 'Module & Compliance' },
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
HelpCircle,
|
||||
CalendarDays,
|
||||
Clock,
|
||||
Database,
|
||||
} from 'lucide-react'
|
||||
import { useAos, type ViewId } from '@/store/aos'
|
||||
import { translate } from '@/lib/i18n'
|
||||
@@ -69,6 +70,7 @@ const NAV: {
|
||||
{ id: 'finance', label: 'Finanzen', icon: Receipt, permission: 'finance:read' },
|
||||
{ id: 'accounting', label: 'Buchhaltung', icon: BookOpen, permission: 'accounting:read' },
|
||||
{ id: 'audit', label: 'Audit-Protokoll', icon: ScrollText, permission: '*' },
|
||||
{ id: 'data', label: 'Datenverwaltung', icon: Database, permission: '*' },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -33,6 +33,7 @@ const TITLES: Record<ViewId, { title: string; crumb: string }> = {
|
||||
finance: { title: 'Finanzen', crumb: 'Betrieb / Finanzen' },
|
||||
accounting: { title: 'Buchhaltung', crumb: 'Betrieb / Buchhaltung' },
|
||||
audit: { title: 'Audit-Protokoll', crumb: 'Betrieb / Audit' },
|
||||
data: { title: 'Datenverwaltung', crumb: 'Betrieb / Daten' },
|
||||
kb: { title: 'Wissensdatenbank', crumb: 'Wissen / KB' },
|
||||
api: { title: 'API & Webhooks', crumb: 'System / API' },
|
||||
settings: { title: 'Erweiterungen', crumb: 'System / Module' },
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useFetch } from '@/hooks/use-fetch'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { ScrollArea } from '@/components/ui/scroll-area'
|
||||
import { PageHeader } from '../primitives'
|
||||
import { formatDateTime, formatRelative } from '@/lib/format'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { toast } from 'sonner'
|
||||
import {
|
||||
Database,
|
||||
Download,
|
||||
FileJson,
|
||||
FileSpreadsheet,
|
||||
ShieldCheck,
|
||||
Lock,
|
||||
Clock,
|
||||
CheckCircle2,
|
||||
AlertTriangle,
|
||||
Loader2,
|
||||
} from 'lucide-react'
|
||||
|
||||
interface InventoryItem {
|
||||
category: string
|
||||
models: string[]
|
||||
count: number
|
||||
retentionYears: number | null
|
||||
legalBasis: string
|
||||
}
|
||||
interface ExportEntry {
|
||||
id: string
|
||||
action: string
|
||||
detail: { format: string; scope: string; checksum: string; sizeBytes: number; recordCount: number } | null
|
||||
actor: string | null
|
||||
createdAt: string
|
||||
}
|
||||
interface DataData {
|
||||
inventory: InventoryItem[]
|
||||
stats: { totalRecords: number; activeTokens: number; activeWebhooks: number; exportCount: number }
|
||||
exports: ExportEntry[]
|
||||
}
|
||||
|
||||
export function DataView() {
|
||||
const { data, loading, refetch } = useFetch<DataData>('/api/aos/data-management')
|
||||
const [exporting, setExporting] = useState<'json-full' | 'csv-full' | null>(null)
|
||||
|
||||
if (loading || !data) {
|
||||
return (
|
||||
<div className="space-y-6 p-4 md:p-6">
|
||||
<Skeleton className="h-9 w-48" />
|
||||
<Skeleton className="h-64" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const { inventory, stats, exports } = data
|
||||
|
||||
const doExport = async (format: 'json' | 'csv', scope: string) => {
|
||||
setExporting(format === 'json' ? 'json-full' : 'csv-full')
|
||||
const t = toast.loading('Export wird erstellt (SHA-256 Checksumme berechnet)…')
|
||||
try {
|
||||
const r = await fetch(`/api/aos/data-management/export?format=${format}&scope=${scope}`)
|
||||
if (!r.ok) throw new Error('export failed')
|
||||
const blob = await r.blob()
|
||||
const checksum = r.headers.get('x-aos-checksum') ?? 'n/a'
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = `aos-export-${scope}-${new Date().toISOString().slice(0, 10)}.${format === 'json' ? 'json' : 'csv'}`
|
||||
a.click()
|
||||
URL.revokeObjectURL(url)
|
||||
toast.success(`Export erstellt — Checksumme: ${checksum.slice(0, 24)}…`, { id: t, duration: 6000 })
|
||||
refetch()
|
||||
} catch {
|
||||
toast.error('Export fehlgeschlagen', { id: t })
|
||||
} finally {
|
||||
setExporting(null)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6 p-4 md:p-6">
|
||||
<PageHeader
|
||||
title="Datenverwaltung"
|
||||
description="DSGVO Art. 15 (Auskunft), Art. 20 (Datenübertragbarkeit), Art. 30 (Verarbeitungsverzeichnis). GoBD-konformer Voll Export mit SHA-256-Prüfsumme."
|
||||
/>
|
||||
|
||||
{/* KPIs */}
|
||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-4">
|
||||
<Card className="p-4">
|
||||
<div className="flex items-center justify-between"><p className="text-xs text-muted-foreground">Datensätze gesamt</p><Database className="size-3.5 text-muted-foreground" /></div>
|
||||
<p className="mt-1 text-2xl font-semibold tabular-nums">{stats.totalRecords}</p>
|
||||
</Card>
|
||||
<Card className="p-4">
|
||||
<div className="flex items-center justify-between"><p className="text-xs text-muted-foreground">Exporte (Historie)</p><Download className="size-3.5 text-muted-foreground" /></div>
|
||||
<p className="mt-1 text-2xl font-semibold tabular-nums">{stats.exportCount}</p>
|
||||
</Card>
|
||||
<Card className="p-4">
|
||||
<div className="flex items-center justify-between"><p className="text-xs text-muted-foreground">Aktive API-Tokens</p><ShieldCheck className="size-3.5 text-muted-foreground" /></div>
|
||||
<p className="mt-1 text-2xl font-semibold tabular-nums">{stats.activeTokens}</p>
|
||||
</Card>
|
||||
<Card className="p-4">
|
||||
<div className="flex items-center justify-between"><p className="text-xs text-muted-foreground">Aktive Webhooks</p><ShieldCheck className="size-3.5 text-muted-foreground" /></div>
|
||||
<p className="mt-1 text-2xl font-semibold tabular-nums">{stats.activeWebhooks}</p>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Export actions */}
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="flex items-center gap-2 text-sm">
|
||||
<Download className="size-4 text-muted-foreground" />
|
||||
Daten-Export (DSGVO Art. 15 / Art. 20)
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
<button
|
||||
onClick={() => doExport('json', 'all')}
|
||||
disabled={exporting !== null}
|
||||
className="flex items-center gap-3 rounded-md border border-border p-3 text-left transition hover:border-foreground/40"
|
||||
>
|
||||
<div className="flex size-10 items-center justify-center rounded-md bg-muted">
|
||||
{exporting === 'json-full' ? <Loader2 className="size-5 animate-spin" /> : <FileJson className="size-5 text-muted-foreground" />}
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-medium">Voll-Export (JSON)</p>
|
||||
<p className="text-[11px] text-muted-foreground">Alle Daten + Audit-Log. SHA-256 Checksumme. GoBD-Jahresarchiv.</p>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => doExport('csv', 'all')}
|
||||
disabled={exporting !== null}
|
||||
className="flex items-center gap-3 rounded-md border border-border p-3 text-left transition hover:border-foreground/40"
|
||||
>
|
||||
<div className="flex size-10 items-center justify-center rounded-md bg-muted">
|
||||
{exporting === 'csv-full' ? <Loader2 className="size-5 animate-spin" /> : <FileSpreadsheet className="size-5 text-muted-foreground" />}
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-medium">Firmen-Export (CSV)</p>
|
||||
<p className="text-[11px] text-muted-foreground">Kundenstammdaten als Tabelle. DATEV/Excel-kompatibel.</p>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<div className="rounded-md border border-dashed border-border p-3 text-[11px] text-muted-foreground">
|
||||
<p className="flex items-center gap-1.5 font-medium text-foreground"><ShieldCheck className="size-3.5" />DSGVO Art. 15 + Art. 20</p>
|
||||
<p className="mt-1">Betroffene haben das Recht auf Auskunft über ihre gespeicherten Daten (Art. 15) und deren Übertragbarkeit in einem strukturierten, gängigen Format (Art. 20). Jeder Export wird mit SHA-256-Prüfsumme signiert und im Audit-Log protokolliert.</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Data inventory (Art. 30) */}
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="flex items-center gap-2 text-sm">
|
||||
<Database className="size-4 text-muted-foreground" />
|
||||
Verarbeitungsverzeichnis (Art. 30 DSGVO)
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="p-0">
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="border-y border-border bg-muted/40 text-left text-[11px] uppercase tracking-wide text-muted-foreground">
|
||||
<tr>
|
||||
<th className="px-4 py-2 font-medium">Kategorie</th>
|
||||
<th className="px-4 py-2 font-medium">Modelle</th>
|
||||
<th className="px-4 py-2 font-medium text-right">Datensätze</th>
|
||||
<th className="px-4 py-2 font-medium">Aufbewahrung</th>
|
||||
<th className="px-4 py-2 font-medium">Rechtsgrundlage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-border">
|
||||
{inventory.map((item) => (
|
||||
<tr key={item.category} className="transition hover:bg-muted/40">
|
||||
<td className="px-4 py-2.5 text-xs font-medium">{item.category}</td>
|
||||
<td className="px-4 py-2.5">
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{item.models.map((m) => <Badge key={m} variant="outline" className="text-[9px] font-mono">{m}</Badge>)}
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-4 py-2.5 text-right text-xs font-semibold tabular-nums">{item.count}</td>
|
||||
<td className="px-4 py-2.5 text-xs">
|
||||
{item.retentionYears ? (
|
||||
<span className="flex items-center gap-1"><Clock className="size-2.5 text-muted-foreground" />{item.retentionYears} Jahre</span>
|
||||
) : (
|
||||
<span className="text-muted-foreground">bis Widerruf</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-4 py-2.5 text-[10px] text-muted-foreground">{item.legalBasis}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
<tfoot className="border-t-2 border-border bg-muted/40">
|
||||
<tr>
|
||||
<td className="px-4 py-2 text-xs font-semibold">Gesamt</td>
|
||||
<td></td>
|
||||
<td className="px-4 py-2 text-right text-sm font-bold tabular-nums">{stats.totalRecords}</td>
|
||||
<td colSpan={2}></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Export history */}
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm">Export-Historie ({exports.length})</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
{exports.length === 0 && <p className="py-4 text-center text-xs text-muted-foreground">Noch keine Exporte.</p>}
|
||||
{exports.map((exp) => (
|
||||
<div key={exp.id} className="flex items-center gap-3 rounded-md border border-border p-2.5">
|
||||
<CheckCircle2 className="size-4 shrink-0 text-muted-foreground" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-xs font-medium">{exp.action}</p>
|
||||
{exp.detail && (
|
||||
<p className="text-[10px] text-muted-foreground">
|
||||
Format: {exp.detail.format} · Scope: {exp.detail.scope} · {exp.detail.recordCount} Datensätze · {(exp.detail.sizeBytes / 1024).toFixed(1)} KB
|
||||
</p>
|
||||
)}
|
||||
{exp.detail && (
|
||||
<p className="text-[9px] font-mono text-muted-foreground">SHA-256: {exp.detail.checksum.slice(0, 32)}…</p>
|
||||
)}
|
||||
</div>
|
||||
<span className="shrink-0 text-[10px] text-muted-foreground">{formatRelative(exp.createdAt)}</span>
|
||||
</div>
|
||||
))}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Retention + Erasure notice */}
|
||||
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="flex items-center gap-2 text-sm">
|
||||
<Clock className="size-4 text-muted-foreground" />
|
||||
Aufbewahrungsfristen
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2 text-xs">
|
||||
<div className="flex items-center justify-between"><span>Rechnungen & Buchhaltungsdaten</span><Badge variant="outline" className="text-[10px]">8 Jahre (GoBD)</Badge></div>
|
||||
<div className="flex items-center justify-between"><span>Geschäftsbriefe & Verträge</span><Badge variant="outline" className="text-[10px]">6 Jahre (GoBD)</Badge></div>
|
||||
<div className="flex items-center justify-between"><span>Audit-Log (Hash-Kette)</span><Badge variant="outline" className="text-[10px]">8 Jahre (GoBD)</Badge></div>
|
||||
<div className="flex items-center justify-between"><span>Kundenstammdaten</span><Badge variant="outline" className="text-[10px]">6 Jahre</Badge></div>
|
||||
<div className="rounded-md border border-dashed border-border p-2 text-[10px] text-muted-foreground mt-2">
|
||||
<p>Automatische Lösch-Jobs (cron) nach Ablauf der Frist. GoBD: Daten sind unveränderlich, Korrekturen als Storno.</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="flex items-center gap-2 text-sm">
|
||||
<AlertTriangle className="size-4 text-muted-foreground" />
|
||||
Löschung (Art. 17 DSGVO)
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2 text-xs text-muted-foreground">
|
||||
<p>Löschbegehren nach Art. 17 DSGVO (Recht auf Vergessenwerden) müssen geprüft werden:</p>
|
||||
<ul className="ml-4 space-y-1 list-disc">
|
||||
<li>GoBD-Aufbewahrungspflicht (8/6 Jahre) hat Vorrang</li>
|
||||
<li>Aktive Verträge/Rechnungen können nicht gelöscht werden</li>
|
||||
<li>Stattdessen: Pseudonymisierung (Name → „gelöscht")</li>
|
||||
<li>Vollständige Löschung erst nach Ablauf aller Fristen</li>
|
||||
</ul>
|
||||
<p className="mt-2 rounded-md border border-foreground/30 bg-foreground/5 p-2 text-[10px]">
|
||||
<Lock className="mr-1 inline size-3" />Lösch-Anfragen werden im Audit-Log protokolliert und erfordern Freigabe durch den Datenschutzbeauftragten.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -18,6 +18,7 @@ export type ViewId =
|
||||
| 'finance'
|
||||
| 'accounting'
|
||||
| 'audit'
|
||||
| 'data'
|
||||
| 'api'
|
||||
| 'kb'
|
||||
| 'calendar'
|
||||
|
||||
Reference in new issue
Block a user