// Lead Modal — New / Edit with Checklist const LeadModal = ({ lead, onClose, onSave }) => { const isNew = !lead.id; const [form, setForm] = React.useState({ empresa: lead.empresa || '', contato: lead.contato || '', tel: lead.tel || '', email: lead.email || '', responsavel: lead.responsavel || RESPONSAVEIS[0], origem: lead.origem || ORIGENS[0], segmento: lead.segmento || SEGMENTOS[0], valor: lead.valor || '', stage: lead.stage || STAGES[0], entrada: lead.entrada || new Date().toISOString().split('T')[0], followup: lead.followup || '', notas: lead.notas || '', checklist: lead.checklist || CHECKLIST_ITEMS.map(c => ({ ...c, done: false })), }); const [tab, setTab] = React.useState('info'); const set = (k, v) => setForm(prev => ({ ...prev, [k]: v })); const toggleCheck = (id) => { setForm(prev => ({ ...prev, checklist: prev.checklist.map(c => c.id === id ? { ...c, done: !c.done } : c), })); }; const handleSave = () => { if (!form.empresa.trim()) return alert('Informe o nome da empresa.'); onSave({ ...lead, ...form, valor: Number(form.valor) || 0, id: lead.id || Date.now() }); onClose(); }; const checkDone = form.checklist.filter(c => c.done).length; const checkTotal = form.checklist.length; const pct = Math.round((checkDone / checkTotal) * 100); // Group checklist by stage const checkByStage = STAGES.map(s => ({ stage: s, items: form.checklist.filter(c => c.stage === s), })); return (