fix: all 7 GraphQL queries — correct field names and LINKS/PHONES subfields

Leads: landingPage → { primaryLinkUrl }, remove duplicateOfLeadId
Ads: adFormat → format, destinationUrl/previewUrl → { primaryLinkUrl }
FollowUps: remove non-existent callId field
LeadActivities: durationSeconds → durationSec
All transforms updated to match query changes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 16:53:40 +05:30
parent 941b51731f
commit f341433c8f
2 changed files with 15 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
// Transform platform GraphQL responses → frontend entity types
// Platform remaps some field names during sync
// Platform remaps field names during sync — this layer normalizes them
import type { Lead, Campaign, Ad, FollowUp, LeadActivity, Call, Patient } from '@/types/entities';
@@ -31,13 +31,13 @@ export function transformLeads(data: any): Lead[] {
utmCampaign: n.utmCampaign,
utmContent: n.utmContent,
utmTerm: n.utmTerm,
landingPageUrl: n.landingPage,
landingPageUrl: n.landingPage?.primaryLinkUrl ?? null,
referrerUrl: n.referrerUrl,
leadScore: n.leadScore,
spamScore: n.spamScore ?? 0,
isSpam: n.isSpam ?? false,
isDuplicate: n.isDuplicate ?? false,
duplicateOfLeadId: n.duplicateOfLeadId,
duplicateOfLeadId: null,
firstContactedAt: n.firstContacted,
lastContactedAt: n.lastContacted,
contactAttempts: n.contactAttempts ?? 0,
@@ -82,11 +82,11 @@ export function transformAds(data: any): Ad[] {
adName: n.adName ?? n.name,
externalAdId: n.externalAdId,
adStatus: n.status,
adFormat: n.adFormat,
adFormat: n.format,
headline: n.headline,
adDescription: n.adDescription,
destinationUrl: n.destinationUrl,
previewUrl: n.previewUrl,
destinationUrl: n.destinationUrl?.primaryLinkUrl ?? null,
previewUrl: n.previewUrl?.primaryLinkUrl ?? null,
impressions: n.impressions ?? 0,
clicks: n.clicks ?? 0,
conversions: n.conversions ?? 0,
@@ -106,7 +106,7 @@ export function transformFollowUps(data: any): FollowUp[] {
priority: n.priority ?? 'NORMAL',
assignedAgent: n.assignedAgent,
patientId: n.patientId,
callId: n.callId,
callId: null,
patientName: undefined,
patientPhone: undefined,
description: n.name,
@@ -124,7 +124,7 @@ export function transformLeadActivities(data: any): LeadActivity[] {
previousValue: n.previousValue,
newValue: n.newValue,
channel: n.channel,
durationSeconds: n.durationSeconds,
durationSeconds: n.durationSec ?? 0,
outcome: n.outcome,
activityNotes: null,
leadId: n.leadId,