import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { ArrowRight, PhoneForwarded, PhoneOutgoing, User } from 'lucide-react' import { useZino } from '../zino-sdk' import { BRAND, MODELS } from '../config' import { isPlausiblePhone, placeCall, toE164 } from '../api' export default function PlaceCall() { const { client } = useZino() const navigate = useNavigate() const [leadName, setLeadName] = useState('') const [modelInterest, setModelInterest] = useState(MODELS[0]) const [leadPhone, setLeadPhone] = useState('') const [handoverNumber, setHandoverNumber] = useState('') const [error, setError] = useState('') const [busy, setBusy] = useState(false) // Both numbers joining the same conference would put the tester on hold with // themselves — catch it here rather than on a live call. const sameNumber = leadPhone && handoverNumber && toE164(leadPhone) === toE164(handoverNumber) const canSubmit = leadName.trim() && isPlausiblePhone(leadPhone) && isPlausiblePhone(handoverNumber) && !sameNumber && !busy const submit = async (e: React.FormEvent) => { e.preventDefault() if (!canSubmit) return setBusy(true) setError('') try { await placeCall(client, { leadName: leadName.trim(), leadPhone: toE164(leadPhone), modelInterest, handoverNumber: toE164(handoverNumber), }) navigate('/monitor') } catch (err: any) { setError(err?.message || 'Could not place the call') setBusy(false) } } return (

Place a call

{BRAND.agentName} calls the customer and qualifies the {BRAND.name} EV lead. When the caller asks for a person — or pushes on price — she announces a transfer and bridges the colleague below into the same call, then keeps listening to brief them.

setLeadName(e.target.value)} placeholder="Yashas" className="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm outline-none focus:border-red-500 focus:ring-2 focus:ring-red-100" />
} label={`Customer — ${BRAND.agentName} calls this`} value={leadPhone} onChange={setLeadPhone} accent="red" />
} label="Colleague — transfer bridges to this" value={handoverNumber} onChange={setHandoverNumber} accent="indigo" />
{sameNumber && (

Both numbers are the same — the transfer would conference you with yourself. Use two different phones.

)} {error && (

{error}

)}
The customer's phone rings within a few seconds.
) } function PhoneBox({ icon, label, value, onChange, accent, }: { icon: React.ReactNode label: string value: string onChange: (v: string) => void accent: 'red' | 'indigo' }) { const normalised = toE164(value) const valid = isPlausiblePhone(value) const ring = accent === 'red' ? 'focus:border-red-500 focus:ring-red-100' : 'focus:border-indigo-500 focus:ring-indigo-100' return (
onChange(e.target.value)} placeholder="+91 98765 43210" inputMode="tel" className={`w-full rounded-lg border border-slate-300 bg-white px-3 py-2 font-mono text-sm outline-none focus:ring-2 ${ring}`} /> {/* Show what will actually be dialled — the operator types loosely, the carrier needs E.164, and a silent rewrite is worth surfacing. */}

{value && (valid ? `Dials as ${normalised}` : 'Needs 10 digits, or +country code')}

) }