From 78d7273b82756c9acd1feab8b85d9adf7bbd8d1a Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Thu, 7 May 2026 18:33:21 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Verifikation=20=E2=80=94=20Suchfeld=20st?= =?UTF-8?q?att=20654=20Mini-Kacheln=20+=20Lazy-Load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SuggestEvidenceModal: Suchfeld + max 20 Ergebnisse statt alle Kacheln - Verification page: Mitigations nur on-demand laden (nicht beim Seitenstart) - Deutlich schnellerer Seitenaufbau Co-Authored-By: Claude Opus 4.6 (1M context) --- .../_components/SuggestEvidenceModal.tsx | 33 +++++++++++++++---- .../iace/[projectId]/verification/page.tsx | 27 +++++++++------ 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/admin-compliance/app/sdk/iace/[projectId]/verification/_components/SuggestEvidenceModal.tsx b/admin-compliance/app/sdk/iace/[projectId]/verification/_components/SuggestEvidenceModal.tsx index a940b6c..e3d05fb 100644 --- a/admin-compliance/app/sdk/iace/[projectId]/verification/_components/SuggestEvidenceModal.tsx +++ b/admin-compliance/app/sdk/iace/[projectId]/verification/_components/SuggestEvidenceModal.tsx @@ -14,6 +14,12 @@ export function SuggestEvidenceModal({ const [selectedMitigation, setSelectedMitigation] = useState('') const [suggested, setSuggested] = useState([]) const [loadingSuggestions, setLoadingSuggestions] = useState(false) + const [search, setSearch] = useState('') + + const filtered = search.trim() + ? mitigations.filter(m => (m.title || '').toLowerCase().includes(search.toLowerCase())) + : mitigations + const displayed = filtered.slice(0, 20) // Show max 20 at a time async function handleSelectMitigation(mitigationId: string) { setSelectedMitigation(mitigationId) @@ -41,22 +47,35 @@ export function SuggestEvidenceModal({ -

- Waehlen Sie eine Massnahme, um passende Nachweismethoden vorgeschlagen zu bekommen. +

+ Waehlen Sie eine Massnahme ({mitigations.length} gesamt). Suchen Sie nach Name:

-
- {mitigations.map(m => ( + setSearch(e.target.value)} + placeholder="Massnahme suchen..." + className="w-full px-3 py-2 text-sm border border-gray-300 rounded-lg mb-3 focus:ring-2 focus:ring-purple-400 dark:bg-gray-700 dark:border-gray-600 dark:text-white" + /> +
+ {displayed.map(m => ( ))} + {filtered.length > 20 && ( +

+ {filtered.length - 20} weitere — Suchbegriff eingeben um zu filtern +

+ )} + {filtered.length === 0 && ( +

Keine Massnahmen gefunden

+ )}
diff --git a/admin-compliance/app/sdk/iace/[projectId]/verification/page.tsx b/admin-compliance/app/sdk/iace/[projectId]/verification/page.tsx index 28785f0..69b3aed 100644 --- a/admin-compliance/app/sdk/iace/[projectId]/verification/page.tsx +++ b/admin-compliance/app/sdk/iace/[projectId]/verification/page.tsx @@ -23,18 +23,25 @@ export default function VerificationPage() { async function fetchData() { try { - const [verRes, hazRes, mitRes] = await Promise.all([ - fetch(`/api/sdk/v1/iace/projects/${projectId}/verifications`), - fetch(`/api/sdk/v1/iace/projects/${projectId}/hazards`), - fetch(`/api/sdk/v1/iace/projects/${projectId}/mitigations`), - ]) + // Only load verifications initially — hazards/mitigations loaded on demand + const verRes = await fetch(`/api/sdk/v1/iace/projects/${projectId}/verifications`) if (verRes.ok) { const j = await verRes.json(); setItems(j.verifications || j || []) } - if (hazRes.ok) { const j = await hazRes.json(); setHazards((j.hazards || j || []).map((h: { id: string; name: string }) => ({ id: h.id, name: h.name }))) } - if (mitRes.ok) { const j = await mitRes.json(); setMitigations((j.mitigations || j || []).map((m: { id: string; title: string }) => ({ id: m.id, title: m.title }))) } } catch (err) { console.error('Failed to fetch data:', err) } finally { setLoading(false) } } + async function loadMitigationsIfNeeded() { + if (mitigations.length > 0) return + try { + const mitRes = await fetch(`/api/sdk/v1/iace/projects/${projectId}/mitigations`) + if (mitRes.ok) { + const j = await mitRes.json() + const mits = (j.mitigations || j || []).map((m: Record) => ({ id: m.id, title: m.title || m.name || '' })) + setMitigations(mits) + } + } catch { /* ignore */ } + } + async function handleSubmit(data: VerificationFormData) { try { const res = await fetch(`/api/sdk/v1/iace/projects/${projectId}/verifications`, { @@ -89,8 +96,8 @@ export default function VerificationPage() {

Nachweisfuehrung fuer alle Schutzmassnahmen und Sicherheitsanforderungen.

- {mitigations.length > 0 && ( - )}