diff --git a/admin-compliance/app/sdk/consent/_components/DocumentCard.tsx b/admin-compliance/app/sdk/consent/_components/DocumentCard.tsx new file mode 100644 index 0000000..2461241 --- /dev/null +++ b/admin-compliance/app/sdk/consent/_components/DocumentCard.tsx @@ -0,0 +1,117 @@ +'use client' + +import React from 'react' +import type { LegalDocument } from '../_hooks/useConsentDocuments' + +export function DocumentCard({ + document, + onDelete, + onEdit, + onPreview, +}: { + document: LegalDocument + onDelete: (id: string) => void + onEdit: (id: string) => void + onPreview: (doc: LegalDocument) => void +}) { + const typeColors = { + 'privacy-policy': 'bg-blue-100 text-blue-700', + terms: 'bg-green-100 text-green-700', + 'cookie-policy': 'bg-yellow-100 text-yellow-700', + imprint: 'bg-gray-100 text-gray-700', + dpa: 'bg-purple-100 text-purple-700', + } + + const typeLabels = { + 'privacy-policy': 'Datenschutz', + terms: 'AGB', + 'cookie-policy': 'Cookie-Richtlinie', + imprint: 'Impressum', + dpa: 'AVV', + } + + const statusColors = { + draft: 'bg-yellow-100 text-yellow-700', + active: 'bg-green-100 text-green-700', + archived: 'bg-gray-100 text-gray-500', + } + + const statusLabels = { + draft: 'Entwurf', + active: 'Aktiv', + archived: 'Archiviert', + } + + return ( +
Kein Inhalt verfügbar.
' }) + } else { + setPreviewDoc({ name: doc.name, content: 'Vorschau nicht verfügbar.
' }) + } + } catch { + setPreviewDoc({ name: doc.name, content: 'Fehler beim Laden der Vorschau.
' }) + } + } + + return { + documents, + loading, + error, + previewDoc, + setPreviewDoc, + handleRagSuggest, + handleCreateDocument, + handleDeleteDocument, + handlePreview, + } +} diff --git a/admin-compliance/app/sdk/consent/page.tsx b/admin-compliance/app/sdk/consent/page.tsx index 0baecfe..2e44d4a 100644 --- a/admin-compliance/app/sdk/consent/page.tsx +++ b/admin-compliance/app/sdk/consent/page.tsx @@ -1,312 +1,29 @@ 'use client' -import React, { useState, useEffect } from 'react' +import React, { useState } from 'react' import { useRouter } from 'next/navigation' -import { useSDK } from '@/lib/sdk' import { StepHeader, STEP_EXPLANATIONS } from '@/components/sdk/StepHeader' - -// ============================================================================= -// TYPES -// ============================================================================= - -interface LegalDocument { - id: string - type: 'privacy-policy' | 'terms' | 'cookie-policy' | 'imprint' | 'dpa' - name: string - version: string - language: string - status: 'draft' | 'active' | 'archived' - lastUpdated: Date - publishedAt: Date | null - author: string - changes: string[] -} - -interface ApiDocument { - id: string - type: string - name: string - description: string - mandatory: boolean - created_at: string - updated_at: string -} - -// Map API document type to UI type -function mapDocumentType(apiType: string): LegalDocument['type'] { - const mapping: RecordKein Inhalt verfügbar.
' }) - } else { - setPreviewDoc({ name: doc.name, content: 'Vorschau nicht verfügbar.
' }) - } - } catch { - setPreviewDoc({ name: doc.name, content: 'Fehler beim Laden der Vorschau.
' }) - } - } + const { + documents, + loading, + error, + previewDoc, + setPreviewDoc, + handleRagSuggest, + handleCreateDocument, + handleDeleteDocument, + handlePreview, + } = useConsentDocuments() const filteredDocuments = filter === 'all' ? documents @@ -315,6 +32,25 @@ export default function ConsentPage() { const activeCount = documents.filter(d => d.status === 'active').length const draftCount = documents.filter(d => d.status === 'draft').length + async function onRagSuggest() { + const text = await handleRagSuggest(newDocForm.type, newDocForm.name) + if (text) setNewDocForm(d => ({ ...d, content: text })) + } + + async function onCreateDocument() { + setCreating(true) + const ok = await handleCreateDocument(newDocForm) + if (ok) { + setShowCreateModal(false) + setNewDocForm({ type: 'privacy_policy', name: '', description: '', content: '' }) + } + setCreating(false) + } + + function handleEdit(id: string) { + router.push('/sdk/workflow') + } + const stepInfo = STEP_EXPLANATIONS['consent'] return ( @@ -531,7 +267,7 @@ export default function ConsentPage() {{item.description}
} +{item.description}
} -