import { useEffect, useState } from 'react'; import { Link, useNavigate, useParams } from 'react-router-dom'; import { ArrowLeft, Mail, Phone, User, Globe, Pencil, Trash2, X, AlertTriangle, Plus, Lightbulb } from 'lucide-react'; import { api, fmt } from '../api'; import { Card, Btn, Field, inputCls, Modal, Spinner, ErrorBox, Table, StatusBadge, Badge } from '../components/ui'; import { EngagementFormModal, TYPE_LABELS, ENG_STATUS_LABELS } from './Engagements'; const STATUS_LABELS = { lead: 'Lead', active: 'Actief', paused: 'Gepauzeerd', archived: 'Gearchiveerd' }; const INV_STATUS_LABELS = { draft: 'Concept', sent: 'Verzonden', paid: 'Betaald', overdue: 'Verlopen', cancelled: 'Geannuleerd' }; const EMPTY_FORM = { name: '', industry: '', website: '', contact_name: '', contact_email: '', contact_phone: '', status: 'lead', source: '', notes: '' }; // Zelfde formulier als in Clients.jsx (bewerk-modus) function ClientFormModal({ open, onClose, client, onSaved, onDelete }) { const [form, setForm] = useState(EMPTY_FORM); const [saving, setSaving] = useState(false); const [error, setError] = useState(null); useEffect(() => { if (!open) return; setError(null); setForm(client ? { name: client.name || '', industry: client.industry || '', website: client.website || '', contact_name: client.contact_name || '', contact_email: client.contact_email || '', contact_phone: client.contact_phone || '', status: client.status || 'lead', source: client.source || '', notes: client.notes || '' } : EMPTY_FORM); }, [open, client]); const set = (k) => (e) => setForm((f) => ({ ...f, [k]: e.target.value })); const submit = async (e) => { e.preventDefault(); setSaving(true); setError(null); try { await api.put(`/clients/${client.id}`, form); onSaved(); } catch (err) { setError(err); } finally { setSaving(false); } }; return (