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

{detail.call.contactDisplayName || 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"}

Caller Phone

{detail.call.callerPhone || normalizePhoneFromIdentity(detail.call.participantIdentity) || "Unknown"}

Company

{detail.call.contactCompany || "—"}

Call Status

{detail.call.callStatus}

Jessica Answered

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

Lead Outcome

{detail.call.leadOutcome}

Email Summary

{detail.call.notificationStatus}

Reminder

{detail.call.reminderStatus || "none"}

Warm Transfer

{detail.call.warmTransferStatus || "none"}

Summary

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

Recording Status

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

Transcript Turns

{detail.call.transcriptTurnCount}

{detail.call.reminderStartAt ? (

Reminder Time

{formatPhoneCallTimestamp(detail.call.reminderStartAt)}

) : null} {detail.call.warmTransferFailureReason ? (

Transfer Detail

{detail.call.warmTransferFailureReason}

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

Email Error

{detail.call.notificationError}

) : null} {detail.call.reminderCalendarHtmlLink ? (
Open reminder
) : 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.

)} {detail.contactProfile ? (

Contact Profile

{detail.contactProfile.displayName || [detail.contactProfile.firstName, detail.contactProfile.lastName] .filter(Boolean) .join(" ") || "Known caller"}

{detail.contactProfile.company || detail.contactProfile.email || "No company or email yet"}

) : null}
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", }