'use client' import { useState } from 'react' import { useParams } from 'next/navigation' import { REDUCTION_TYPES } from './_components/types' import { HierarchyWarning } from './_components/HierarchyWarning' import { MeasuresLibraryModal } from './_components/MeasuresLibraryModal' import { SuggestMeasuresModal } from './_components/SuggestMeasuresModal' import { MitigationForm } from './_components/MitigationForm' import { MitigationCard } from './_components/MitigationCard' import { ProtectiveMeasure } from './_components/types' import { useMitigations } from './_hooks/useMitigations' export default function MitigationsPage() { const params = useParams() const projectId = params.projectId as string const { hazards, loading, hierarchyWarning, setHierarchyWarning, measures, byType, fetchMeasuresLibrary, handleSubmit, handleAddSuggestedMeasure, handleVerify, handleDelete, } = useMitigations(projectId) const [showForm, setShowForm] = useState(false) const [preselectedType, setPreselectedType] = useState<'design' | 'protection' | 'information' | undefined>() const [showLibrary, setShowLibrary] = useState(false) const [libraryFilter, setLibraryFilter] = useState() const [showSuggest, setShowSuggest] = useState(false) function handleOpenLibrary(type?: string) { setLibraryFilter(type) fetchMeasuresLibrary(type) setShowLibrary(true) } function handleSelectMeasure(measure: ProtectiveMeasure) { setShowLibrary(false) setShowForm(true) setPreselectedType(measure.reduction_type as 'design' | 'protection' | 'information') } function handleAddForType(type: 'design' | 'protection' | 'information') { setPreselectedType(type) setShowForm(true) } if (loading) { return (
) } return (
{/* Header */}

Massnahmen

Risikominderung nach dem 3-Stufen-Verfahren: Design → Schutz → Information.

{hazards.length > 0 && ( )}
{hierarchyWarning && setHierarchyWarning(false)} />} {showForm && ( { const ok = await handleSubmit(data) if (ok) { setShowForm(false); setPreselectedType(undefined) } }} onCancel={() => { setShowForm(false); setPreselectedType(undefined) }} hazards={hazards} preselectedType={preselectedType} onOpenLibrary={handleOpenLibrary} /> )} {showLibrary && ( setShowLibrary(false)} filterType={libraryFilter} /> )} {showSuggest && ( setShowSuggest(false)} /> )} {/* 3-Column Layout */}
{(['design', 'protection', 'information'] as const).map((type) => { const config = REDUCTION_TYPES[type] const items = byType[type] return (
{config.icon}

{config.label}

{config.description}

{items.length}
{config.subTypes.map((st) => ( {st.label} ))}
{items.map((m) => ( ))}
) })}
) }