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 (
{detail.call.contactDisplayName || normalizePhoneFromIdentity(detail.call.participantIdentity) || detail.call.participantIdentity}
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
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}
Reminder Time
{formatPhoneCallTimestamp(detail.call.reminderStartAt)}
Transfer Detail
{detail.call.warmTransferFailureReason}
Email Error
{detail.call.notificationError}
Contact
{detail.linkedLead.firstName} {detail.linkedLead.lastName}
Lead Type
{detail.linkedLead.type}
{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"}
No transcript turns were captured for this call.
) : ( detail.turns.map((turn: any) => ({turn.text}