From 8bc01d1a9fb40fb5cca8a6d3e0516cc14661ebf1 Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Mon, 13 Apr 2026 13:57:59 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20QA=20defects=20=E2=80=94=20phone=20forma?= =?UTF-8?q?t=20E.164,=20call=20history=20shows=20phone=20not=20Unknown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - appointment-form: normalize phone to +91XXXXXXXXXX before patient create - appointment-form: use empty string not 'Unknown' for name fallback - call-history: show formatted phone number instead of 'Unknown' when no lead Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/call-desk/appointment-form.tsx | 7 +++++-- src/pages/call-history.tsx | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/call-desk/appointment-form.tsx b/src/components/call-desk/appointment-form.tsx index 7eead57..8495b9d 100644 --- a/src/components/call-desk/appointment-form.tsx +++ b/src/components/call-desk/appointment-form.tsx @@ -264,13 +264,16 @@ export const AppointmentForm = ({ if (!resolvedPatientId && callerNumber) { const trimmedName = patientName.trim(); const nameParts = { - firstName: trimmedName.split(' ')[0] || 'Unknown', + firstName: trimmedName.split(' ')[0] || '', lastName: trimmedName.split(' ').slice(1).join(' ') || '', }; + // Normalize phone to +91XXXXXXXXXX format + const phoneDigits = callerNumber.replace(/\D/g, '').slice(-10); + const phoneE164 = `+91${phoneDigits}`; try { const created = await apiClient.graphql<{ createPatient: { id: string } }>( `mutation($data: PatientCreateInput!) { createPatient(data: $data) { id } }`, - { data: { fullName: nameParts, phones: { primaryPhoneNumber: callerNumber }, patientType: 'NEW' } }, + { data: { fullName: nameParts, phones: { primaryPhoneNumber: phoneE164 }, patientType: 'NEW' } }, ); resolvedPatientId = created.createPatient.id; } catch (err) { diff --git a/src/pages/call-history.tsx b/src/pages/call-history.tsx index 3af72d3..3b35a94 100644 --- a/src/pages/call-history.tsx +++ b/src/pages/call-history.tsx @@ -234,7 +234,8 @@ export const CallHistoryPage = () => { {(call) => { - const patientName = call.leadName ?? leadNameMap.get(call.leadId ?? '') ?? 'Unknown'; + const phoneRawForName = call.callerNumber?.[0]?.number ?? ''; + const patientName = call.leadName ?? leadNameMap.get(call.leadId ?? '') ?? (phoneRawForName ? formatPhone({ number: phoneRawForName, callingCode: '+91' }) : 'Unknown'); const phoneDisplay = formatPhoneDisplay(call); const phoneRaw = call.callerNumber?.[0]?.number ?? ''; const dispositionCfg = call.disposition !== null ? dispositionConfig[call.disposition] : null;