import Link from "next/link" import { notFound } from "next/navigation" import { fetchQuery } from "convex/nextjs" import { ArrowLeft, ContactRound, MessageSquare } from "lucide-react" import { api } from "@/convex/_generated/api" import { Badge } from "@/components/ui/badge" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card" type PageProps = { params: Promise<{ id: string }> } function formatTimestamp(value?: number) { if (!value) { return "—" } return new Date(value).toLocaleString("en-US", { month: "short", day: "numeric", year: "numeric", hour: "2-digit", minute: "2-digit", }) } export default async function AdminContactDetailPage({ params }: PageProps) { const { id } = await params const detail = await fetchQuery(api.crm.getAdminContactDetail, { contactId: id, }) if (!detail) { notFound() } return (
Back to contacts

{detail.contact.displayName}

Contact details and activity history.

Contact Profile Basic details and connected records.

Email

{detail.contact.email || "—"}

Phone

{detail.contact.phone || "—"}

Company

{detail.contact.company || "—"}

Status

{detail.contact.status}

GHL Contact ID

{detail.contact.ghlContactId || "—"}

Last Activity

{formatTimestamp(detail.contact.lastActivityAt)}

Conversations Conversations linked to this contact. {detail.conversations.length === 0 ? (

No conversations are linked to this contact yet.

) : ( detail.conversations.map((conversation: any) => (

{conversation.title || detail.contact.displayName}

{conversation.channel} •{" "} {formatTimestamp(conversation.lastMessageAt)}

{conversation.status}

{conversation.lastMessagePreview || "No preview yet"}

)) )}
Timeline Calls, messages, recordings, and lead events in one stream. {detail.timeline.length === 0 ? (

No timeline activity for this contact yet.

) : ( detail.timeline.map((item: any) => (
{item.type} {formatTimestamp(item.timestamp)}

{item.title || "Untitled"}

{item.body || "—"}

)) )}
) } export const metadata = { title: "Contact Detail | Admin", description: "Review a contact and full interaction timeline", }