'use client'
import { useEffect, useState, memo } from 'react'
import { useParams } from 'next/navigation'
import { api } from '@/lib/api'
import { Header } from '@/components/Header'
import { Footer } from '@/components/Footer'
import {
Shield,
CheckCircle,
Clock,
DollarSign,
Mail,
User,
Building,
Phone,
MessageSquare,
Send,
Loader2,
AlertCircle,
Sparkles,
TrendingUp,
Globe,
Calendar,
ExternalLink,
ShieldCheck,
Lock,
ArrowRight,
Check,
Info
} from 'lucide-react'
import Link from 'next/link'
import clsx from 'clsx'
interface Listing {
domain: string
slug: string
title: string | null
description: string | null
asking_price: number | null
currency: string
price_type: 'bid' | 'fixed' | 'negotiable'
pounce_score: number | null
estimated_value: number | null
is_verified: boolean
allow_offers: boolean
public_url: string
seller_verified: boolean
seller_member_since: string | null
status: string
}
// Tooltip Component
const Tooltip = memo(({ children, content }: { children: React.ReactNode; content: string }) => (
))
Tooltip.displayName = 'Tooltip'
export default function BuyDomainPage() {
const params = useParams()
const slug = params.slug as string
const [listing, setListing] = useState(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState(null)
// Inquiry form state
const [submitting, setSubmitting] = useState(false)
const [submitted, setSubmitted] = useState(false)
const [formData, setFormData] = useState({
name: '',
email: '',
phone: '',
company: '',
message: '',
offer_amount: '',
})
useEffect(() => {
loadListing()
}, [slug])
const loadListing = async () => {
setLoading(true)
setError(null)
try {
const data = await api.request(`/listings/${slug}`)
setListing(data)
} catch (err: any) {
setError(err.message || 'Listing not found')
} finally {
setLoading(false)
}
}
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setSubmitting(true)
try {
await api.request(`/listings/${slug}/inquire`, {
method: 'POST',
body: JSON.stringify({
...formData,
offer_amount: formData.offer_amount ? parseFloat(formData.offer_amount) : null,
}),
})
setSubmitted(true)
} catch (err: any) {
setError(err.message || 'Failed to submit inquiry')
} finally {
setSubmitting(false)
}
}
const formatPrice = (price: number, currency: string) => {
return new Intl.NumberFormat('en-US', {
style: 'currency',
currency,
minimumFractionDigits: 0,
maximumFractionDigits: 0,
}).format(price)
}
const getScoreColor = (score: number) => {
if (score >= 80) return 'text-emerald-400'
if (score >= 60) return 'text-amber-400'
return 'text-zinc-500'
}
if (loading) {
return (
)
}
if (error || !listing) {
return (
{/* Background Grid */}
Domain Unavailable
The domain you are looking for has been sold, removed, or is temporarily unavailable.
Browse Marketplace
)
}
return (
{/* Hero Section */}
{/* Cinematic Background */}
{/* Top Label */}
{/* Domain Name */}
{listing.domain}
{listing.title && (
{listing.title}
)}
{/* Left Column: Details & Stats */}
{/* Description */}
{listing.description && (
About this Asset
{listing.description}
)}
{/* Stats Grid */}
{listing.pounce_score || 'N/A'}
/100
Based on length, TLD, and market demand.
{listing.estimated_value ? formatPrice(listing.estimated_value, listing.currency) : '—'}
Automated AI valuation estimate.
{/* Trust Section */}
Secure Transfer Guarantee
Escrow Service
Funds held securely until transfer is complete.
Verified Owner
Ownership verified via DNS validation.
Fast Transfer
Most transfers completed within 24 hours.
{/* Right Column: Action Card */}
{/* Card Shine */}
{!submitted ? (
<>
{listing.price_type === 'fixed' ? 'Buy Now Price' : 'Asking Price'}
{listing.asking_price ? (
{formatPrice(listing.asking_price, listing.currency)}
) : (
Make Offer
)}
{listing.price_type === 'negotiable' && listing.asking_price && (
Negotiable
)}
{/* Always Visible Form */}
>
) : (
Inquiry Sent
The seller has been notified and will contact you shortly.
)}
)
}