"use client" import { useState, useEffect } from "react" import Link from "next/link" import { motion } from "framer-motion" import { use } from "react" import { PageHeader } from "@/components/shared/page-header" import { LeadDetailsCard } from "@/components/leads/lead-details-card" import { LeadStatusBadge } from "@/components/leads/lead-status-badge" import { NoteTimeline } from "@/components/notes/note-timeline" import { NoteForm } from "@/components/notes/note-form" import { Button } from "@/components/ui/button" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { ArrowLeft, Edit, ExternalLink } from "lucide-react" import { Lead, Note } from "@/types" export default function LeadDetailsPage({ params }: { params: Promise<{ id: string }> }) { const { id } = use(params) const [lead, setLead] = useState(null) const [leadNotes, setLeadNotes] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { async function fetchData() { try { const [leadRes, notesRes] = await Promise.all([ fetch(`/api/leads/${id}`), fetch(`/api/leads/${id}/notes`), ]) if (leadRes.ok) setLead(await leadRes.json()) if (notesRes.ok) setLeadNotes(await notesRes.json()) } catch { // ignore } setLoading(false) } fetchData() }, [id]) if (loading) { return (

Loading...

) } if (!lead) { return (

Lead not found

The lead you are looking for does not exist.

) } return (
Back to leads {lead.companyName}
} description={lead.contactName} >

Activity

Lead Created

{new Date(lead.createdAt).toLocaleDateString()}

{leadNotes.slice(0, 3).map((note) => (

{note.authorName}

{note.note.slice(0, 60)}...

))}

Quick Actions

) }