import { useState } from 'react' import { AlertTriangle, Building2, FileSignature, UserCheck } from 'lucide-react' import { Badge, Panel } from '../components/ui' import { Empty, Labeled, Note, Select, btnGhost, btnPrimary, fieldCls } from '../components/form' import { COMMITMENT_TYPES, PARTNER_ROLES, PARTNER_STATUSES, partnerColor, useAddCommitment, useAddPartner, useKeyPersonnel, useTeamingPartners, useUpdateCommitment, useUpdatePartner, } from '../lib/teaming' // TEAMING AND KEY PERSONNEL, on the capture record because that is where the decisions are made. // // A teaming agreement is negotiated while a pursuit is being shaped, months before a proposal exists. A key // person is named in a bid and evaluated by the customer, and if they walk between submission and award the // score walks with them. Both were invisible to this product until now. export function TeamingPanel({ opportunityId }: { opportunityId: string }) { const q = useTeamingPartners(opportunityId) const add = useAddPartner(opportunityId) const update = useUpdatePartner(opportunityId) const [name, setName] = useState('') const [role, setRole] = useState('subcontractor') const partners = q.data?.partners ?? [] const unsigned = partners.filter((p) => p.status !== 'agreement_signed' && p.status !== 'declined') return ( {q.isError ? ( {(q.error as Error).message} ) : partners.length === 0 ? ( ) : ( )}
{!open ? ( ) : (
{ e.preventDefault() add.mutate(form, { onSuccess: () => setOpen(false) }) }} >
setForm({ ...form, requirement_id: e.target.value })} className={fieldCls} /> setForm({ ...form, role_title: e.target.value })} className={fieldCls} /> {/* EITHER our candidate OR a partner's person, never both. The database refuses a row naming neither or both, and saying so here means the refusal is rare rather than routine. */} setForm({ ...form, candidate_id: e.target.value, teaming_partner_id: '', partner_person_name: '' })} className={fieldCls} /> setForm({ ...form, partner_person_name: e.target.value })} className={fieldCls} /> )} setForm({ ...form, signed_on: e.target.value })} className={fieldCls} /> setForm({ ...form, expires_on: e.target.value })} className={fieldCls} />
{add.isError && {(add.error as Error).message}}
)}
) }