'use client' import React, { useState, useEffect } from 'react' import { useParams } from 'next/navigation' interface Mitigation { id: string title: string description: string reduction_type: 'design' | 'protection' | 'information' status: 'planned' | 'implemented' | 'verified' linked_hazard_ids: string[] linked_hazard_names: string[] created_at: string verified_at: string | null verified_by: string | null } interface Hazard { id: string name: string risk_level: string } const REDUCTION_TYPES = { design: { label: 'Design', description: 'Inhaerent sichere Konstruktion', color: 'border-blue-200 bg-blue-50', headerColor: 'bg-blue-100 text-blue-800', icon: ( ), }, protection: { label: 'Schutz', description: 'Technische Schutzmassnahmen', color: 'border-green-200 bg-green-50', headerColor: 'bg-green-100 text-green-800', icon: ( ), }, information: { label: 'Information', description: 'Hinweise und Schulungen', color: 'border-yellow-200 bg-yellow-50', headerColor: 'bg-yellow-100 text-yellow-800', icon: ( ), }, } function StatusBadge({ status }: { status: string }) { const colors: Record = { planned: 'bg-gray-100 text-gray-700', implemented: 'bg-blue-100 text-blue-700', verified: 'bg-green-100 text-green-700', } const labels: Record = { planned: 'Geplant', implemented: 'Umgesetzt', verified: 'Verifiziert', } return ( {labels[status] || status} ) } interface MitigationFormData { title: string description: string reduction_type: 'design' | 'protection' | 'information' linked_hazard_ids: string[] } function MitigationForm({ onSubmit, onCancel, hazards, preselectedType, }: { onSubmit: (data: MitigationFormData) => void onCancel: () => void hazards: Hazard[] preselectedType?: 'design' | 'protection' | 'information' }) { const [formData, setFormData] = useState({ title: '', description: '', reduction_type: preselectedType || 'design', linked_hazard_ids: [], }) function toggleHazard(id: string) { setFormData((prev) => ({ ...prev, linked_hazard_ids: prev.linked_hazard_ids.includes(id) ? prev.linked_hazard_ids.filter((h) => h !== id) : [...prev.linked_hazard_ids, id], })) } return (

Neue Massnahme

setFormData({ ...formData, title: e.target.value })} placeholder="z.B. Lichtvorhang an Gefahrenstelle" className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent dark:bg-gray-700 dark:border-gray-600 dark:text-white" />