'use client' import { useEffect, useState } from 'react' import { useParams } from 'next/navigation' import { Header } from '@/components/Header' import { Footer } from '@/components/Footer' import { api } from '@/lib/api' import { ArrowLeft, TrendingUp, TrendingDown, Minus, Calendar, Globe, Building, DollarSign, ArrowRight, ExternalLink, } from 'lucide-react' import Link from 'next/link' import clsx from 'clsx' interface TldDetails { tld: string type: string description: string registry: string introduced: number trend: string trend_reason: string pricing: { avg: number min: number max: number } registrars: Array<{ name: string registration_price: number renewal_price: number transfer_price: number }> cheapest_registrar: string } interface TldHistory { tld: string current_price: number price_change_7d: number price_change_30d: number price_change_90d: number history: Array<{ date: string price: number }> } export default function TldDetailPage() { const params = useParams() const tld = params.tld as string const [details, setDetails] = useState(null) const [history, setHistory] = useState(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { if (tld) { loadData() } }, [tld]) const loadData = async () => { try { const [historyData, compareData] = await Promise.all([ api.getTldHistory(tld, 90), api.getTldCompare(tld), ]) // Build details from API data if (historyData && compareData) { const registrars = compareData.registrars || [] const prices = registrars.map(r => r.registration_price) const avgPrice = prices.length > 0 ? prices.reduce((a, b) => a + b, 0) / prices.length : 0 setDetails({ tld: tld, type: 'generic', description: `Domain extension .${tld}`, registry: 'Various', introduced: 2020, trend: historyData.price_change_30d > 0 ? 'up' : historyData.price_change_30d < 0 ? 'down' : 'stable', trend_reason: 'Price tracking available', pricing: { avg: avgPrice, min: Math.min(...prices), max: Math.max(...prices), }, registrars: registrars.sort((a, b) => a.registration_price - b.registration_price), cheapest_registrar: registrars[0]?.name || 'N/A', }) setHistory(historyData) } else { setError('Failed to load TLD data') } } catch (err) { setError('Failed to load TLD data') } finally { setLoading(false) } } const getTrendIcon = (trend: string) => { switch (trend) { case 'up': return case 'down': return default: return } } if (loading) { return (
) } if (error || !details) { return (

{error || 'TLD not found'}

Back to TLD Overview
) } return (
{/* Ambient glow */}
{/* Back Link */} All TLDs {/* Header */}

.{details.tld}

{details.description}

{getTrendIcon(details.trend)} {details.trend === 'up' ? 'Rising' : details.trend === 'down' ? 'Falling' : 'Stable'}

{details.trend_reason}

{/* Price Stats */}

Average Price

${details.pricing.avg.toFixed(2)}/yr

Cheapest

${details.pricing.min.toFixed(2)}/yr

at {details.cheapest_registrar}

Price Range

${details.pricing.min.toFixed(2)} - ${details.pricing.max.toFixed(2)}

{/* Price Changes */} {history && (

Price Changes

7 Days

0 ? "text-warning" : history.price_change_7d < 0 ? "text-accent" : "text-foreground-muted" )}> {history.price_change_7d > 0 ? '+' : ''}{history.price_change_7d.toFixed(2)}%

30 Days

0 ? "text-warning" : history.price_change_30d < 0 ? "text-accent" : "text-foreground-muted" )}> {history.price_change_30d > 0 ? '+' : ''}{history.price_change_30d.toFixed(2)}%

90 Days

0 ? "text-warning" : history.price_change_90d < 0 ? "text-accent" : "text-foreground-muted" )}> {history.price_change_90d > 0 ? '+' : ''}{history.price_change_90d.toFixed(2)}%

)} {/* Price Chart */} {history && history.history.length > 0 && (

90-Day Price History

{history.history.map((point, i) => { const prices = history.history.map(p => p.price) const minPrice = Math.min(...prices) const maxPrice = Math.max(...prices) const range = maxPrice - minPrice || 1 const height = ((point.price - minPrice) / range) * 100 const isLast = i === history.history.length - 1 return (
) })}
{history.history[0]?.date} Today
)} {/* TLD Info */}

TLD Information

Type

{details.type}

Registry

{details.registry}

Introduced

{details.introduced}

Registrars

{details.registrars.length} available

{/* Registrar Comparison */}

Registrar Comparison

{details.registrars.map((registrar, i) => ( ))}
Registrar Register Renew Transfer
{registrar.name} {i === 0 && ( Cheapest )}
${registrar.registration_price.toFixed(2)} ${registrar.renewal_price.toFixed(2)} ${registrar.transfer_price.toFixed(2)}
{/* CTA */}

Monitor .{details.tld} Domains

Track availability and get notified when your target domains become available.

Start Monitoring
) }