style: Unify Terminal backgrounds & redesign TLD detail page

- Remove all hardcoded 'bg-black' backgrounds from Terminal pages
- Let global background with emerald glow shine through
- Redesign TLD detail page to match Market/Radar/Intel style
- Use consistent StatCards, glassmorphism containers, and spacing
- Improve Quick Check section on TLD detail page
- Unify Watchlist and Listing page backgrounds for consistency
This commit is contained in:
2025-12-11 08:40:18 +01:00
parent 254c2b2cf0
commit 5857123ed5
3 changed files with 1387 additions and 1123 deletions

View File

@ -3,7 +3,6 @@
import { useEffect, useState, useMemo, useRef } from 'react'
import { useParams } from 'next/navigation'
import { TerminalLayout } from '@/components/TerminalLayout'
import { PageContainer, StatCard } from '@/components/PremiumTable'
import { useStore } from '@/lib/store'
import { api } from '@/lib/api'
import {
@ -24,10 +23,69 @@ import {
DollarSign,
BarChart3,
Shield,
Loader2,
Info,
ChevronDown
} from 'lucide-react'
import Link from 'next/link'
import clsx from 'clsx'
// ============================================================================
// SHARED COMPONENTS
// ============================================================================
function Tooltip({ children, content }: { children: React.ReactNode; content: string }) {
return (
<div className="relative flex items-center group/tooltip w-fit">
{children}
<div className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-zinc-900 border border-zinc-800 rounded text-[10px] text-zinc-300 whitespace-nowrap opacity-0 group-hover/tooltip:opacity-100 transition-opacity pointer-events-none z-50 shadow-xl">
{content}
<div className="absolute top-full left-1/2 -translate-x-1/2 -mt-px border-4 border-transparent border-t-zinc-800" />
</div>
</div>
)
}
function StatCard({
label,
value,
subValue,
icon: Icon,
trend
}: {
label: string
value: string | number
subValue?: string
icon: any
trend?: 'up' | 'down' | 'neutral' | 'active'
}) {
return (
<div className="bg-zinc-900/40 border border-white/5 rounded-xl p-4 flex items-start justify-between hover:bg-white/[0.02] transition-colors relative overflow-hidden group">
<div className="absolute inset-0 bg-gradient-to-br from-white/[0.03] to-transparent opacity-0 group-hover:opacity-100 transition-opacity" />
<div className="relative z-10">
<p className="text-[11px] font-semibold text-zinc-500 uppercase tracking-wider mb-1">{label}</p>
<div className="flex items-baseline gap-2">
<span className="text-2xl font-bold text-white tracking-tight">{value}</span>
{subValue && <span className="text-xs text-zinc-500 font-medium">{subValue}</span>}
</div>
</div>
<div className={clsx(
"relative z-10 p-2 rounded-lg bg-zinc-800/50 transition-colors",
trend === 'up' && "text-emerald-400 bg-emerald-500/10",
trend === 'down' && "text-rose-400 bg-rose-500/10",
trend === 'active' && "text-blue-400 bg-blue-500/10 animate-pulse",
trend === 'neutral' && "text-zinc-400"
)}>
<Icon className="w-4 h-4" />
</div>
</div>
)
}
// ============================================================================
// TYPES & DATA
// ============================================================================
interface TldDetails {
tld: string
type: string
@ -48,7 +106,6 @@ interface TldDetails {
transfer_price: number
}>
cheapest_registrar: string
// New fields from table
min_renewal_price: number
price_change_1y: number
price_change_3y: number
@ -79,7 +136,6 @@ interface DomainCheckResult {
expiration_date?: string | null
}
// Registrar URLs
const REGISTRAR_URLS: Record<string, string> = {
'Namecheap': 'https://www.namecheap.com/domains/registration/results/?domain=',
'Porkbun': 'https://porkbun.com/checkout/search?q=',
@ -92,7 +148,10 @@ const REGISTRAR_URLS: Record<string, string> = {
type ChartPeriod = '1M' | '3M' | '1Y' | 'ALL'
// Premium Chart Component with real data
// ============================================================================
// SUB-COMPONENTS
// ============================================================================
function PriceChart({
data,
chartStats,
@ -105,7 +164,7 @@ function PriceChart({
if (data.length === 0) {
return (
<div className="h-48 flex items-center justify-center text-foreground-muted">
<div className="h-48 flex items-center justify-center text-zinc-600 text-xs font-mono uppercase">
No price history available
</div>
)
@ -124,17 +183,17 @@ function PriceChart({
const linePath = points.map((p, i) => `${i === 0 ? 'M' : 'L'}${p.x},${p.y}`).join(' ')
const areaPath = linePath + ` L${points[points.length - 1].x},100 L${points[0].x},100 Z`
const isRising = data[data.length - 1].price > data[0].price
const strokeColor = isRising ? '#f97316' : '#00d4aa'
const isRising = data[data.length - 1].price >= data[0].price
const strokeColor = isRising ? '#10b981' : '#f43f5e' // emerald-500 : rose-500
return (
<div
ref={containerRef}
className="relative h-48"
className="relative h-48 w-full"
onMouseLeave={() => setHoveredIndex(null)}
>
<svg
className="w-full h-full"
className="w-full h-full overflow-visible"
viewBox="0 0 100 100"
preserveAspectRatio="none"
onMouseMove={(e) => {
@ -147,46 +206,59 @@ function PriceChart({
>
<defs>
<linearGradient id="chartGradient" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stopColor={strokeColor} stopOpacity="0.3" />
<stop offset="100%" stopColor={strokeColor} stopOpacity="0.02" />
<stop offset="0%" stopColor={strokeColor} stopOpacity="0.2" />
<stop offset="100%" stopColor={strokeColor} stopOpacity="0" />
</linearGradient>
</defs>
<path d={areaPath} fill="url(#chartGradient)" />
<path d={linePath} fill="none" stroke={strokeColor} strokeWidth="2" />
<path d={linePath} fill="none" stroke={strokeColor} strokeWidth="1.5" vectorEffect="non-scaling-stroke" />
{hoveredIndex !== null && points[hoveredIndex] && (
<circle
cx={points[hoveredIndex].x}
cy={points[hoveredIndex].y}
r="4"
fill={strokeColor}
stroke="#0a0a0a"
strokeWidth="2"
/>
<g>
<line
x1={points[hoveredIndex].x}
y1="0"
x2={points[hoveredIndex].x}
y2="100"
stroke="#52525b"
strokeWidth="1"
strokeDasharray="2"
vectorEffect="non-scaling-stroke"
/>
<circle
cx={points[hoveredIndex].x}
cy={points[hoveredIndex].y}
r="4"
fill="#09090b"
stroke={strokeColor}
strokeWidth="2"
vectorEffect="non-scaling-stroke"
/>
</g>
)}
</svg>
{/* Tooltip */}
{hoveredIndex !== null && points[hoveredIndex] && (
<div
className="absolute -top-2 transform -translate-x-1/2 bg-background border border-border rounded-lg px-3 py-2 shadow-lg z-10 pointer-events-none"
className="absolute -top-10 transform -translate-x-1/2 bg-zinc-900 border border-zinc-800 rounded px-3 py-1.5 shadow-xl z-20 pointer-events-none"
style={{ left: `${points[hoveredIndex].x}%` }}
>
<p className="text-sm font-medium text-foreground">${points[hoveredIndex].price.toFixed(2)}</p>
<p className="text-xs text-foreground-muted">{new Date(points[hoveredIndex].date).toLocaleDateString()}</p>
<div className="flex flex-col items-center">
<span className="text-xs font-bold text-white font-mono">${points[hoveredIndex].price.toFixed(2)}</span>
<span className="text-[10px] text-zinc-500 font-mono">{new Date(points[hoveredIndex].date).toLocaleDateString()}</span>
</div>
<div className="absolute top-full left-1/2 -translate-x-1/2 -mt-px border-4 border-transparent border-t-zinc-900" />
</div>
)}
{/* Y-axis labels */}
<div className="absolute left-0 top-0 bottom-0 flex flex-col justify-between text-xs text-foreground-subtle -ml-12 w-10 text-right">
<span>${maxPrice.toFixed(2)}</span>
<span>${((maxPrice + minPrice) / 2).toFixed(2)}</span>
<span>${minPrice.toFixed(2)}</span>
</div>
</div>
)
}
// ============================================================================
// MAIN PAGE
// ============================================================================
export default function CommandTldDetailPage() {
const params = useParams()
const { fetchSubscription } = useStore()
@ -213,7 +285,7 @@ export default function CommandTldDetailPage() {
const [historyData, compareData, overviewData] = await Promise.all([
api.getTldHistory(tld, 365),
api.getTldCompare(tld),
api.getTldOverview(1, 0, 'popularity', tld), // Get the specific TLD data
api.getTldOverview(1, 0, 'popularity', tld),
])
if (historyData && compareData) {
@ -221,7 +293,6 @@ export default function CommandTldDetailPage() {
a.registration_price - b.registration_price
)
// Get additional data from overview API (1y, 3y change, risk)
const tldFromOverview = overviewData?.tlds?.[0]
setDetails({
@ -239,7 +310,6 @@ export default function CommandTldDetailPage() {
},
registrars: sortedRegistrars,
cheapest_registrar: compareData.cheapest_registrar || sortedRegistrars[0]?.name || 'N/A',
// New fields from overview
min_renewal_price: tldFromOverview?.min_renewal_price || sortedRegistrars[0]?.renewal_price || 0,
price_change_1y: tldFromOverview?.price_change_1y || 0,
price_change_3y: tldFromOverview?.price_change_3y || 0,
@ -316,7 +386,6 @@ export default function CommandTldDetailPage() {
return baseUrl
}
// Calculate renewal trap info
const getRenewalInfo = () => {
if (!details?.registrars?.length) return null
const cheapest = details.registrars[0]
@ -331,23 +400,22 @@ export default function CommandTldDetailPage() {
const renewalInfo = getRenewalInfo()
// Risk badge component
const getRiskBadge = () => {
if (!details) return null
const level = details.risk_level
const reason = details.risk_reason
return (
<span className={clsx(
"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-sm font-medium",
level === 'high' && "bg-red-500/10 text-red-400",
level === 'medium' && "bg-amber-500/10 text-amber-400",
level === 'low' && "bg-accent/10 text-accent"
"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",
level === 'high' && "bg-rose-500/10 text-rose-400 border border-rose-500/20",
level === 'medium' && "bg-amber-500/10 text-amber-400 border border-amber-500/20",
level === 'low' && "bg-emerald-500/10 text-emerald-400 border border-emerald-500/20"
)}>
<span className={clsx(
"w-2.5 h-2.5 rounded-full",
level === 'high' && "bg-red-400",
"w-1.5 h-1.5 rounded-full",
level === 'high' && "bg-rose-400 animate-pulse",
level === 'medium' && "bg-amber-400",
level === 'low' && "bg-accent"
level === 'low' && "bg-emerald-400"
)} />
{reason}
</span>
@ -356,366 +424,307 @@ export default function CommandTldDetailPage() {
if (loading) {
return (
<TerminalLayout title={`.${tld}`} subtitle="Loading...">
<PageContainer>
<div className="flex items-center justify-center py-20">
<RefreshCw className="w-6 h-6 text-accent animate-spin" />
</div>
</PageContainer>
<TerminalLayout hideHeaderSearch={true}>
<div className="flex items-center justify-center min-h-[50vh]">
<Loader2 className="w-8 h-8 text-emerald-500 animate-spin" />
</div>
</TerminalLayout>
)
}
if (error || !details) {
return (
<TerminalLayout title="TLD Not Found" subtitle="Error loading data">
<PageContainer>
<div className="text-center py-20">
<div className="w-16 h-16 bg-background-secondary rounded-full flex items-center justify-center mx-auto mb-6">
<X className="w-8 h-8 text-foreground-subtle" />
</div>
<h1 className="text-xl font-medium text-foreground mb-2">TLD Not Found</h1>
<p className="text-foreground-muted mb-8">{error || `The TLD .${tld} could not be found.`}</p>
<Link
href="/terminal/intel"
className="inline-flex items-center gap-2 px-6 py-3 bg-accent text-background rounded-xl font-medium hover:bg-accent-hover transition-all"
>
<ArrowLeft className="w-4 h-4" />
Back to TLD Pricing
</Link>
</div>
</PageContainer>
<TerminalLayout hideHeaderSearch={true}>
<div className="flex flex-col items-center justify-center min-h-[50vh] text-zinc-400">
<X className="w-12 h-12 text-zinc-600 mb-4" />
<h1 className="text-xl font-bold text-white mb-2">TLD Not Found</h1>
<p className="mb-6">The extension .{tld} is not currently tracked.</p>
<Link href="/terminal/intel" className="text-emerald-400 hover:text-emerald-300 flex items-center gap-2">
<ArrowLeft className="w-4 h-4" /> Back to Intelligence
</Link>
</div>
</TerminalLayout>
)
}
return (
<TerminalLayout
title={`.${details.tld}`}
subtitle={details.description}
>
<PageContainer>
{/* Breadcrumb */}
<nav className="flex items-center gap-2 text-sm mb-6">
<Link href="/terminal/intel" className="text-foreground-subtle hover:text-foreground transition-colors">
TLD Pricing
</Link>
<ChevronRight className="w-3.5 h-3.5 text-foreground-subtle" />
<span className="text-foreground font-medium">.{details.tld}</span>
</nav>
{/* Stats Grid - All info from table */}
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
<div title="Lowest first-year registration price across all tracked registrars">
<StatCard
title="Buy Price (1y)"
value={`$${details.pricing.min.toFixed(2)}`}
subtitle={`at ${details.cheapest_registrar}`}
icon={DollarSign}
/>
</div>
<div title={renewalInfo?.isTrap
? `Warning: Renewal is ${renewalInfo.ratio.toFixed(1)}x the registration price`
: 'Annual renewal price after first year'}>
<StatCard
title="Renewal (1y)"
value={details.min_renewal_price ? `$${details.min_renewal_price.toFixed(2)}` : '—'}
subtitle={renewalInfo?.isTrap ? `${renewalInfo.ratio.toFixed(1)}x registration` : 'per year'}
icon={RefreshCw}
/>
</div>
<div title="Price change over the last 12 months">
<StatCard
title="1y Change"
value={`${details.price_change_1y > 0 ? '+' : ''}${details.price_change_1y.toFixed(0)}%`}
icon={details.price_change_1y > 0 ? TrendingUp : details.price_change_1y < 0 ? TrendingDown : Minus}
/>
</div>
<div title="Price change over the last 3 years">
<StatCard
title="3y Change"
value={`${details.price_change_3y > 0 ? '+' : ''}${details.price_change_3y.toFixed(0)}%`}
icon={BarChart3}
/>
</div>
<TerminalLayout hideHeaderSearch={true}>
<div className="relative">
{/* Ambient Background Glow */}
<div className="pointer-events-none absolute inset-0 -z-10">
<div className="absolute top-[-200px] right-[-100px] w-[800px] h-[600px] bg-emerald-500/5 rounded-full blur-[120px] mix-blend-screen" />
<div className="absolute bottom-0 left-[-100px] w-[600px] h-[500px] bg-blue-500/5 rounded-full blur-[100px] mix-blend-screen" />
</div>
{/* Risk Level */}
<div className="flex items-center gap-4 p-4 bg-background-secondary/30 border border-border/50 rounded-xl">
<Shield className="w-5 h-5 text-foreground-muted" />
<div className="flex-1">
<p className="text-sm font-medium text-foreground">Risk Assessment</p>
<p className="text-xs text-foreground-muted">Based on renewal ratio, price volatility, and market trends</p>
</div>
{getRiskBadge()}
</div>
<div className="space-y-6 pb-20 md:pb-0 relative">
{/* Header Section */}
<div className="flex flex-col md:flex-row justify-between items-start md:items-end gap-6 border-b border-white/5 pb-8">
<div className="space-y-4">
{/* Breadcrumb */}
<nav className="flex items-center gap-2 text-xs font-medium text-zinc-500 uppercase tracking-widest">
<Link href="/terminal/intel" className="hover:text-emerald-400 transition-colors">
Intelligence
</Link>
<ChevronRight className="w-3 h-3" />
<span className="text-white">.{details.tld}</span>
</nav>
{/* Renewal Trap Warning */}
{renewalInfo?.isTrap && (
<div className="p-4 bg-amber-500/10 border border-amber-500/20 rounded-xl flex items-start gap-3">
<AlertTriangle className="w-5 h-5 text-amber-400 shrink-0 mt-0.5" />
<div>
<p className="text-sm font-medium text-amber-400">Renewal Trap Detected</p>
<p className="text-sm text-foreground-muted mt-1">
The renewal price (${renewalInfo.renewal.toFixed(2)}) is {renewalInfo.ratio.toFixed(1)}x higher than the registration price (${renewalInfo.registration.toFixed(2)}).
Consider the total cost of ownership before registering.
</p>
</div>
</div>
)}
{/* Price Chart */}
<div className="p-6 bg-background-secondary/30 border border-border/50 rounded-2xl">
<div className="flex items-center justify-between mb-6">
<h2 className="text-lg font-medium text-foreground">Price History</h2>
<div className="flex items-center gap-1 bg-foreground/5 rounded-lg p-1">
{(['1M', '3M', '1Y', 'ALL'] as ChartPeriod[]).map((period) => (
<button
key={period}
onClick={() => setChartPeriod(period)}
className={clsx(
"px-3 py-1.5 text-xs font-medium rounded-md transition-all",
chartPeriod === period
? "bg-accent text-background"
: "text-foreground-muted hover:text-foreground"
)}
>
{period}
</button>
))}
</div>
</div>
<div className="pl-14">
<PriceChart data={filteredHistory} chartStats={chartStats} />
</div>
{/* Chart Stats */}
<div className="grid grid-cols-3 gap-4 mt-6 pt-6 border-t border-border/30">
<div className="text-center">
<p className="text-xs text-foreground-subtle uppercase mb-1">Period High</p>
<p className="text-lg font-medium text-foreground tabular-nums">${chartStats.high.toFixed(2)}</p>
</div>
<div className="text-center">
<p className="text-xs text-foreground-subtle uppercase mb-1">Average</p>
<p className="text-lg font-medium text-foreground tabular-nums">${chartStats.avg.toFixed(2)}</p>
</div>
<div className="text-center">
<p className="text-xs text-foreground-subtle uppercase mb-1">Period Low</p>
<p className="text-lg font-medium text-foreground tabular-nums">${chartStats.low.toFixed(2)}</p>
</div>
</div>
</div>
{/* Registrar Comparison */}
<div className="p-6 bg-background-secondary/30 border border-border/50 rounded-2xl">
<h2 className="text-lg font-medium text-foreground mb-6">Registrar Comparison</h2>
<div className="overflow-x-auto">
<table className="w-full">
<thead>
<tr className="border-b border-border/30">
<th className="text-left pb-3 text-sm font-medium text-foreground-muted">Registrar</th>
<th className="text-right pb-3 text-sm font-medium text-foreground-muted" title="First year registration price">Register</th>
<th className="text-right pb-3 text-sm font-medium text-foreground-muted" title="Annual renewal price">Renew</th>
<th className="text-right pb-3 text-sm font-medium text-foreground-muted" title="Transfer from another registrar">Transfer</th>
<th className="text-right pb-3"></th>
</tr>
</thead>
<tbody className="divide-y divide-border/20">
{details.registrars.map((registrar, idx) => {
const hasRenewalTrap = registrar.renewal_price / registrar.registration_price > 1.5
const isBestValue = idx === 0 && !hasRenewalTrap
return (
<tr key={registrar.name} className={clsx(isBestValue && "bg-accent/5")}>
<td className="py-4">
<div className="flex items-center gap-2">
<span className="font-medium text-foreground">{registrar.name}</span>
{isBestValue && (
<span
className="px-2 py-0.5 text-xs bg-accent/10 text-accent rounded-full cursor-help"
title="Best overall value: lowest registration price without renewal trap"
>
Best
</span>
)}
{idx === 0 && hasRenewalTrap && (
<span
className="px-2 py-0.5 text-xs bg-amber-500/10 text-amber-400 rounded-full cursor-help"
title="Cheapest registration but high renewal costs"
>
Cheap Start
</span>
)}
</div>
</td>
<td className="py-4 text-right">
<span
className={clsx(
"font-medium tabular-nums cursor-help",
isBestValue ? "text-accent" : "text-foreground"
)}
title={`First year: $${registrar.registration_price.toFixed(2)}`}
>
${registrar.registration_price.toFixed(2)}
</span>
</td>
<td className="py-4 text-right">
<div className="flex items-center gap-1 justify-end">
<span
className={clsx(
"tabular-nums cursor-help",
hasRenewalTrap ? "text-amber-400" : "text-foreground-muted"
)}
title={hasRenewalTrap
? `Renewal is ${(registrar.renewal_price / registrar.registration_price).toFixed(1)}x the registration price`
: `Annual renewal: $${registrar.renewal_price.toFixed(2)}`}
>
${registrar.renewal_price.toFixed(2)}
</span>
{hasRenewalTrap && (
<span title={`Renewal trap: ${(registrar.renewal_price / registrar.registration_price).toFixed(1)}x registration price`}>
<AlertTriangle className="w-3.5 h-3.5 text-amber-400 cursor-help" />
</span>
)}
</div>
</td>
<td className="py-4 text-right">
<span
className="text-foreground-muted tabular-nums cursor-help"
title={`Transfer from another registrar: $${registrar.transfer_price.toFixed(2)}`}
>
${registrar.transfer_price.toFixed(2)}
</span>
</td>
<td className="py-4 text-right">
<a
href={getRegistrarUrl(registrar.name)}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1 text-sm text-accent hover:text-accent/80 transition-colors"
title={`Register at ${registrar.name}`}
>
Visit
<ExternalLink className="w-3.5 h-3.5" />
</a>
</td>
</tr>
)
})}
</tbody>
</table>
</div>
</div>
{/* Quick Domain Check */}
<div className="p-6 bg-background-secondary/30 border border-border/50 rounded-2xl">
<h2 className="text-lg font-medium text-foreground mb-4">Quick Domain Check</h2>
<p className="text-sm text-foreground-muted mb-4">
Check if a domain is available with .{tld}
</p>
<div className="flex gap-3">
<div className="flex-1 relative">
<input
type="text"
value={domainSearch}
onChange={(e) => setDomainSearch(e.target.value)}
onKeyDown={(e) => e.key === 'Enter' && handleDomainCheck()}
placeholder={`example or example.${tld}`}
className="w-full h-11 px-4 bg-background border border-border/50 rounded-xl
text-sm text-foreground placeholder:text-foreground-subtle
focus:outline-none focus:border-accent/50 transition-all"
/>
</div>
<button
onClick={handleDomainCheck}
disabled={checkingDomain || !domainSearch.trim()}
className="h-11 px-6 bg-accent text-background font-medium rounded-xl
hover:bg-accent-hover transition-all disabled:opacity-50"
>
{checkingDomain ? (
<RefreshCw className="w-4 h-4 animate-spin" />
) : (
'Check'
)}
</button>
</div>
{/* Result */}
{domainResult && (
<div className={clsx(
"mt-4 p-4 rounded-xl border",
domainResult.is_available
? "bg-accent/10 border-accent/30"
: "bg-foreground/5 border-border/50"
)}>
<div className="flex items-center gap-3">
{domainResult.is_available ? (
<Check className="w-5 h-5 text-accent" />
) : (
<X className="w-5 h-5 text-foreground-subtle" />
)}
<div className="flex items-center gap-4">
<div className="h-12 w-1.5 bg-emerald-500 rounded-full shadow-[0_0_15px_rgba(16,185,129,0.5)]" />
<div>
<p className="font-medium text-foreground">{domainResult.domain}</p>
<p className="text-sm text-foreground-muted">
{domainResult.is_available ? 'Available for registration!' : 'Already registered'}
</p>
<h1 className="text-4xl font-bold tracking-tight text-white flex items-center gap-3">
.{details.tld}
{getRiskBadge()}
</h1>
<p className="text-zinc-400 text-sm mt-1 max-w-lg">
{details.description}
</p>
</div>
</div>
{domainResult.is_available && (
<a
href={getRegistrarUrl(details.cheapest_registrar, domainResult.domain)}
target="_blank"
rel="noopener noreferrer"
className="mt-3 inline-flex items-center gap-2 px-4 py-2 bg-accent text-background text-sm font-medium rounded-lg hover:bg-accent-hover transition-all"
</div>
<div className="flex gap-2">
<Link
href="/terminal/intel"
className="px-4 py-2 rounded-lg bg-zinc-900 border border-white/10 hover:bg-white/5 text-sm font-medium text-zinc-300 transition-colors flex items-center gap-2"
>
Register at {details.cheapest_registrar}
<ExternalLink className="w-3.5 h-3.5" />
</a>
)}
</div>
)}
</div>
{/* TLD Info */}
<div className="p-6 bg-background-secondary/30 border border-border/50 rounded-2xl">
<h2 className="text-lg font-medium text-foreground mb-4">TLD Information</h2>
<div className="grid sm:grid-cols-2 lg:grid-cols-4 gap-4">
<div className="p-4 bg-background/50 rounded-xl">
<div className="flex items-center gap-2 text-foreground-muted mb-2">
<Globe className="w-4 h-4" />
<span className="text-xs uppercase">Type</span>
</div>
<p className="font-medium text-foreground capitalize">{details.type}</p>
</div>
<div className="p-4 bg-background/50 rounded-xl">
<div className="flex items-center gap-2 text-foreground-muted mb-2">
<Building className="w-4 h-4" />
<span className="text-xs uppercase">Registry</span>
</div>
<p className="font-medium text-foreground">{details.registry}</p>
</div>
<div className="p-4 bg-background/50 rounded-xl">
<div className="flex items-center gap-2 text-foreground-muted mb-2">
<Calendar className="w-4 h-4" />
<span className="text-xs uppercase">Introduced</span>
</div>
<p className="font-medium text-foreground">{details.introduced || 'Unknown'}</p>
</div>
<div className="p-4 bg-background/50 rounded-xl">
<div className="flex items-center gap-2 text-foreground-muted mb-2">
<BarChart3 className="w-4 h-4" />
<span className="text-xs uppercase">Registrars</span>
</div>
<p className="font-medium text-foreground">{details.registrars.length} tracked</p>
<ArrowLeft className="w-4 h-4" /> Back
</Link>
</div>
</div>
{/* Metric Grid */}
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
<StatCard
label="Registration"
value={`$${details.pricing.min.toFixed(2)}`}
subValue={`at ${details.cheapest_registrar}`}
icon={DollarSign}
trend="neutral"
/>
<StatCard
label="Renewal"
value={details.min_renewal_price ? `$${details.min_renewal_price.toFixed(2)}` : '—'}
subValue={renewalInfo?.isTrap ? `${renewalInfo.ratio.toFixed(1)}x Markup` : '/ year'}
icon={RefreshCw}
trend={renewalInfo?.isTrap ? 'down' : 'neutral'}
/>
<StatCard
label="1y Trend"
value={`${details.price_change_1y > 0 ? '+' : ''}${details.price_change_1y.toFixed(0)}%`}
subValue="Volatility"
icon={details.price_change_1y > 0 ? TrendingUp : TrendingDown}
trend={details.price_change_1y > 10 ? 'down' : details.price_change_1y < -10 ? 'up' : 'neutral'}
/>
<StatCard
label="Tracked"
value={details.registrars.length}
subValue="Registrars"
icon={Building}
/>
</div>
{/* Quick Check Bar */}
<div className="bg-zinc-900/40 border border-white/5 rounded-xl p-6 backdrop-blur-sm relative overflow-hidden group hover:border-white/10 transition-colors">
<div className="absolute inset-0 bg-gradient-to-r from-emerald-500/5 to-transparent pointer-events-none opacity-50" />
<div className="relative z-10 flex flex-col md:flex-row gap-6 items-center">
<div className="flex-1">
<h2 className="text-lg font-bold text-white mb-1">Check Availability</h2>
<p className="text-sm text-zinc-400">Instantly check if your desired .{details.tld} domain is available across all registrars.</p>
</div>
<div className="flex-1 w-full max-w-xl flex gap-3">
<div className="relative flex-1 group/input">
<input
type="text"
value={domainSearch}
onChange={(e) => setDomainSearch(e.target.value)}
onKeyDown={(e) => e.key === 'Enter' && handleDomainCheck()}
placeholder={`example.${details.tld}`}
className="w-full h-12 bg-black/50 border border-white/10 rounded-lg pl-4 pr-4 text-white placeholder:text-zinc-600 focus:outline-none focus:border-emerald-500/50 focus:ring-1 focus:ring-emerald-500/50 transition-all font-mono"
/>
</div>
<button
onClick={handleDomainCheck}
disabled={checkingDomain || !domainSearch.trim()}
className="h-12 px-8 bg-emerald-500 text-white font-bold rounded-lg hover:bg-emerald-400 transition-all disabled:opacity-50 shadow-lg shadow-emerald-500/20"
>
{checkingDomain ? <Loader2 className="w-5 h-5 animate-spin" /> : 'Check'}
</button>
</div>
</div>
{/* Check Result */}
{domainResult && (
<div className="mt-6 pt-6 border-t border-white/5 animate-in fade-in slide-in-from-top-2">
<div className={clsx(
"p-4 rounded-lg border flex items-center justify-between",
domainResult.is_available
? "bg-emerald-500/10 border-emerald-500/20"
: "bg-rose-500/10 border-rose-500/20"
)}>
<div className="flex items-center gap-3">
{domainResult.is_available ? (
<div className="p-2 rounded-full bg-emerald-500/20 text-emerald-400"><Check className="w-5 h-5" /></div>
) : (
<div className="p-2 rounded-full bg-rose-500/20 text-rose-400"><X className="w-5 h-5" /></div>
)}
<div>
<div className="font-mono font-bold text-white text-lg">{domainResult.domain}</div>
<div className={clsx("text-xs font-medium uppercase tracking-wider", domainResult.is_available ? "text-emerald-400" : "text-rose-400")}>
{domainResult.is_available ? 'Available for registration' : 'Already Registered'}
</div>
</div>
</div>
{domainResult.is_available && (
<a
href={getRegistrarUrl(details.cheapest_registrar, domainResult.domain)}
target="_blank"
rel="noopener noreferrer"
className="px-4 py-2 bg-emerald-500 text-white text-sm font-bold rounded hover:bg-emerald-400 transition-colors flex items-center gap-2"
>
Buy at {details.cheapest_registrar} <ExternalLink className="w-4 h-4" />
</a>
)}
</div>
</div>
)}
</div>
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
{/* Left Column: Chart & Info */}
<div className="lg:col-span-2 space-y-8">
{/* Price History Chart */}
<div className="bg-zinc-900/40 border border-white/5 rounded-xl p-6 backdrop-blur-sm shadow-xl">
<div className="flex items-center justify-between mb-6">
<div>
<h3 className="text-lg font-bold text-white">Price History</h3>
<p className="text-xs text-zinc-500">Historical registration price trends</p>
</div>
<div className="flex bg-black/50 rounded-lg p-1 border border-white/5">
{(['1M', '3M', '1Y', 'ALL'] as ChartPeriod[]).map((period) => (
<button
key={period}
onClick={() => setChartPeriod(period)}
className={clsx(
"px-3 py-1 text-[10px] font-bold rounded transition-all",
chartPeriod === period
? "bg-zinc-800 text-white shadow-sm"
: "text-zinc-500 hover:text-zinc-300"
)}
>
{period}
</button>
))}
</div>
</div>
<div className="h-64">
<PriceChart data={filteredHistory} chartStats={chartStats} />
</div>
<div className="grid grid-cols-3 gap-4 mt-6 pt-6 border-t border-white/5">
<div className="text-center">
<div className="text-[10px] text-zinc-500 uppercase tracking-widest mb-1">High</div>
<div className="text-lg font-mono font-bold text-white">${chartStats.high.toFixed(2)}</div>
</div>
<div className="text-center border-l border-r border-white/5">
<div className="text-[10px] text-zinc-500 uppercase tracking-widest mb-1">Average</div>
<div className="text-lg font-mono font-bold text-white">${chartStats.avg.toFixed(2)}</div>
</div>
<div className="text-center">
<div className="text-[10px] text-zinc-500 uppercase tracking-widest mb-1">Low</div>
<div className="text-lg font-mono font-bold text-emerald-400">${chartStats.low.toFixed(2)}</div>
</div>
</div>
</div>
{/* TLD Info Cards */}
<div className="grid grid-cols-2 gap-4">
<div className="bg-zinc-900/40 border border-white/5 rounded-xl p-4 hover:border-white/10 transition-colors">
<div className="flex items-center gap-2 text-zinc-500 mb-2">
<Globe className="w-4 h-4" />
<span className="text-xs uppercase tracking-widest">Type</span>
</div>
<div className="text-lg font-medium text-white capitalize">{details.type}</div>
</div>
<div className="bg-zinc-900/40 border border-white/5 rounded-xl p-4 hover:border-white/10 transition-colors">
<div className="flex items-center gap-2 text-zinc-500 mb-2">
<Building className="w-4 h-4" />
<span className="text-xs uppercase tracking-widest">Registry</span>
</div>
<div className="text-lg font-medium text-white truncate" title={details.registry}>{details.registry}</div>
</div>
</div>
</div>
{/* Right Column: Registrars Table */}
<div className="bg-zinc-900/40 border border-white/5 rounded-xl overflow-hidden backdrop-blur-sm flex flex-col h-fit shadow-xl">
<div className="p-4 border-b border-white/5 bg-white/[0.02]">
<h3 className="text-lg font-bold text-white">Registrar Prices</h3>
<p className="text-xs text-zinc-500">Live comparison sorted by price</p>
</div>
<div className="overflow-x-auto">
<table className="w-full text-left">
<thead>
<tr className="border-b border-white/5 text-[10px] font-bold text-zinc-500 uppercase tracking-wider">
<th className="px-4 py-3">Registrar</th>
<th className="px-4 py-3 text-right">Reg</th>
<th className="px-4 py-3 text-right">Renew</th>
<th className="px-4 py-3 text-right"></th>
</tr>
</thead>
<tbody className="divide-y divide-white/5">
{details.registrars.map((registrar, idx) => {
const hasRenewalTrap = registrar.renewal_price / registrar.registration_price > 1.5
const isBest = idx === 0 && !hasRenewalTrap
return (
<tr key={registrar.name} className="group hover:bg-white/[0.02] transition-colors">
<td className="px-4 py-3">
<div className="font-medium text-white text-sm">{registrar.name}</div>
{isBest && <span className="text-[10px] text-emerald-400 font-bold uppercase">Best Value</span>}
{idx === 0 && hasRenewalTrap && <span className="text-[10px] text-amber-400 font-bold uppercase">Renewal Trap</span>}
</td>
<td className="px-4 py-3 text-right">
<div className={clsx("font-mono text-sm", isBest ? "text-emerald-400 font-bold" : "text-white")}>
${registrar.registration_price.toFixed(2)}
</div>
</td>
<td className="px-4 py-3 text-right">
<div className={clsx("font-mono text-sm", hasRenewalTrap ? "text-amber-400" : "text-zinc-500")}>
${registrar.renewal_price.toFixed(2)}
</div>
</td>
<td className="px-4 py-3 text-right">
<a
href={getRegistrarUrl(registrar.name)}
target="_blank"
rel="noopener noreferrer"
className="p-1.5 rounded bg-white/5 text-zinc-400 hover:text-white hover:bg-white/10 transition-colors inline-block"
>
<ExternalLink className="w-3.5 h-3.5" />
</a>
</td>
</tr>
)
})}
</tbody>
</table>
</div>
</div>
</div>
</div>
</PageContainer>
</div>
</TerminalLayout>
)
}

View File

@ -5,7 +5,6 @@ import { useSearchParams } from 'next/navigation'
import { useStore } from '@/lib/store'
import { api } from '@/lib/api'
import { TerminalLayout } from '@/components/TerminalLayout'
import { PageContainer, StatCard, Badge, ActionButton } from '@/components/PremiumTable'
import {
Plus,
Shield,
@ -23,10 +22,77 @@ import {
Tag,
Store,
Sparkles,
ArrowRight,
TrendingUp,
Globe,
MoreHorizontal
} from 'lucide-react'
import Link from 'next/link'
import clsx from 'clsx'
// ============================================================================
// SHARED COMPONENTS
// ============================================================================
function Tooltip({ children, content }: { children: React.ReactNode; content: string }) {
return (
<div className="relative flex items-center group/tooltip w-fit">
{children}
<div className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-zinc-900 border border-zinc-800 rounded text-[10px] text-zinc-300 whitespace-nowrap opacity-0 group-hover/tooltip:opacity-100 transition-opacity pointer-events-none z-50 shadow-xl">
{content}
<div className="absolute top-full left-1/2 -translate-x-1/2 -mt-px border-4 border-transparent border-t-zinc-800" />
</div>
</div>
)
}
function StatCard({
label,
value,
subValue,
icon: Icon,
trend
}: {
label: string
value: string | number
subValue?: string
icon: any
trend?: 'up' | 'down' | 'neutral' | 'active'
}) {
return (
<div className="bg-zinc-900/40 border border-white/5 p-4 relative overflow-hidden group hover:border-white/10 transition-colors">
<div className="absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity">
<Icon className="w-16 h-16" />
</div>
<div className="relative z-10">
<div className="flex items-center gap-2 text-zinc-400 mb-1">
<Icon className="w-4 h-4" />
<span className="text-xs font-medium uppercase tracking-wider">{label}</span>
</div>
<div className="flex items-baseline gap-2">
<span className="text-2xl font-bold text-white tracking-tight">{value}</span>
{subValue && <span className="text-xs text-zinc-500 font-medium">{subValue}</span>}
</div>
{trend && (
<div className={clsx(
"mt-2 text-[10px] font-medium px-1.5 py-0.5 w-fit rounded border",
trend === 'up' && "text-emerald-400 border-emerald-400/20 bg-emerald-400/5",
trend === 'down' && "text-rose-400 border-rose-400/20 bg-rose-400/5",
trend === 'active' && "text-blue-400 border-blue-400/20 bg-blue-400/5 animate-pulse",
trend === 'neutral' && "text-zinc-400 border-zinc-400/20 bg-zinc-400/5",
)}>
{trend === 'active' ? '● LIVE MONITORING' : trend === 'up' ? '▲ POSITIVE' : '▼ NEGATIVE'}
</div>
)}
</div>
</div>
)
}
// ============================================================================
// TYPES
// ============================================================================
interface Listing {
id: number
domain: string
@ -60,6 +126,10 @@ interface VerificationInfo {
status: string
}
// ============================================================================
// MAIN PAGE
// ============================================================================
export default function MyListingsPage() {
const { subscription } = useStore()
const searchParams = useSearchParams()
@ -68,7 +138,7 @@ export default function MyListingsPage() {
const [listings, setListings] = useState<Listing[]>([])
const [loading, setLoading] = useState(true)
// Modals - auto-open if domain is prefilled
// Modals
const [showCreateModal, setShowCreateModal] = useState(false)
const [showVerifyModal, setShowVerifyModal] = useState(false)
const [selectedListing, setSelectedListing] = useState<Listing | null>(null)
@ -78,7 +148,7 @@ export default function MyListingsPage() {
const [error, setError] = useState<string | null>(null)
const [success, setSuccess] = useState<string | null>(null)
// Create form
// Create form state
const [newListing, setNewListing] = useState({
domain: '',
title: '',
@ -104,7 +174,6 @@ export default function MyListingsPage() {
loadListings()
}, [loadListings])
// Auto-open create modal if domain is prefilled from portfolio
useEffect(() => {
if (prefillDomain) {
setNewListing(prev => ({ ...prev, domain: prefillDomain }))
@ -208,6 +277,7 @@ export default function MyListingsPage() {
const copyToClipboard = (text: string) => {
navigator.clipboard.writeText(text)
setSuccess('Copied to clipboard!')
setTimeout(() => setSuccess(null), 2000)
}
const formatPrice = (price: number | null, currency: string) => {
@ -219,390 +289,443 @@ export default function MyListingsPage() {
}).format(price)
}
const getStatusBadge = (status: string, isVerified: boolean) => {
if (status === 'active') return <Badge variant="success">Live</Badge>
if (status === 'draft' && !isVerified) return <Badge variant="warning">Needs Verification</Badge>
if (status === 'draft') return <Badge>Draft</Badge>
if (status === 'sold') return <Badge variant="accent">Sold</Badge>
return <Badge>{status}</Badge>
}
// Tier limits as per concept: Scout = 0 (blocked), Trader = 5, Tycoon = 50
// Tier limits
const tier = subscription?.tier || 'scout'
const limits = { scout: 0, trader: 5, tycoon: 50 }
const maxListings = limits[tier as keyof typeof limits] || 0
const canList = tier !== 'scout'
const activeCount = listings.filter(l => l.status === 'active').length
const totalViews = listings.reduce((sum, l) => sum + l.view_count, 0)
const totalInquiries = listings.reduce((sum, l) => sum + l.inquiry_count, 0)
return (
<TerminalLayout
title="My Listings"
subtitle={`Manage your domains for sale • ${listings.length}/${maxListings} slots used`}
actions={
<div className="flex items-center gap-3">
<Link
href="/buy"
className="flex items-center gap-2 px-4 py-2 text-foreground-muted text-sm font-medium
border border-border rounded-lg hover:bg-foreground/5 transition-all"
>
<Store className="w-4 h-4" />
Browse Marketplace
</Link>
<button
onClick={() => setShowCreateModal(true)}
disabled={listings.length >= maxListings}
className="flex items-center gap-2 px-4 py-2 bg-accent text-background text-sm font-medium rounded-lg
hover:bg-accent-hover transition-all disabled:opacity-50 disabled:cursor-not-allowed"
>
<Plus className="w-4 h-4" />
List Domain
</button>
<TerminalLayout hideHeaderSearch={true}>
<div className="relative font-sans text-zinc-100 selection:bg-emerald-500/30 pb-20">
{/* Ambient Background Glow */}
<div className="fixed inset-0 pointer-events-none overflow-hidden">
<div className="absolute top-0 right-1/4 w-[800px] h-[600px] bg-emerald-500/5 rounded-full blur-[120px] mix-blend-screen" />
<div className="absolute bottom-0 left-1/4 w-[600px] h-[500px] bg-blue-500/5 rounded-full blur-[100px] mix-blend-screen" />
</div>
}
>
<PageContainer>
{/* Scout Paywall */}
{!canList && (
<div className="p-6 bg-gradient-to-br from-accent/10 to-transparent border border-accent/20 rounded-2xl text-center">
<Shield className="w-12 h-12 text-accent mx-auto mb-4" />
<h2 className="text-xl font-semibold text-foreground mb-2">Upgrade to List Domains</h2>
<p className="text-foreground-muted mb-6 max-w-md mx-auto">
The Pounce marketplace is exclusive to Trader and Tycoon members.
List your domains, get verified, and sell directly to buyers with 0% commission.
</p>
<div className="flex items-center justify-center gap-4">
<div className="relative z-10 max-w-[1600px] mx-auto p-4 md:p-8 space-y-8">
{/* Header Section */}
<div className="flex flex-col md:flex-row justify-between items-start md:items-end gap-6 border-b border-white/5 pb-8">
<div className="space-y-2">
<div className="flex items-center gap-3">
<div className="h-8 w-1 bg-emerald-500 rounded-full shadow-[0_0_10px_rgba(16,185,129,0.5)]" />
<h1 className="text-3xl font-bold tracking-tight text-white">Portfolio</h1>
</div>
<p className="text-zinc-400 max-w-lg">
Manage your domain inventory, track performance, and process offers.
</p>
</div>
<div className="flex gap-2">
<Link
href="/pricing"
className="inline-flex items-center gap-2 px-6 py-3 bg-accent text-background font-semibold rounded-xl hover:bg-accent/90 transition-all"
href="/buy"
className="px-4 py-2 rounded-lg bg-white/5 border border-white/10 hover:bg-white/10 text-sm font-medium text-zinc-300 transition-colors flex items-center gap-2"
>
Upgrade to Trader $9/mo
<Store className="w-4 h-4" /> Marketplace
</Link>
<button
onClick={() => setShowCreateModal(true)}
disabled={listings.length >= maxListings}
className="px-4 py-2 bg-emerald-500 text-white font-medium rounded-lg hover:bg-emerald-400 transition-all shadow-lg shadow-emerald-500/20 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"
>
<Plus className="w-4 h-4" /> New Listing
</button>
</div>
</div>
)}
{/* Messages */}
{error && (
<div className="p-4 bg-red-500/10 border border-red-500/20 rounded-xl flex items-center gap-3">
<AlertCircle className="w-5 h-5 text-red-400" />
<p className="text-sm text-red-400 flex-1">{error}</p>
<button onClick={() => setError(null)}><X className="w-4 h-4 text-red-400" /></button>
</div>
)}
{success && (
<div className="p-4 bg-accent/10 border border-accent/20 rounded-xl flex items-center gap-3">
<CheckCircle className="w-5 h-5 text-accent" />
<p className="text-sm text-accent flex-1">{success}</p>
<button onClick={() => setSuccess(null)}><X className="w-4 h-4 text-accent" /></button>
</div>
)}
{/* Messages */}
{error && (
<div className="p-4 bg-rose-500/10 border border-rose-500/20 rounded-xl flex items-center gap-3 text-rose-400 animate-in fade-in slide-in-from-top-2">
<AlertCircle className="w-5 h-5" />
<p className="text-sm flex-1">{error}</p>
<button onClick={() => setError(null)}><X className="w-4 h-4" /></button>
</div>
)}
{success && (
<div className="p-4 bg-emerald-500/10 border border-emerald-500/20 rounded-xl flex items-center gap-3 text-emerald-400 animate-in fade-in slide-in-from-top-2">
<CheckCircle className="w-5 h-5" />
<p className="text-sm flex-1">{success}</p>
<button onClick={() => setSuccess(null)}><X className="w-4 h-4" /></button>
</div>
)}
{/* Stats - only show if can list */}
{canList && (
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
<StatCard title="My Listings" value={`${listings.length}/${maxListings}`} icon={Tag} />
<StatCard
title="Published"
value={listings.filter(l => l.status === 'active').length}
icon={CheckCircle}
accent
/>
<StatCard
title="Total Views"
value={listings.reduce((sum, l) => sum + l.view_count, 0)}
icon={Eye}
/>
<StatCard
title="Inquiries"
value={listings.reduce((sum, l) => sum + l.inquiry_count, 0)}
icon={MessageSquare}
/>
</div>
)}
{/* Paywall */}
{!canList && (
<div className="p-8 bg-gradient-to-br from-emerald-900/20 to-black border border-emerald-500/20 rounded-2xl text-center relative overflow-hidden">
<div className="absolute inset-0 bg-grid-white/[0.02] bg-[length:20px_20px]" />
<div className="relative z-10">
<Shield className="w-12 h-12 text-emerald-400 mx-auto mb-4" />
<h2 className="text-2xl font-bold text-white mb-2">Unlock Portfolio Management</h2>
<p className="text-zinc-400 mb-6 max-w-md mx-auto">
List your domains, verify ownership automatically, and sell directly to buyers with 0% commission on the Pounce Marketplace.
</p>
<Link
href="/pricing"
className="inline-flex items-center gap-2 px-6 py-3 bg-emerald-500 text-white font-bold rounded-xl hover:bg-emerald-400 transition-all shadow-lg shadow-emerald-500/20"
>
Upgrade to Trader <ArrowRight className="w-4 h-4" />
</Link>
</div>
</div>
)}
{/* Listings */}
{canList && (
loading ? (
<div className="flex items-center justify-center py-20">
<Loader2 className="w-6 h-6 text-accent animate-spin" />
</div>
) : listings.length === 0 ? (
<div className="text-center py-16 bg-background-secondary/30 border border-border rounded-2xl">
<Sparkles className="w-16 h-16 text-foreground-subtle mx-auto mb-6" />
<h2 className="text-xl font-medium text-foreground mb-2">No Listings Yet</h2>
<p className="text-foreground-muted mb-6 max-w-md mx-auto">
Create your first listing to sell a domain on the Pounce marketplace.
</p>
<button
onClick={() => setShowCreateModal(true)}
className="inline-flex items-center gap-2 px-6 py-3 bg-accent text-background font-medium rounded-xl hover:bg-accent-hover transition-all"
>
<Plus className="w-5 h-5" />
Create Listing
</button>
</div>
) : (
<div className="space-y-4">
{listings.map((listing) => (
<div
key={listing.id}
className="p-5 bg-background-secondary/30 border border-border rounded-2xl hover:border-border-hover transition-all"
>
<div className="flex flex-wrap items-start gap-4">
{/* Domain Info */}
<div className="flex-1 min-w-[200px]">
<div className="flex items-center gap-3 mb-2">
<h3 className="font-mono text-lg font-medium text-foreground">{listing.domain}</h3>
{getStatusBadge(listing.status, listing.is_verified)}
{listing.is_verified && (
<div className="w-6 h-6 bg-accent/10 rounded flex items-center justify-center" title="Verified">
<Shield className="w-3 h-3 text-accent" />
</div>
)}
</div>
{listing.title && (
<p className="text-sm text-foreground-muted">{listing.title}</p>
)}
</div>
{/* Price */}
<div className="text-right">
<p className="text-xl font-semibold text-foreground">
{formatPrice(listing.asking_price, listing.currency)}
</p>
{listing.pounce_score && (
<p className="text-xs text-foreground-muted">Score: {listing.pounce_score}</p>
)}
</div>
{/* Stats */}
<div className="flex items-center gap-4 text-sm text-foreground-muted">
<span className="flex items-center gap-1">
<Eye className="w-4 h-4" /> {listing.view_count}
</span>
<span className="flex items-center gap-1">
<MessageSquare className="w-4 h-4" /> {listing.inquiry_count}
</span>
</div>
{/* Actions */}
<div className="flex items-center gap-2">
{!listing.is_verified && (
<button
onClick={() => handleStartVerification(listing)}
disabled={verifying}
className="flex items-center gap-1.5 px-3 py-2 bg-amber-500/10 text-amber-400 text-sm font-medium rounded-lg hover:bg-amber-500/20 transition-all"
>
<Shield className="w-4 h-4" />
Verify
</button>
)}
{listing.is_verified && listing.status === 'draft' && (
<button
onClick={() => handlePublish(listing)}
className="flex items-center gap-1.5 px-3 py-2 bg-accent text-background text-sm font-medium rounded-lg hover:bg-accent-hover transition-all"
>
<CheckCircle className="w-4 h-4" />
Publish
</button>
)}
{listing.status === 'active' && (
<Link
href={`/buy/${listing.slug}`}
target="_blank"
className="flex items-center gap-1.5 px-3 py-2 bg-foreground/5 text-foreground-muted text-sm font-medium rounded-lg hover:bg-foreground/10 transition-all"
>
<ExternalLink className="w-4 h-4" />
View
</Link>
)}
<button
onClick={() => handleDelete(listing)}
className="p-2 text-foreground-subtle hover:text-red-400 transition-colors"
>
<Trash2 className="w-4 h-4" />
</button>
</div>
{/* Stats Grid */}
{canList && (
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
<StatCard
label="Inventory"
value={listings.length}
subValue={`/ ${maxListings} slots`}
icon={Tag}
trend="neutral"
/>
<StatCard
label="Active Listings"
value={activeCount}
subValue="Live on market"
icon={Store}
trend="active"
/>
<StatCard
label="Total Views"
value={totalViews}
subValue="All time"
icon={Eye}
trend={totalViews > 0 ? 'up' : 'neutral'}
/>
<StatCard
label="Inquiries"
value={totalInquiries}
subValue="Pending"
icon={MessageSquare}
trend={totalInquiries > 0 ? 'up' : 'neutral'}
/>
</div>
)}
{/* Listings Table */}
{canList && (
<div className="bg-zinc-900/40 border border-white/5 rounded-xl overflow-hidden backdrop-blur-sm">
{/* Table Header */}
<div className="grid grid-cols-12 gap-4 px-6 py-3 bg-white/[0.02] border-b border-white/5 text-[11px] font-semibold text-zinc-500 uppercase tracking-wider">
<div className="col-span-12 md:col-span-5">Domain</div>
<div className="hidden md:block md:col-span-2 text-center">Status</div>
<div className="hidden md:block md:col-span-2 text-right">Price</div>
<div className="hidden md:block md:col-span-1 text-center">Views</div>
<div className="hidden md:block md:col-span-2 text-right">Actions</div>
</div>
{loading ? (
<div className="flex items-center justify-center py-20">
<Loader2 className="w-8 h-8 text-emerald-500 animate-spin" />
</div>
</div>
))}
</div>
)
)}
</PageContainer>
{/* Create Modal */}
{showCreateModal && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-background/80 backdrop-blur-sm">
<div className="w-full max-w-lg bg-background-secondary border border-border rounded-2xl p-6">
<h2 className="text-xl font-semibold text-foreground mb-6">List Domain for Sale</h2>
<form onSubmit={handleCreate} className="space-y-4">
<div>
<label className="block text-sm text-foreground-muted mb-1">Domain *</label>
<input
type="text"
required
value={newListing.domain}
onChange={(e) => setNewListing({ ...newListing, domain: e.target.value })}
placeholder="example.com"
className="w-full px-4 py-3 bg-background border border-border rounded-xl text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-accent"
/>
</div>
<div>
<label className="block text-sm text-foreground-muted mb-1">Headline</label>
<input
type="text"
value={newListing.title}
onChange={(e) => setNewListing({ ...newListing, title: e.target.value })}
placeholder="Perfect for AI startups"
className="w-full px-4 py-3 bg-background border border-border rounded-xl text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-accent"
/>
</div>
<div>
<label className="block text-sm text-foreground-muted mb-1">Description</label>
<textarea
rows={3}
value={newListing.description}
onChange={(e) => setNewListing({ ...newListing, description: e.target.value })}
placeholder="Tell potential buyers about this domain..."
className="w-full px-4 py-3 bg-background border border-border rounded-xl text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-accent resize-none"
/>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<label className="block text-sm text-foreground-muted mb-1">Asking Price (USD)</label>
<div className="relative">
<DollarSign className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-foreground-subtle" />
<input
type="number"
value={newListing.asking_price}
onChange={(e) => setNewListing({ ...newListing, asking_price: e.target.value })}
placeholder="Leave empty for 'Make Offer'"
className="w-full pl-9 pr-4 py-3 bg-background border border-border rounded-xl text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-accent"
/>
) : listings.length === 0 ? (
<div className="flex flex-col items-center justify-center py-20 text-center">
<div className="w-16 h-16 rounded-full bg-white/5 flex items-center justify-center mb-4">
<Sparkles className="w-8 h-8 text-zinc-600" />
</div>
<h3 className="text-lg font-medium text-white mb-1">No listings yet</h3>
<p className="text-zinc-500 text-sm max-w-xs mx-auto mb-6">
Create your first listing to start selling.
</p>
<button
onClick={() => setShowCreateModal(true)}
className="text-emerald-400 text-sm hover:text-emerald-300 transition-colors flex items-center gap-2 font-medium"
>
Create Listing <ArrowRight className="w-4 h-4" />
</button>
</div>
) : (
<div className="divide-y divide-white/5">
{listings.map((listing) => (
<div key={listing.id} className="grid grid-cols-12 gap-4 px-6 py-4 items-center hover:bg-white/[0.04] transition-all group relative">
{/* Mobile View */}
<div className="md:hidden col-span-12">
<div className="flex justify-between items-start mb-2">
<div>
<div className="font-mono font-bold text-white text-lg">{listing.domain}</div>
<div className="text-xs text-zinc-500 mt-0.5">{listing.title || 'No headline'}</div>
</div>
<div className="text-right">
<div className="font-mono text-emerald-400 font-bold">{formatPrice(listing.asking_price, listing.currency)}</div>
</div>
</div>
<div className="flex justify-between items-center mt-3 pt-3 border-t border-white/5">
<span className={clsx(
"text-[10px] font-bold uppercase px-2 py-0.5 rounded border",
listing.status === 'active' ? "bg-emerald-500/10 text-emerald-400 border-emerald-500/20" :
listing.status === 'draft' ? "bg-zinc-800 text-zinc-400 border-zinc-700" :
"bg-blue-500/10 text-blue-400 border-blue-500/20"
)}>
{listing.status}
</span>
<div className="flex gap-2">
<button onClick={() => handleDelete(listing)} className="p-2 text-zinc-500 hover:text-rose-400"><Trash2 className="w-4 h-4" /></button>
{!listing.is_verified && <button onClick={() => handleStartVerification(listing)} className="p-2 text-amber-400 hover:bg-amber-500/10 rounded"><Shield className="w-4 h-4" /></button>}
</div>
</div>
</div>
{/* Desktop View */}
<div className="hidden md:block col-span-5">
<div className="flex items-center gap-3">
<div className={clsx(
"w-10 h-10 rounded-lg flex items-center justify-center text-lg font-bold",
listing.status === 'active' ? "bg-emerald-500/10 text-emerald-400" : "bg-zinc-800 text-zinc-500"
)}>
{listing.domain.charAt(0).toUpperCase()}
</div>
<div>
<div className="font-mono font-bold text-white tracking-tight">{listing.domain}</div>
<div className="text-xs text-zinc-500">{listing.title || 'No description provided'}</div>
</div>
</div>
</div>
<div className="hidden md:flex col-span-2 justify-center">
<span className={clsx(
"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider border",
listing.status === 'active' ? "bg-emerald-500/10 text-emerald-400 border-emerald-500/20" :
listing.status === 'draft' ? "bg-zinc-800/50 text-zinc-400 border-zinc-700" :
"bg-blue-500/10 text-blue-400 border-blue-500/20"
)}>
<span className={clsx("w-1.5 h-1.5 rounded-full", listing.status === 'active' ? "bg-emerald-400" : "bg-zinc-500")} />
{listing.status}
</span>
</div>
<div className="hidden md:block col-span-2 text-right">
<div className="font-mono font-medium text-white">{formatPrice(listing.asking_price, listing.currency)}</div>
{listing.pounce_score && <div className="text-[10px] text-zinc-500 mt-0.5">Score: {listing.pounce_score}</div>}
</div>
<div className="hidden md:block col-span-1 text-center">
<div className="text-sm text-zinc-400">{listing.view_count}</div>
</div>
<div className="hidden md:flex col-span-2 justify-end gap-2">
{!listing.is_verified ? (
<Tooltip content="Verify ownership to publish">
<button
onClick={() => handleStartVerification(listing)}
className="p-2 rounded-lg bg-amber-500/10 text-amber-400 border border-amber-500/20 hover:bg-amber-500/20 transition-all"
>
<Shield className="w-4 h-4" />
</button>
</Tooltip>
) : listing.status === 'draft' ? (
<Tooltip content="Publish to Marketplace">
<button
onClick={() => handlePublish(listing)}
className="p-2 rounded-lg bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 hover:bg-emerald-500/20 transition-all"
>
<CheckCircle className="w-4 h-4" />
</button>
</Tooltip>
) : (
<Tooltip content="View public listing">
<Link
href={`/buy/${listing.slug}`}
target="_blank"
className="p-2 rounded-lg bg-white/5 text-zinc-400 hover:text-white hover:bg-white/10 transition-all"
>
<ExternalLink className="w-4 h-4" />
</Link>
</Tooltip>
)}
<Tooltip content="Delete listing">
<button
onClick={() => handleDelete(listing)}
className="p-2 rounded-lg text-zinc-600 hover:text-rose-400 hover:bg-rose-500/10 transition-all"
>
<Trash2 className="w-4 h-4" />
</button>
</Tooltip>
</div>
</div>
))}
</div>
)}
</div>
)}
</div>
{/* Create Modal */}
{showCreateModal && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-md">
<div className="w-full max-w-lg bg-[#0A0A0A] border border-white/10 rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200">
<div className="p-6 border-b border-white/5">
<h2 className="text-xl font-bold text-white">Create Listing</h2>
<p className="text-sm text-zinc-500">List your domain for sale on the marketplace</p>
</div>
<form onSubmit={handleCreate} className="p-6 space-y-5">
<div>
<label className="block text-xs font-bold text-zinc-500 uppercase tracking-wider mb-2">Domain Name</label>
<input
type="text"
required
value={newListing.domain}
onChange={(e) => setNewListing({ ...newListing, domain: e.target.value })}
placeholder="example.com"
className="w-full px-4 py-3 bg-white/5 border border-white/10 rounded-xl text-white placeholder:text-zinc-600 focus:outline-none focus:border-emerald-500/50 focus:bg-white/10 transition-all font-mono"
/>
</div>
<div>
<label className="block text-sm text-foreground-muted mb-1">Price Type</label>
<select
value={newListing.price_type}
onChange={(e) => setNewListing({ ...newListing, price_type: e.target.value })}
className="w-full px-4 py-3 bg-background border border-border rounded-xl text-foreground focus:outline-none focus:border-accent"
>
<option value="negotiable">Negotiable</option>
<option value="fixed">Fixed Price</option>
<option value="make_offer">Make Offer Only</option>
</select>
<label className="block text-xs font-bold text-zinc-500 uppercase tracking-wider mb-2">Headline</label>
<input
type="text"
value={newListing.title}
onChange={(e) => setNewListing({ ...newListing, title: e.target.value })}
placeholder="Short, catchy title (e.g. Perfect for AI Startups)"
className="w-full px-4 py-3 bg-white/5 border border-white/10 rounded-xl text-white placeholder:text-zinc-600 focus:outline-none focus:border-emerald-500/50 transition-all"
/>
</div>
</div>
<label className="flex items-center gap-3 cursor-pointer">
<input
type="checkbox"
checked={newListing.allow_offers}
onChange={(e) => setNewListing({ ...newListing, allow_offers: e.target.checked })}
className="w-5 h-5 rounded border-border text-accent focus:ring-accent"
/>
<span className="text-sm text-foreground">Allow buyers to make offers</span>
</label>
<div className="flex gap-3 pt-4">
<button
type="button"
onClick={() => setShowCreateModal(false)}
className="flex-1 px-4 py-3 border border-border text-foreground-muted rounded-xl hover:bg-foreground/5 transition-all"
>
Cancel
</button>
<button
type="submit"
disabled={creating}
className="flex-1 flex items-center justify-center gap-2 px-4 py-3 bg-accent text-background font-medium rounded-xl hover:bg-accent-hover transition-all disabled:opacity-50"
>
{creating ? <Loader2 className="w-5 h-5 animate-spin" /> : <Plus className="w-5 h-5" />}
{creating ? 'Creating...' : 'Create'}
</button>
</div>
</form>
<div className="grid grid-cols-2 gap-4">
<div>
<label className="block text-xs font-bold text-zinc-500 uppercase tracking-wider mb-2">Price (USD)</label>
<div className="relative">
<DollarSign className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-500" />
<input
type="number"
value={newListing.asking_price}
onChange={(e) => setNewListing({ ...newListing, asking_price: e.target.value })}
placeholder="Make Offer"
className="w-full pl-9 pr-4 py-3 bg-white/5 border border-white/10 rounded-xl text-white placeholder:text-zinc-600 focus:outline-none focus:border-emerald-500/50 transition-all font-mono"
/>
</div>
</div>
<div>
<label className="block text-xs font-bold text-zinc-500 uppercase tracking-wider mb-2">Type</label>
<select
value={newListing.price_type}
onChange={(e) => setNewListing({ ...newListing, price_type: e.target.value })}
className="w-full px-4 py-3 bg-white/5 border border-white/10 rounded-xl text-white focus:outline-none focus:border-emerald-500/50 transition-all appearance-none"
>
<option value="negotiable">Negotiable</option>
<option value="fixed">Fixed Price</option>
<option value="make_offer">Make Offer</option>
</select>
</div>
</div>
<label className="flex items-center gap-3 cursor-pointer p-3 rounded-lg border border-white/5 hover:bg-white/5 transition-colors">
<input
type="checkbox"
checked={newListing.allow_offers}
onChange={(e) => setNewListing({ ...newListing, allow_offers: e.target.checked })}
className="w-5 h-5 rounded border-white/20 bg-black text-emerald-500 focus:ring-emerald-500 focus:ring-offset-0"
/>
<span className="text-sm text-zinc-300">Allow buyers to submit offers</span>
</label>
<div className="flex gap-3 pt-4">
<button
type="button"
onClick={() => setShowCreateModal(false)}
className="flex-1 px-4 py-3 border border-white/10 text-zinc-400 rounded-xl hover:bg-white/5 hover:text-white transition-all font-medium"
>
Cancel
</button>
<button
type="submit"
disabled={creating}
className="flex-1 flex items-center justify-center gap-2 px-4 py-3 bg-emerald-500 text-white font-bold rounded-xl hover:bg-emerald-400 transition-all disabled:opacity-50 shadow-lg shadow-emerald-500/20"
>
{creating ? <Loader2 className="w-5 h-5 animate-spin" /> : <Plus className="w-5 h-5" />}
{creating ? 'Creating...' : 'Create Listing'}
</button>
</div>
</form>
</div>
</div>
</div>
)}
)}
{/* Verification Modal */}
{showVerifyModal && verificationInfo && selectedListing && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-background/80 backdrop-blur-sm">
<div className="w-full max-w-xl bg-background-secondary border border-border rounded-2xl p-6">
<h2 className="text-xl font-semibold text-foreground mb-2">Verify Domain Ownership</h2>
<p className="text-sm text-foreground-muted mb-6">
Add a DNS TXT record to prove you own <strong>{selectedListing.domain}</strong>
</p>
<div className="space-y-4">
<div className="p-4 bg-background rounded-xl border border-border">
<p className="text-sm text-foreground-muted mb-2">Record Type</p>
<p className="font-mono text-foreground">{verificationInfo.dns_record_type}</p>
</div>
{/* Verify Modal */}
{showVerifyModal && verificationInfo && selectedListing && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-md">
<div className="w-full max-w-xl bg-[#0A0A0A] border border-white/10 rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200">
<div className="p-6 border-b border-white/5 bg-white/[0.02]">
<h2 className="text-xl font-bold text-white mb-2">Verify Ownership</h2>
<p className="text-sm text-zinc-400">
Add this DNS TXT record to <strong>{selectedListing.domain}</strong> to prove you own it.
</p>
</div>
<div className="p-4 bg-background rounded-xl border border-border">
<p className="text-sm text-foreground-muted mb-2">Name / Host</p>
<div className="flex items-center justify-between">
<p className="font-mono text-foreground">{verificationInfo.dns_record_name}</p>
<button
onClick={() => copyToClipboard(verificationInfo.dns_record_name)}
className="p-2 text-foreground-subtle hover:text-accent transition-colors"
>
<Copy className="w-4 h-4" />
</button>
<div className="p-6 space-y-6">
<div className="grid grid-cols-3 gap-4">
<div className="col-span-1">
<div className="text-[10px] font-bold text-zinc-500 uppercase tracking-wider mb-2">Type</div>
<div className="p-3 bg-white/5 border border-white/10 rounded-lg font-mono text-white text-center">
{verificationInfo.dns_record_type}
</div>
</div>
<div className="col-span-2">
<div className="text-[10px] font-bold text-zinc-500 uppercase tracking-wider mb-2">Name / Host</div>
<div className="p-3 bg-white/5 border border-white/10 rounded-lg font-mono text-white flex justify-between items-center group cursor-pointer" onClick={() => copyToClipboard(verificationInfo.dns_record_name)}>
<span className="truncate">{verificationInfo.dns_record_name}</span>
<Copy className="w-4 h-4 text-zinc-500 group-hover:text-emerald-400 transition-colors" />
</div>
</div>
</div>
<div>
<div className="text-[10px] font-bold text-zinc-500 uppercase tracking-wider mb-2">Value</div>
<div className="p-3 bg-white/5 border border-white/10 rounded-lg font-mono text-sm text-zinc-300 break-all flex justify-between items-start gap-4 group cursor-pointer" onClick={() => copyToClipboard(verificationInfo.dns_record_value)}>
{verificationInfo.dns_record_value}
<Copy className="w-4 h-4 text-zinc-500 group-hover:text-emerald-400 transition-colors shrink-0 mt-0.5" />
</div>
</div>
<div className="p-4 bg-emerald-500/5 border border-emerald-500/10 rounded-xl">
<p className="text-xs text-emerald-400/80 leading-relaxed">
<InfoIcon className="w-4 h-4 inline mr-1.5 -mt-0.5" />
After adding the record, it may take up to 24 hours to propagate, though typically it's instant. Click verify below to check.
</p>
</div>
</div>
<div className="p-4 bg-background rounded-xl border border-border">
<p className="text-sm text-foreground-muted mb-2">Value</p>
<div className="flex items-center justify-between">
<p className="font-mono text-sm text-foreground break-all">{verificationInfo.dns_record_value}</p>
<button
onClick={() => copyToClipboard(verificationInfo.dns_record_value)}
className="p-2 text-foreground-subtle hover:text-accent transition-colors shrink-0"
>
<Copy className="w-4 h-4" />
</button>
</div>
<div className="flex gap-3 p-6 pt-0">
<button
onClick={() => setShowVerifyModal(false)}
className="flex-1 px-4 py-3 border border-white/10 text-zinc-400 rounded-xl hover:bg-white/5 hover:text-white transition-all font-medium"
>
Close
</button>
<button
onClick={handleCheckVerification}
disabled={verifying}
className="flex-1 flex items-center justify-center gap-2 px-4 py-3 bg-emerald-500 text-white font-bold rounded-xl hover:bg-emerald-400 transition-all disabled:opacity-50 shadow-lg shadow-emerald-500/20"
>
{verifying ? <Loader2 className="w-5 h-5 animate-spin" /> : <Shield className="w-5 h-5" />}
{verifying ? 'Verifying...' : 'Verify Now'}
</button>
</div>
<div className="p-4 bg-accent/5 border border-accent/20 rounded-xl">
<p className="text-sm text-foreground-muted whitespace-pre-line">
{verificationInfo.instructions}
</p>
</div>
</div>
<div className="flex gap-3 mt-6">
<button
onClick={() => setShowVerifyModal(false)}
className="flex-1 px-4 py-3 border border-border text-foreground-muted rounded-xl hover:bg-foreground/5 transition-all"
>
Close
</button>
<button
onClick={handleCheckVerification}
disabled={verifying}
className="flex-1 flex items-center justify-center gap-2 px-4 py-3 bg-accent text-background font-medium rounded-xl hover:bg-accent-hover transition-all disabled:opacity-50"
>
{verifying ? <Loader2 className="w-5 h-5 animate-spin" /> : <RefreshCw className="w-5 h-5" />}
{verifying ? 'Checking...' : 'Check Verification'}
</button>
</div>
</div>
</div>
)}
)}
</div>
</TerminalLayout>
)
}
function InfoIcon(props: any) {
return (
<svg {...props} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>
)
}

File diff suppressed because it is too large Load Diff