import Link from "next/link"; import { notFound } from "next/navigation"; import { fetchQuery } from "convex/nextjs"; import { ArrowLeft, ExternalLink, Phone } from "lucide-react"; import { api } from "@/convex/_generated/api"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { formatPhoneCallDuration, formatPhoneCallTimestamp, normalizePhoneFromIdentity, } from "@/lib/phone-calls"; type PageProps = { params: Promise<{ id: string; }>; }; export default async function AdminCallDetailPage({ params }: PageProps) { const { id } = await params; const detail = await fetchQuery(api.voiceSessions.getAdminPhoneCallDetail, { callId: id, }); if (!detail) { notFound(); } return (
Back to calls

Phone Call Detail

{normalizePhoneFromIdentity(detail.call.participantIdentity) || detail.call.participantIdentity}

Call Status Operational detail for this direct phone session.

Started

{formatPhoneCallTimestamp(detail.call.startedAt)}

Room

{detail.call.roomName}

Duration

{formatPhoneCallDuration(detail.call.durationMs)}

Participant Identity

{detail.call.participantIdentity || "Unknown"}

Call Status

{detail.call.callStatus}

Jessica Answered

{detail.call.answered ? "Yes" : "No"}

Lead Outcome

{detail.call.leadOutcome}

Email Summary

{detail.call.notificationStatus}

Summary

{detail.call.summaryText || "No summary available yet."}

Recording Status

{detail.call.recordingStatus || "Unavailable"}

Transcript Turns

{detail.call.transcriptTurnCount}

{detail.call.recordingUrl ? (
Open recording
) : null} {detail.call.notificationError ? (

Email Error

{detail.call.notificationError}

) : null}
Linked Lead {detail.linkedLead ? "Lead created from this phone call." : "No lead was created from this call."} {detail.linkedLead ? ( <>

Contact

{detail.linkedLead.firstName} {detail.linkedLead.lastName}

Lead Type

{detail.linkedLead.type}

Email

{detail.linkedLead.email}

Phone

{detail.linkedLead.phone}

Message

{detail.linkedLead.message || "—"}

) : (

Jessica handled the call, but it did not result in a submitted lead.

)}
Transcript Complete mirrored transcript for this phone call. {detail.turns.length === 0 ? (

No transcript turns were captured for this call.

) : ( detail.turns.map((turn: any) => (
{turn.role} {formatPhoneCallTimestamp(turn.createdAt)}

{turn.text}

)) )}
); } export const metadata = { title: "Phone Call Detail | Admin", description: "Review a mirrored direct phone call transcript and linked lead details", };