From 40c80f5fe1a5459bb3f120fe96d6fef8cac56261 Mon Sep 17 00:00:00 2001 From: Kaj Kowalski Date: Sun, 13 Jul 2025 16:17:16 +0200 Subject: [PATCH] fix: standardize nullable field handling in session mapping - Use undefined for optional boolean fields (escalated, forwardedHr) - Use null for fields explicitly typed as '| null' in ChatSession interface - Use undefined for optional-only fields (messagesSent, initialMsg) - Ensures type consistency throughout mapPrismaSessionToChatSession function --- app/api/dashboard/session/[id]/route.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/api/dashboard/session/[id]/route.ts b/app/api/dashboard/session/[id]/route.ts index 4f692e5..49ab91a 100644 --- a/app/api/dashboard/session/[id]/route.ts +++ b/app/api/dashboard/session/[id]/route.ts @@ -53,13 +53,13 @@ function mapPrismaSessionToChatSession(prismaSession: { country: prismaSession.country ?? null, ipAddress: prismaSession.ipAddress ?? null, sentiment: prismaSession.sentiment ?? null, - messagesSent: prismaSession.messagesSent ?? undefined, // Maintain consistency with other nullable fields + messagesSent: prismaSession.messagesSent ?? undefined, avgResponseTime: prismaSession.avgResponseTime ?? null, - escalated: prismaSession.escalated ?? false, - forwardedHr: prismaSession.forwardedHr ?? false, + escalated: prismaSession.escalated ?? undefined, + forwardedHr: prismaSession.forwardedHr ?? undefined, initialMsg: prismaSession.initialMsg ?? undefined, - fullTranscriptUrl: prismaSession.fullTranscriptUrl ?? undefined, - summary: prismaSession.summary ?? undefined, // New field + fullTranscriptUrl: prismaSession.fullTranscriptUrl ?? null, + summary: prismaSession.summary ?? null, transcriptContent: undefined, // Not available in Session model messages: prismaSession.messages?.map((msg) => ({