refactor: remove 473 lines of dead code across 5 SDK modules
- obligations: unused vendors state/fetch, unreachable filter==='ai' path - tom: unused vendorControlsLoading state, unused bulkUpdateTOMs import - loeschfristen: unused BASELINE_TEMPLATES imports, sdk hook, managingLegalHolds state - vvt: unused apiGetCompleteness/apiGetLibrary, 7 unused VVTLib* interfaces - vendor-compliance: 11 unused context methods, 6 unused selector hooks, ContractUploadData type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import React, { useState, useEffect, useCallback, useMemo } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useSDK } from '@/lib/sdk'
|
||||
import { StepHeader, STEP_EXPLANATIONS } from '@/components/sdk/StepHeader'
|
||||
import {
|
||||
LoeschfristPolicy, LegalHold, StorageLocation,
|
||||
@@ -15,7 +14,6 @@ import {
|
||||
formatRetentionDuration, isPolicyOverdue, getActiveLegalHolds,
|
||||
getEffectiveDeletionTrigger,
|
||||
} from '@/lib/sdk/loeschfristen-types'
|
||||
import { BASELINE_TEMPLATES, templateToPolicy, getTemplateById, getAllTemplateTags } from '@/lib/sdk/loeschfristen-baseline-catalog'
|
||||
import {
|
||||
PROFILING_STEPS, ProfilingAnswer, ProfilingStep,
|
||||
isStepComplete, getProfilingProgress, generatePoliciesFromProfile,
|
||||
@@ -107,7 +105,6 @@ function TagInput({
|
||||
|
||||
export default function LoeschfristenPage() {
|
||||
const router = useRouter()
|
||||
const sdk = useSDK()
|
||||
|
||||
// ---- Core state ----
|
||||
const [tab, setTab] = useState<Tab>('uebersicht')
|
||||
@@ -127,9 +124,6 @@ export default function LoeschfristenPage() {
|
||||
// ---- Compliance state ----
|
||||
const [complianceResult, setComplianceResult] = useState<ComplianceCheckResult | null>(null)
|
||||
|
||||
// ---- Legal Hold management ----
|
||||
const [managingLegalHolds, setManagingLegalHolds] = useState(false)
|
||||
|
||||
// ---- Saving state ----
|
||||
const [saving, setSaving] = useState(false)
|
||||
|
||||
|
||||
@@ -588,17 +588,6 @@ export default function ObligationsPage() {
|
||||
const [profiling, setProfiling] = useState(false)
|
||||
const [applicableRegs, setApplicableRegs] = useState<ApplicableRegulation[]>([])
|
||||
const [activeTab, setActiveTab] = useState<Tab>('uebersicht')
|
||||
const [vendors, setVendors] = useState<Array<{id: string, name: string, role: string}>>([])
|
||||
|
||||
useEffect(() => {
|
||||
fetch('/api/sdk/v1/vendor-compliance/vendors?limit=500')
|
||||
.then(r => r.ok ? r.json() : null)
|
||||
.then(data => {
|
||||
const items = data?.data?.items || []
|
||||
setVendors(items.map((v: any) => ({ id: v.id, name: v.name, role: v.role })))
|
||||
})
|
||||
.catch(() => {})
|
||||
}, [])
|
||||
|
||||
// Compliance check result — auto-computed when obligations change
|
||||
const complianceResult = useMemo<ObligationComplianceCheckResult | null>(() => {
|
||||
@@ -777,9 +766,6 @@ export default function ObligationsPage() {
|
||||
const stepInfo = STEP_EXPLANATIONS['obligations']
|
||||
|
||||
const filteredObligations = obligations.filter(o => {
|
||||
if (filter === 'ai') {
|
||||
if (!o.source.toLowerCase().includes('ai')) return false
|
||||
}
|
||||
if (regulationFilter !== 'all') {
|
||||
const src = o.source?.toLowerCase() || ''
|
||||
const key = regulationFilter.toLowerCase()
|
||||
|
||||
@@ -35,7 +35,7 @@ const TABS: TabDefinition[] = [
|
||||
export default function TOMPage() {
|
||||
const router = useRouter()
|
||||
const sdk = useSDK()
|
||||
const { state, dispatch, bulkUpdateTOMs, runGapAnalysis } = useTOMGenerator()
|
||||
const { state, dispatch, runGapAnalysis } = useTOMGenerator()
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Local state
|
||||
@@ -53,7 +53,6 @@ export default function TOMPage() {
|
||||
status: string
|
||||
lastTestedAt?: string
|
||||
}>>([])
|
||||
const [vendorControlsLoading, setVendorControlsLoading] = useState(false)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Compliance check (auto-run when derivedTOMs change)
|
||||
@@ -71,7 +70,6 @@ export default function TOMPage() {
|
||||
|
||||
useEffect(() => {
|
||||
if (tab !== 'uebersicht') return
|
||||
setVendorControlsLoading(true)
|
||||
Promise.all([
|
||||
fetch('/api/sdk/v1/vendor-compliance/control-instances?limit=500').then(r => r.ok ? r.json() : null),
|
||||
fetch('/api/sdk/v1/vendor-compliance/vendors?limit=500').then(r => r.ok ? r.json() : null),
|
||||
@@ -95,7 +93,7 @@ export default function TOMPage() {
|
||||
lastTestedAt: ci.lastTestedAt || ci.last_tested_at,
|
||||
}))
|
||||
setVendorControls(tomControls)
|
||||
}).catch(() => {}).finally(() => setVendorControlsLoading(false))
|
||||
}).catch(() => {})
|
||||
}, [tab])
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -235,21 +235,6 @@ async function apiInstantiateTemplate(templateId: string): Promise<VVTActivity>
|
||||
return activityFromApi(await res.json())
|
||||
}
|
||||
|
||||
async function apiGetCompleteness(activityId: string): Promise<{ score: number; missing: string[]; warnings: string[] }> {
|
||||
const res = await fetch(`${VVT_API_BASE}/activities/${activityId}/completeness`)
|
||||
if (!res.ok) return { score: 0, missing: [], warnings: [] }
|
||||
return res.json()
|
||||
}
|
||||
|
||||
interface LibraryItem { id: string; label_de: string; description_de?: string; [key: string]: any }
|
||||
|
||||
async function apiGetLibrary(type: string): Promise<LibraryItem[]> {
|
||||
const res = await fetch(`${VVT_API_BASE}/libraries/${type}`)
|
||||
if (!res.ok) return []
|
||||
const data = await res.json()
|
||||
return Array.isArray(data) ? data : []
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// MAIN PAGE
|
||||
// =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user