Files
breakpilot-compliance/admin-compliance/app/sdk/loeschfristen/_components/api.ts
Sharang Parnerkar e0c1d21879 refactor(admin): split loeschfristen and vvt pages
Reduce both page.tsx files below the 500-LOC hard cap by extracting
all inline tab components and API helpers into colocated _components/.
- loeschfristen/page.tsx: 2720 → 467 LOC
- vvt/page.tsx: 2297 → 256 LOC
New files: LoeschkonzeptTab, loeschfristen/api, TabDokument, TabProcessor
Updated: TabVerzeichnis (template picker + badge), vvt/api (template helpers)
Fixed: VVTLinkSection wrong field name (linkedVVTActivityIds), VendorLinkSection added

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 17:11:45 +02:00

75 lines
3.0 KiB
TypeScript

import { LoeschfristPolicy, createEmptyPolicy } from '@/lib/sdk/loeschfristen-types'
export const LOESCHFRISTEN_API = '/api/sdk/v1/compliance/loeschfristen'
export function apiToPolicy(raw: any): LoeschfristPolicy {
const base = createEmptyPolicy()
return {
...base,
id: raw.id,
policyId: raw.policy_id || base.policyId,
dataObjectName: raw.data_object_name || '',
description: raw.description || '',
affectedGroups: raw.affected_groups || [],
dataCategories: raw.data_categories || [],
primaryPurpose: raw.primary_purpose || '',
deletionTrigger: raw.deletion_trigger || 'PURPOSE_END',
retentionDriver: raw.retention_driver || null,
retentionDriverDetail: raw.retention_driver_detail || '',
retentionDuration: raw.retention_duration ?? null,
retentionUnit: raw.retention_unit || null,
retentionDescription: raw.retention_description || '',
startEvent: raw.start_event || '',
hasActiveLegalHold: raw.has_active_legal_hold || false,
legalHolds: raw.legal_holds || [],
storageLocations: raw.storage_locations || [],
deletionMethod: raw.deletion_method || 'MANUAL_REVIEW_DELETE',
deletionMethodDetail: raw.deletion_method_detail || '',
responsibleRole: raw.responsible_role || '',
responsiblePerson: raw.responsible_person || '',
releaseProcess: raw.release_process || '',
linkedVVTActivityIds: raw.linked_vvt_activity_ids || [],
linkedVendorIds: raw.linked_vendor_ids || [],
status: raw.status || 'DRAFT',
lastReviewDate: raw.last_review_date || base.lastReviewDate,
nextReviewDate: raw.next_review_date || base.nextReviewDate,
reviewInterval: raw.review_interval || 'ANNUAL',
tags: raw.tags || [],
createdAt: raw.created_at || base.createdAt,
updatedAt: raw.updated_at || base.updatedAt,
}
}
export function policyToPayload(p: LoeschfristPolicy): any {
return {
policy_id: p.policyId,
data_object_name: p.dataObjectName,
description: p.description,
affected_groups: p.affectedGroups,
data_categories: p.dataCategories,
primary_purpose: p.primaryPurpose,
deletion_trigger: p.deletionTrigger,
retention_driver: p.retentionDriver || null,
retention_driver_detail: p.retentionDriverDetail,
retention_duration: p.retentionDuration || null,
retention_unit: p.retentionUnit || null,
retention_description: p.retentionDescription,
start_event: p.startEvent,
has_active_legal_hold: p.hasActiveLegalHold,
legal_holds: p.legalHolds,
storage_locations: p.storageLocations,
deletion_method: p.deletionMethod,
deletion_method_detail: p.deletionMethodDetail,
responsible_role: p.responsibleRole,
responsible_person: p.responsiblePerson,
release_process: p.releaseProcess,
linked_vvt_activity_ids: p.linkedVVTActivityIds,
linked_vendor_ids: p.linkedVendorIds,
status: p.status,
last_review_date: p.lastReviewDate || null,
next_review_date: p.nextReviewDate || null,
review_interval: p.reviewInterval,
tags: p.tags,
}
}