import { Link } from '@inertiajs/react'; import { useCrmRecordEdit } from '@/lib/crm-record-edit'; import CrmEditComparison from '@/components/crm-edit-comparison'; import { Management, Field, control, button } from '../management/shared'; import { leadStates } from './types'; type Contact = { id: string; version_no: number; full_name: string; email: string | null; phone: string | null; }; function ContactForm({ contact, investorId, }: { contact: Contact; investorId: string; }) { const edit = useCrmRecordEdit({ id: contact.id, kind: 'contact', version: contact.version_no, values: { full_name: contact.full_name, email: contact.email ?? '', phone: contact.phone ?? '', }, }); const form = edit.form; return (
{ e.preventDefault(); edit.submit( `/management/crm/investors/${investorId}/contacts/${contact.id}`, ); }} > edit.change('full_name', e.target.value)} /> edit.change('email', e.target.value)} /> edit.change('phone', e.target.value)} /> ); } export default function InvestorDetail({ investor, contacts, leads, }: { investor: { id: string; version_no: number; legal_name: string; investor_type: string; status: string; }; contacts: Contact[]; leads: { id: string; title: string; status: string }[]; }) { const edit = useCrmRecordEdit({ id: investor.id, kind: 'investor', version: investor.version_no, values: { legal_name: investor.legal_name, investor_type: investor.investor_type, status: investor.status, }, }); const form = edit.form; return (
{ e.preventDefault(); edit.submit(`/management/crm/investors/${investor.id}`); }} > edit.change('legal_name', e.target.value) } /> key === 'investor_type' ? ({ domestic: 'Nacional', foreign: 'Estrangeiro', institutional: 'Institucional', individual: 'Individual', }[value] ?? value) : key === 'status' ? ({ prospect: 'Potencial investidor', active: 'Activo', inactive: 'Inactivo', }[value] ?? value) : value } />

Contactos

Um contacto pode representar vários investidores. Alterações ao contacto são partilhadas entre essas relações.

{contacts.map((contact) => ( ))}

Leads associados

{leads.map((lead) => (

{lead.title} {' '} · {leadStates[lead.status]}

))}
); }