'use client' import { useEffect, useState, useMemo } from 'react' import { useStore } from '@/lib/store' import { api } from '@/lib/api' import { Header } from '@/components/Header' import { Footer } from '@/components/Footer' import { PlatformBadge } from '@/components/PremiumTable' import { Clock, ExternalLink, Search, Flame, Timer, Gavel, DollarSign, X, Lock, TrendingUp, ChevronUp, ChevronDown, ChevronsUpDown, Sparkles, Diamond, ShieldCheck, Zap, Filter, Check, Shield, ArrowUpRight, ArrowRight } from 'lucide-react' import Link from 'next/link' import clsx from 'clsx' interface MarketItem { id: string domain: string tld: string price: number currency: string price_type: 'bid' | 'fixed' | 'negotiable' status: 'auction' | 'instant' source: string is_pounce: boolean verified: boolean time_remaining?: string end_time?: string num_bids?: number slug?: string seller_verified: boolean url: string is_external: boolean pounce_score: number } interface Auction { domain: string platform: string platform_url: string current_bid: number currency: string num_bids: number end_time: string time_remaining: string buy_now_price: number | null reserve_met: boolean | null traffic: number | null age_years: number | null tld: string affiliate_url: string } type TabType = 'all' | 'ending' | 'hot' type SortField = 'domain' | 'ending' | 'bid' | 'bids' type SortDirection = 'asc' | 'desc' const PLATFORMS = [ { id: 'All', name: 'All Sources' }, { id: 'GoDaddy', name: 'GoDaddy' }, { id: 'Sedo', name: 'Sedo' }, { id: 'NameJet', name: 'NameJet' }, { id: 'DropCatch', name: 'DropCatch' }, ] // Premium TLDs that look professional const PREMIUM_TLDS = ['com', 'io', 'ai', 'co', 'de', 'ch', 'net', 'org', 'app', 'dev', 'xyz'] // Vanity Filter: Only show "beautiful" domains to non-authenticated users function isVanityDomain(auction: Auction): boolean { const domain = auction.domain const parts = domain.split('.') if (parts.length < 2) return false const name = parts[0] const tld = parts.slice(1).join('.').toLowerCase() // Check TLD is premium if (!PREMIUM_TLDS.includes(tld)) return false // Check length (max 12 characters for the name) if (name.length > 12) return false // No hyphens if (name.includes('-')) return false // No numbers (unless domain is 4 chars or less - short domains are valuable) if (name.length > 4 && /\d/.test(name)) return false return true } // Generate a mock "Deal Score" for display purposes function getDealScore(auction: Auction): number | null { let score = 50 const name = auction.domain.split('.')[0] if (name.length <= 4) score += 20 else if (name.length <= 6) score += 10 if (['com', 'io', 'ai'].includes(auction.tld)) score += 15 if (auction.age_years && auction.age_years > 5) score += 10 if (auction.num_bids >= 20) score += 15 else if (auction.num_bids >= 10) score += 10 return Math.min(score, 100) } function SortIcon({ field, currentField, direction }: { field: SortField, currentField: SortField, direction: SortDirection }) { if (field !== currentField) { return } return direction === 'asc' ? : } export default function MarketPage() { const { isAuthenticated, checkAuth, isLoading: authLoading } = useStore() const [allAuctions, setAllAuctions] = useState([]) const [endingSoon, setEndingSoon] = useState([]) const [hotAuctions, setHotAuctions] = useState([]) const [pounceItems, setPounceItems] = useState([]) const [loading, setLoading] = useState(true) const [activeTab, setActiveTab] = useState('all') const [sortField, setSortField] = useState('ending') const [sortDirection, setSortDirection] = useState('asc') const [searchQuery, setSearchQuery] = useState('') const [selectedPlatform, setSelectedPlatform] = useState('All') const [maxBid, setMaxBid] = useState('') useEffect(() => { checkAuth() loadAuctions() }, [checkAuth]) const loadAuctions = async () => { setLoading(true) try { const [allFeed, endingFeed, hotFeed, pounceFeed] = await Promise.all([ api.getMarketFeed({ source: 'all', limit: 100, sortBy: 'time' }), api.getMarketFeed({ source: 'external', endingWithin: 24, limit: 50, sortBy: 'time' }), api.getMarketFeed({ source: 'external', limit: 50, sortBy: 'score' }), api.getMarketFeed({ source: 'pounce', limit: 10 }), ]) const convertToAuction = (item: MarketItem): Auction => ({ domain: item.domain, platform: item.source, platform_url: item.url, current_bid: item.price, currency: item.currency, num_bids: item.num_bids || 0, end_time: item.end_time || '', time_remaining: item.time_remaining || '', buy_now_price: item.price_type === 'fixed' ? item.price : null, reserve_met: null, traffic: null, age_years: null, tld: item.tld, affiliate_url: item.url, }) const externalOnly = (items: MarketItem[]) => items.filter(i => !i.is_pounce).map(convertToAuction) setAllAuctions(externalOnly(allFeed.items || [])) setEndingSoon(externalOnly(endingFeed.items || [])) setHotAuctions(externalOnly(hotFeed.items || [])) setPounceItems(pounceFeed.items || []) } catch (error) { console.error('Failed to load auctions:', error) } finally { setLoading(false) } } const getCurrentAuctions = (): Auction[] => { switch (activeTab) { case 'ending': return endingSoon case 'hot': return hotAuctions default: return allAuctions } } // Apply Vanity Filter for non-authenticated users const displayAuctions = useMemo(() => { const current = getCurrentAuctions() if (isAuthenticated) { return current } return current.filter(isVanityDomain) }, [activeTab, allAuctions, endingSoon, hotAuctions, isAuthenticated]) const filteredAuctions = displayAuctions.filter(auction => { if (searchQuery && !auction.domain.toLowerCase().includes(searchQuery.toLowerCase())) { return false } if (selectedPlatform !== 'All' && auction.platform !== selectedPlatform) { return false } if (maxBid && auction.current_bid > parseFloat(maxBid)) { return false } return true }) const handleSort = (field: SortField) => { if (sortField === field) { setSortDirection(sortDirection === 'asc' ? 'desc' : 'asc') } else { setSortField(field) setSortDirection('asc') } } const sortedAuctions = [...filteredAuctions].sort((a, b) => { const modifier = sortDirection === 'asc' ? 1 : -1 switch (sortField) { case 'domain': return a.domain.localeCompare(b.domain) * modifier case 'bid': return (a.current_bid - b.current_bid) * modifier case 'bids': return (a.num_bids - b.num_bids) * modifier default: return 0 } }) const formatCurrency = (amount: number, currency = 'USD') => { return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount) } const getTimeColor = (timeRemaining: string) => { if (timeRemaining.includes('m') && !timeRemaining.includes('h')) return 'text-red-400 font-bold' if (timeRemaining.includes('h') && parseInt(timeRemaining) < 12) return 'text-amber-400 font-bold' return 'text-white/40' } const hotPreview = hotAuctions.slice(0, 4) if (authLoading) { return (
) } return (
{/* Cinematic Background - Architectural & Fine */}
{/* Hero Header - High Tech */}
Live Liquidity Pool

Acquire Assets.

Global liquidity pool. Verified assets only. Aggregated from GoDaddy, Sedo, and Pounce Direct.

{formatCurrency(allAuctions.length, 'USD').replace('$', '')}
Live Opportunities
{pounceItems.length}
Direct Listings
{/* Login Banner for non-authenticated users */} {!isAuthenticated && (

Restricted Access

Sign in to unlock valuations, deal scores, and unfiltered data.

Authorize
)} {/* Pounce Direct Section - Featured */} {pounceItems.length > 0 && (
Direct Listings
// 0% COMMISSION // INSTANT SETTLEMENT
How to list my domains?
{pounceItems.map((item) => (
Available Now

{item.domain}

{item.verified && ( Verified )} {isAuthenticated ? `Score: ${item.pounce_score}/100` : 'Score: [LOCKED]'}
Buy Price {formatCurrency(item.price, item.currency)}
Acquire
))}
)} {/* Search & Filters - Tech Bar */}
{/* Search */}
setSearchQuery(e.target.value)} className="w-full pl-14 pr-5 py-3.5 bg-[#0A0A0A] border border-white/10 text-white placeholder:text-white/20 font-mono text-base focus:outline-none focus:border-accent focus:bg-[#0F0F0F] transition-all rounded-none" />
{/* Filters */}
{[ { id: 'all' as const, label: 'ALL', icon: Gavel }, { id: 'ending' as const, label: 'ENDING', icon: Timer }, { id: 'hot' as const, label: 'HOT', icon: Flame }, ].map((tab) => ( ))}
{/* Auctions Table - The Terminal */}
{loading ? ( Array.from({ length: 10 }).map((_, idx) => ( )) ) : sortedAuctions.length === 0 ? ( ) : ( sortedAuctions.map((auction) => ( {/* Valuation - blurred for non-authenticated */} )) )}
Source Valuation {!isAuthenticated && }
{searchQuery ? `// NO_ASSETS_FOUND: "${searchQuery}"` : '// NO_DATA_AVAILABLE'}
{auction.domain}
{auction.platform}
{auction.platform} {auction.platform === 'Pounce' && }
{formatCurrency(auction.current_bid)} {auction.buy_now_price && ( Buy Now )}
{isAuthenticated ? ( ${(auction.current_bid * 1.5).toFixed(0)} ) : (
$X,XXX
)}
{auction.time_remaining}
{/* Stats */} {!loading && (
System Status: Online {searchQuery ? `Assets Found: ${sortedAuctions.length}` : `Total Assets: ${allAuctions.length}` }
)} {/* Bottom CTA */} {!isAuthenticated && (

Eliminate Noise.

Our 'Trader' plan filters 99% of junk domains automatically. Stop digging through spam. Start acquiring assets.

Upgrade Intel
)}
) }