const { useState } = React; function NewContact({ onContactCreated }) { const [formData, setFormData] = useState({ full_name: '', preferred_name: '', current_title: '', organisation: '', seniority_band: 'Mid', sector: '', location: '', country: '', tier: 'Prospect', warmth_status: 'warm', how_we_met: '', strategic_context: '', emails: [''], phones: [''], linkedin_url: '', }); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const handleChange = (field, value) => { setFormData(prev => ({ ...prev, [field]: value })); }; const handleEmailChange = (index, value) => { const newEmails = [...formData.emails]; newEmails[index] = value; setFormData(prev => ({ ...prev, emails: newEmails })); }; const handlePhoneChange = (index, value) => { const newPhones = [...formData.phones]; newPhones[index] = value; setFormData(prev => ({ ...prev, phones: newPhones })); }; const addEmail = () => { setFormData(prev => ({ ...prev, emails: [...prev.emails, ''] })); }; const addPhone = () => { setFormData(prev => ({ ...prev, phones: [...prev.phones, ''] })); }; const handleSubmit = async (e) => { e.preventDefault(); if (!formData.full_name || !formData.organisation) { setError('Full name and organisation are required'); return; } setLoading(true); setError(null); try { const payload = { ...formData, emails: formData.emails.filter(e => e.trim()), phones: formData.phones.filter(p => p.trim()), }; const res = await fetch('/api/contacts', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }); if (!res.ok) throw new Error('Failed to create contact'); const data = await res.json(); alert('Contact created successfully'); onContactCreated(); } catch (err) { setError(err.message); } finally { setLoading(false); } }; return (

Add New Contact

{error &&
{error}
}
Core Information
handleChange('full_name', e.target.value)} placeholder="e.g. John Smith" />
handleChange('preferred_name', e.target.value)} placeholder="e.g. John" />
handleChange('organisation', e.target.value)} placeholder="e.g. Booking Holdings" />
handleChange('current_title', e.target.value)} placeholder="e.g. VP Commercial" />
handleChange('location', e.target.value)} placeholder="e.g. London" />
handleChange('country', e.target.value)} placeholder="e.g. UK" />
Contact Channels
{formData.emails.map((email, idx) => (
handleEmailChange(idx, e.target.value)} placeholder="name@example.com" />
))}
{formData.phones.map((phone, idx) => (
handlePhoneChange(idx, e.target.value)} placeholder="+1 555 123 4567" />
))}
handleChange('linkedin_url', e.target.value)} placeholder="https://linkedin.com/in/..." />
Classification
handleChange('how_we_met', e.target.value)} placeholder="e.g. EWC 2026 pre-event call" />
handleChange('strategic_context', e.target.value)} placeholder="e.g. EWC 2026, Aviation Partnership" />
); }