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 (
Contact details and activity history.
{detail.contact.email || "—"}
Phone
{detail.contact.phone || "—"}
Company
{detail.contact.company || "—"}
Status
GHL Contact ID
{detail.contact.ghlContactId || "—"}
Last Activity
{formatTimestamp(detail.contact.lastActivityAt)}
No conversations are linked to this contact yet.
) : ( detail.conversations.map((conversation: any) => ({conversation.title || detail.contact.displayName}
{conversation.channel} •{" "} {formatTimestamp(conversation.lastMessageAt)}
{conversation.lastMessagePreview || "No preview yet"}
No timeline activity for this contact yet.
) : ( detail.timeline.map((item: any) => ({item.title || "Untitled"}
{item.body || "—"}