feat: Marketplace navigation + SEO fix + tab-based listings
MARKETPLACE INTEGRATION: - Added 'Marketplace' (/buy) to public Header navigation - Renamed 'For Sale' to 'Marketplace' in Command Center Sidebar LISTINGS PAGE REDESIGN: - Added tab-based layout: 'Browse Marketplace' / 'My Listings' - Browse tab: Search + grid view of all public listings - My Listings tab: Full management with stats - Unified experience to view marketplace and manage own listings SEO JUICE DETECTOR FIX: - Fixed 500 error when database table doesn't exist - Added fallback: _format_dict_response for when DB is unavailable - Service now gracefully handles missing tables - Returns estimated data even on cache failures
This commit is contained in:
@ -81,22 +81,37 @@ class SEOAnalyzerService:
|
|||||||
"""
|
"""
|
||||||
domain = domain.lower().strip()
|
domain = domain.lower().strip()
|
||||||
|
|
||||||
# Check cache first
|
try:
|
||||||
if not force_refresh:
|
# Check cache first
|
||||||
cached = await self._get_cached(domain, db)
|
if not force_refresh:
|
||||||
if cached and not cached.is_expired:
|
try:
|
||||||
|
cached = await self._get_cached(domain, db)
|
||||||
|
if cached and not cached.is_expired:
|
||||||
|
return self._format_response(cached)
|
||||||
|
except Exception as e:
|
||||||
|
# Table might not exist yet
|
||||||
|
logger.warning(f"Cache check failed (table may not exist): {e}")
|
||||||
|
|
||||||
|
# Fetch fresh data
|
||||||
|
if self.has_moz:
|
||||||
|
seo_data = await self._fetch_moz_data(domain)
|
||||||
|
else:
|
||||||
|
seo_data = await self._estimate_seo_data(domain)
|
||||||
|
|
||||||
|
# Try to save to cache (may fail if table doesn't exist)
|
||||||
|
try:
|
||||||
|
cached = await self._save_to_cache(domain, seo_data, db)
|
||||||
return self._format_response(cached)
|
return self._format_response(cached)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Cache save failed (table may not exist): {e}")
|
||||||
|
# Return data directly without caching
|
||||||
|
return self._format_dict_response(domain, seo_data)
|
||||||
|
|
||||||
# Fetch fresh data
|
except Exception as e:
|
||||||
if self.has_moz:
|
logger.error(f"SEO analysis failed for {domain}: {e}")
|
||||||
seo_data = await self._fetch_moz_data(domain)
|
# Return estimated data on any error
|
||||||
else:
|
|
||||||
seo_data = await self._estimate_seo_data(domain)
|
seo_data = await self._estimate_seo_data(domain)
|
||||||
|
return self._format_dict_response(domain, seo_data)
|
||||||
# Save to cache
|
|
||||||
cached = await self._save_to_cache(domain, seo_data, db)
|
|
||||||
|
|
||||||
return self._format_response(cached)
|
|
||||||
|
|
||||||
async def _get_cached(self, domain: str, db: AsyncSession) -> Optional[DomainSEOData]:
|
async def _get_cached(self, domain: str, db: AsyncSession) -> Optional[DomainSEOData]:
|
||||||
"""Get cached SEO data for a domain."""
|
"""Get cached SEO data for a domain."""
|
||||||
@ -375,6 +390,56 @@ class SEOAnalyzerService:
|
|||||||
'is_estimated': data.data_source == 'estimated',
|
'is_estimated': data.data_source == 'estimated',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _format_dict_response(self, domain: str, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
"""Format SEO data from dict (when DB is not available)."""
|
||||||
|
da = data.get('domain_authority', 0) or 0
|
||||||
|
|
||||||
|
# Calculate SEO score
|
||||||
|
seo_score = da
|
||||||
|
if data.get('has_wikipedia_link'):
|
||||||
|
seo_score = min(100, seo_score + 10)
|
||||||
|
if data.get('has_gov_link'):
|
||||||
|
seo_score = min(100, seo_score + 5)
|
||||||
|
if data.get('has_edu_link'):
|
||||||
|
seo_score = min(100, seo_score + 5)
|
||||||
|
if data.get('has_news_link'):
|
||||||
|
seo_score = min(100, seo_score + 3)
|
||||||
|
|
||||||
|
# Determine value category
|
||||||
|
if seo_score >= 60:
|
||||||
|
value_category = "High Value"
|
||||||
|
elif seo_score >= 40:
|
||||||
|
value_category = "Medium Value"
|
||||||
|
elif seo_score >= 20:
|
||||||
|
value_category = "Low Value"
|
||||||
|
else:
|
||||||
|
value_category = "Minimal"
|
||||||
|
|
||||||
|
return {
|
||||||
|
'domain': domain,
|
||||||
|
'seo_score': seo_score,
|
||||||
|
'value_category': value_category,
|
||||||
|
'metrics': {
|
||||||
|
'domain_authority': data.get('domain_authority'),
|
||||||
|
'page_authority': data.get('page_authority'),
|
||||||
|
'spam_score': data.get('spam_score'),
|
||||||
|
'total_backlinks': data.get('total_backlinks'),
|
||||||
|
'referring_domains': data.get('referring_domains'),
|
||||||
|
},
|
||||||
|
'notable_links': {
|
||||||
|
'has_wikipedia': data.get('has_wikipedia_link', False),
|
||||||
|
'has_gov': data.get('has_gov_link', False),
|
||||||
|
'has_edu': data.get('has_edu_link', False),
|
||||||
|
'has_news': data.get('has_news_link', False),
|
||||||
|
'notable_domains': data.get('notable_backlinks', '').split(',') if data.get('notable_backlinks') else [],
|
||||||
|
},
|
||||||
|
'top_backlinks': data.get('top_backlinks', []),
|
||||||
|
'estimated_value': data.get('seo_value_estimate'),
|
||||||
|
'data_source': data.get('data_source', 'estimated'),
|
||||||
|
'last_updated': datetime.utcnow().isoformat(),
|
||||||
|
'is_estimated': data.get('data_source') == 'estimated',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Singleton instance
|
# Singleton instance
|
||||||
seo_analyzer = SEOAnalyzerService()
|
seo_analyzer = SEOAnalyzerService()
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { useEffect, useState } from 'react'
|
|||||||
import { useStore } from '@/lib/store'
|
import { useStore } from '@/lib/store'
|
||||||
import { api } from '@/lib/api'
|
import { api } from '@/lib/api'
|
||||||
import { CommandCenterLayout } from '@/components/CommandCenterLayout'
|
import { CommandCenterLayout } from '@/components/CommandCenterLayout'
|
||||||
import { PageContainer, StatCard, PremiumTable, Badge } from '@/components/PremiumTable'
|
import { PageContainer, StatCard, Badge } from '@/components/PremiumTable'
|
||||||
import {
|
import {
|
||||||
Plus,
|
Plus,
|
||||||
Shield,
|
Shield,
|
||||||
@ -13,9 +13,7 @@ import {
|
|||||||
ExternalLink,
|
ExternalLink,
|
||||||
Loader2,
|
Loader2,
|
||||||
Trash2,
|
Trash2,
|
||||||
Edit2,
|
|
||||||
CheckCircle,
|
CheckCircle,
|
||||||
Clock,
|
|
||||||
AlertCircle,
|
AlertCircle,
|
||||||
Copy,
|
Copy,
|
||||||
RefreshCw,
|
RefreshCw,
|
||||||
@ -23,6 +21,10 @@ import {
|
|||||||
Globe,
|
Globe,
|
||||||
X,
|
X,
|
||||||
Sparkles,
|
Sparkles,
|
||||||
|
Store,
|
||||||
|
List,
|
||||||
|
Search,
|
||||||
|
Tag,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
@ -51,6 +53,22 @@ interface Listing {
|
|||||||
published_at: string | null
|
published_at: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface PublicListing {
|
||||||
|
domain: string
|
||||||
|
slug: string
|
||||||
|
title: string | null
|
||||||
|
description: string | null
|
||||||
|
asking_price: number | null
|
||||||
|
currency: string
|
||||||
|
price_type: string
|
||||||
|
pounce_score: number | null
|
||||||
|
estimated_value: number | null
|
||||||
|
is_verified: boolean
|
||||||
|
allow_offers: boolean
|
||||||
|
public_url: string
|
||||||
|
seller_verified: boolean
|
||||||
|
}
|
||||||
|
|
||||||
interface VerificationInfo {
|
interface VerificationInfo {
|
||||||
verification_code: string
|
verification_code: string
|
||||||
dns_record_type: string
|
dns_record_type: string
|
||||||
@ -60,11 +78,24 @@ interface VerificationInfo {
|
|||||||
status: string
|
status: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TabType = 'browse' | 'my-listings'
|
||||||
|
|
||||||
export default function ListingsPage() {
|
export default function ListingsPage() {
|
||||||
const { subscription } = useStore()
|
const { subscription } = useStore()
|
||||||
|
|
||||||
const [listings, setListings] = useState<Listing[]>([])
|
// Tab state
|
||||||
const [loading, setLoading] = useState(true)
|
const [activeTab, setActiveTab] = useState<TabType>('browse')
|
||||||
|
|
||||||
|
// My Listings state
|
||||||
|
const [myListings, setMyListings] = useState<Listing[]>([])
|
||||||
|
const [loadingMy, setLoadingMy] = useState(true)
|
||||||
|
|
||||||
|
// Browse state
|
||||||
|
const [publicListings, setPublicListings] = useState<PublicListing[]>([])
|
||||||
|
const [loadingPublic, setLoadingPublic] = useState(true)
|
||||||
|
const [searchQuery, setSearchQuery] = useState('')
|
||||||
|
|
||||||
|
// Modals
|
||||||
const [showCreateModal, setShowCreateModal] = useState(false)
|
const [showCreateModal, setShowCreateModal] = useState(false)
|
||||||
const [showVerifyModal, setShowVerifyModal] = useState(false)
|
const [showVerifyModal, setShowVerifyModal] = useState(false)
|
||||||
const [selectedListing, setSelectedListing] = useState<Listing | null>(null)
|
const [selectedListing, setSelectedListing] = useState<Listing | null>(null)
|
||||||
@ -85,18 +116,31 @@ export default function ListingsPage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadListings()
|
loadMyListings()
|
||||||
|
loadPublicListings()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const loadListings = async () => {
|
const loadMyListings = async () => {
|
||||||
setLoading(true)
|
setLoadingMy(true)
|
||||||
try {
|
try {
|
||||||
const data = await api.request<Listing[]>('/listings/my')
|
const data = await api.request<Listing[]>('/listings/my')
|
||||||
setListings(data)
|
setMyListings(data)
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
setError(err.message)
|
console.error('Failed to load my listings:', err)
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoadingMy(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadPublicListings = async () => {
|
||||||
|
setLoadingPublic(true)
|
||||||
|
try {
|
||||||
|
const data = await api.request<PublicListing[]>('/listings?limit=50')
|
||||||
|
setPublicListings(data)
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('Failed to load public listings:', err)
|
||||||
|
} finally {
|
||||||
|
setLoadingPublic(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +164,8 @@ export default function ListingsPage() {
|
|||||||
setSuccess('Listing created! Now verify ownership to publish.')
|
setSuccess('Listing created! Now verify ownership to publish.')
|
||||||
setShowCreateModal(false)
|
setShowCreateModal(false)
|
||||||
setNewListing({ domain: '', title: '', description: '', asking_price: '', price_type: 'negotiable', allow_offers: true })
|
setNewListing({ domain: '', title: '', description: '', asking_price: '', price_type: 'negotiable', allow_offers: true })
|
||||||
loadListings()
|
loadMyListings()
|
||||||
|
setActiveTab('my-listings')
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
setError(err.message)
|
setError(err.message)
|
||||||
} finally {
|
} finally {
|
||||||
@ -157,7 +202,7 @@ export default function ListingsPage() {
|
|||||||
if (result.verified) {
|
if (result.verified) {
|
||||||
setSuccess('Domain verified! You can now publish your listing.')
|
setSuccess('Domain verified! You can now publish your listing.')
|
||||||
setShowVerifyModal(false)
|
setShowVerifyModal(false)
|
||||||
loadListings()
|
loadMyListings()
|
||||||
} else {
|
} else {
|
||||||
setError(result.message)
|
setError(result.message)
|
||||||
}
|
}
|
||||||
@ -175,7 +220,8 @@ export default function ListingsPage() {
|
|||||||
body: JSON.stringify({ status: 'active' }),
|
body: JSON.stringify({ status: 'active' }),
|
||||||
})
|
})
|
||||||
setSuccess('Listing published!')
|
setSuccess('Listing published!')
|
||||||
loadListings()
|
loadMyListings()
|
||||||
|
loadPublicListings()
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
setError(err.message)
|
setError(err.message)
|
||||||
}
|
}
|
||||||
@ -187,7 +233,7 @@ export default function ListingsPage() {
|
|||||||
try {
|
try {
|
||||||
await api.request(`/listings/${listing.id}`, { method: 'DELETE' })
|
await api.request(`/listings/${listing.id}`, { method: 'DELETE' })
|
||||||
setSuccess('Listing deleted')
|
setSuccess('Listing deleted')
|
||||||
loadListings()
|
loadMyListings()
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
setError(err.message)
|
setError(err.message)
|
||||||
}
|
}
|
||||||
@ -215,23 +261,33 @@ export default function ListingsPage() {
|
|||||||
return <Badge>{status}</Badge>
|
return <Badge>{status}</Badge>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filteredPublicListings = publicListings.filter(listing => {
|
||||||
|
if (!searchQuery) return true
|
||||||
|
return listing.domain.toLowerCase().includes(searchQuery.toLowerCase())
|
||||||
|
})
|
||||||
|
|
||||||
const tier = subscription?.tier || 'scout'
|
const tier = subscription?.tier || 'scout'
|
||||||
const limits = { scout: 2, trader: 10, tycoon: 50 }
|
const limits = { scout: 2, trader: 10, tycoon: 50 }
|
||||||
const maxListings = limits[tier as keyof typeof limits] || 2
|
const maxListings = limits[tier as keyof typeof limits] || 2
|
||||||
|
|
||||||
|
const tabs = [
|
||||||
|
{ id: 'browse' as TabType, label: 'Browse Marketplace', icon: Store, count: publicListings.length },
|
||||||
|
{ id: 'my-listings' as TabType, label: 'My Listings', icon: List, count: myListings.length },
|
||||||
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CommandCenterLayout
|
<CommandCenterLayout
|
||||||
title="My Listings"
|
title="Marketplace"
|
||||||
subtitle={`Manage your domain marketplace listings (${listings.length}/${maxListings})`}
|
subtitle="Buy and sell premium domains"
|
||||||
actions={
|
actions={
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowCreateModal(true)}
|
onClick={() => setShowCreateModal(true)}
|
||||||
disabled={listings.length >= maxListings}
|
disabled={myListings.length >= maxListings}
|
||||||
className="flex items-center gap-2 px-4 py-2 bg-accent text-background text-sm font-medium rounded-lg
|
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"
|
hover:bg-accent-hover transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||||
>
|
>
|
||||||
<Plus className="w-4 h-4" />
|
<Plus className="w-4 h-4" />
|
||||||
New Listing
|
List Domain
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@ -253,135 +309,252 @@ export default function ListingsPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Stats */}
|
{/* Tabs */}
|
||||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
|
<div className="flex gap-2 p-1 bg-background-secondary/50 rounded-xl border border-border">
|
||||||
<StatCard title="Total Listings" value={listings.length} icon={Globe} />
|
{tabs.map((tab) => (
|
||||||
<StatCard
|
<button
|
||||||
title="Published"
|
key={tab.id}
|
||||||
value={listings.filter(l => l.status === 'active').length}
|
onClick={() => setActiveTab(tab.id)}
|
||||||
icon={CheckCircle}
|
className={clsx(
|
||||||
accent
|
"flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-lg font-medium transition-all",
|
||||||
/>
|
activeTab === tab.id
|
||||||
<StatCard
|
? "bg-foreground text-background"
|
||||||
title="Total Views"
|
: "text-foreground-muted hover:text-foreground hover:bg-foreground/5"
|
||||||
value={listings.reduce((sum, l) => sum + l.view_count, 0)}
|
)}
|
||||||
icon={Eye}
|
>
|
||||||
/>
|
<tab.icon className="w-4 h-4" />
|
||||||
<StatCard
|
{tab.label}
|
||||||
title="Inquiries"
|
<span className={clsx(
|
||||||
value={listings.reduce((sum, l) => sum + l.inquiry_count, 0)}
|
"px-2 py-0.5 text-xs rounded-full",
|
||||||
icon={MessageSquare}
|
activeTab === tab.id ? "bg-background/20 text-background" : "bg-foreground/10"
|
||||||
/>
|
)}>
|
||||||
|
{tab.count}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Listings Table */}
|
{/* Browse Tab */}
|
||||||
{loading ? (
|
{activeTab === 'browse' && (
|
||||||
<div className="flex items-center justify-center py-20">
|
<div className="space-y-6">
|
||||||
<Loader2 className="w-6 h-6 text-accent animate-spin" />
|
{/* Search */}
|
||||||
</div>
|
<div className="relative">
|
||||||
) : listings.length === 0 ? (
|
<Search className="absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-foreground-subtle" />
|
||||||
<div className="text-center py-16 bg-background-secondary/30 border border-border rounded-2xl">
|
<input
|
||||||
<Sparkles className="w-16 h-16 text-foreground-subtle mx-auto mb-6" />
|
type="text"
|
||||||
<h2 className="text-xl font-medium text-foreground mb-2">No Listings Yet</h2>
|
placeholder="Search domains for sale..."
|
||||||
<p className="text-foreground-muted mb-6 max-w-md mx-auto">
|
value={searchQuery}
|
||||||
Create your first listing to sell a domain on the Pounce marketplace.
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
</p>
|
className="w-full pl-12 pr-4 py-3 bg-background-secondary/50 border border-border rounded-xl
|
||||||
<button
|
text-foreground placeholder:text-foreground-subtle
|
||||||
onClick={() => setShowCreateModal(true)}
|
focus:outline-none focus:ring-2 focus:ring-accent/30 focus:border-accent"
|
||||||
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"
|
/>
|
||||||
>
|
</div>
|
||||||
<Plus className="w-5 h-5" />
|
|
||||||
Create Listing
|
{/* Listings Grid */}
|
||||||
</button>
|
{loadingPublic ? (
|
||||||
</div>
|
<div className="flex items-center justify-center py-20">
|
||||||
) : (
|
<Loader2 className="w-6 h-6 text-accent animate-spin" />
|
||||||
<div className="space-y-4">
|
</div>
|
||||||
{listings.map((listing) => (
|
) : filteredPublicListings.length === 0 ? (
|
||||||
<div
|
<div className="text-center py-16 bg-background-secondary/30 border border-border rounded-2xl">
|
||||||
key={listing.id}
|
<Store className="w-16 h-16 text-foreground-subtle mx-auto mb-6" />
|
||||||
className="p-5 bg-background-secondary/30 border border-border rounded-2xl hover:border-border-hover transition-all"
|
<h2 className="text-xl font-medium text-foreground mb-2">No Domains Listed</h2>
|
||||||
>
|
<p className="text-foreground-muted mb-6">
|
||||||
<div className="flex flex-wrap items-start gap-4">
|
{searchQuery ? `No domains match "${searchQuery}"` : 'Be the first to list your domain!'}
|
||||||
{/* Domain Info */}
|
</p>
|
||||||
<div className="flex-1 min-w-[200px]">
|
<button
|
||||||
<div className="flex items-center gap-3 mb-2">
|
onClick={() => {
|
||||||
<h3 className="font-mono text-lg font-medium text-foreground">{listing.domain}</h3>
|
setActiveTab('my-listings')
|
||||||
{getStatusBadge(listing.status, listing.is_verified)}
|
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" />
|
||||||
|
List Your Domain
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="grid sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
{filteredPublicListings.map((listing) => (
|
||||||
|
<Link
|
||||||
|
key={listing.slug}
|
||||||
|
href={`/buy/${listing.slug}`}
|
||||||
|
className="group p-5 bg-background-secondary/30 border border-border rounded-2xl
|
||||||
|
hover:border-accent/50 hover:bg-background-secondary/50 transition-all duration-300"
|
||||||
|
>
|
||||||
|
<div className="flex items-start justify-between mb-3">
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
<h3 className="font-mono text-lg font-medium text-foreground group-hover:text-accent transition-colors truncate">
|
||||||
|
{listing.domain}
|
||||||
|
</h3>
|
||||||
|
{listing.title && (
|
||||||
|
<p className="text-sm text-foreground-muted truncate mt-1">{listing.title}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
{listing.is_verified && (
|
{listing.is_verified && (
|
||||||
<div className="w-6 h-6 bg-accent/10 rounded flex items-center justify-center" title="Verified">
|
<div className="shrink-0 ml-2 w-8 h-8 bg-accent/10 rounded-lg flex items-center justify-center">
|
||||||
<Shield className="w-3 h-3 text-accent" />
|
<Shield className="w-4 h-4 text-accent" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{listing.title && (
|
|
||||||
<p className="text-sm text-foreground-muted">{listing.title}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Price */}
|
<div className="flex items-end justify-between">
|
||||||
<div className="text-right">
|
{listing.pounce_score && (
|
||||||
<p className="text-xl font-display text-foreground">
|
<div className="px-2 py-1 bg-accent/10 text-accent rounded text-sm font-medium">
|
||||||
{formatPrice(listing.asking_price, listing.currency)}
|
Score: {listing.pounce_score}
|
||||||
</p>
|
</div>
|
||||||
{listing.pounce_score && (
|
)}
|
||||||
<p className="text-xs text-foreground-muted">Score: {listing.pounce_score}</p>
|
<div className="text-right">
|
||||||
)}
|
<p className="text-xl font-display text-foreground">
|
||||||
</div>
|
{formatPrice(listing.asking_price, listing.currency)}
|
||||||
|
</p>
|
||||||
{/* Stats */}
|
{listing.price_type === 'negotiable' && (
|
||||||
<div className="flex items-center gap-4 text-sm text-foreground-muted">
|
<p className="text-xs text-accent">Negotiable</p>
|
||||||
<span className="flex items-center gap-1">
|
)}
|
||||||
<Eye className="w-4 h-4" /> {listing.view_count}
|
</div>
|
||||||
</span>
|
</div>
|
||||||
<span className="flex items-center gap-1">
|
</Link>
|
||||||
<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>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* My Listings Tab */}
|
||||||
|
{activeTab === 'my-listings' && (
|
||||||
|
<div className="space-y-6">
|
||||||
|
{/* Stats */}
|
||||||
|
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
|
||||||
|
<StatCard title="My Listings" value={`${myListings.length}/${maxListings}`} icon={Tag} />
|
||||||
|
<StatCard
|
||||||
|
title="Published"
|
||||||
|
value={myListings.filter(l => l.status === 'active').length}
|
||||||
|
icon={CheckCircle}
|
||||||
|
accent
|
||||||
|
/>
|
||||||
|
<StatCard
|
||||||
|
title="Total Views"
|
||||||
|
value={myListings.reduce((sum, l) => sum + l.view_count, 0)}
|
||||||
|
icon={Eye}
|
||||||
|
/>
|
||||||
|
<StatCard
|
||||||
|
title="Inquiries"
|
||||||
|
value={myListings.reduce((sum, l) => sum + l.inquiry_count, 0)}
|
||||||
|
icon={MessageSquare}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* My Listings */}
|
||||||
|
{loadingMy ? (
|
||||||
|
<div className="flex items-center justify-center py-20">
|
||||||
|
<Loader2 className="w-6 h-6 text-accent animate-spin" />
|
||||||
|
</div>
|
||||||
|
) : myListings.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">
|
||||||
|
{myListings.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-display 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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
@ -390,7 +563,7 @@ export default function ListingsPage() {
|
|||||||
{showCreateModal && (
|
{showCreateModal && (
|
||||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-background/80 backdrop-blur-sm">
|
<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">
|
<div className="w-full max-w-lg bg-background-secondary border border-border rounded-2xl p-6">
|
||||||
<h2 className="text-xl font-display text-foreground mb-6">Create Listing</h2>
|
<h2 className="text-xl font-display text-foreground mb-6">List Domain for Sale</h2>
|
||||||
|
|
||||||
<form onSubmit={handleCreate} className="space-y-4">
|
<form onSubmit={handleCreate} className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
@ -558,4 +731,3 @@ export default function ListingsPage() {
|
|||||||
</CommandCenterLayout>
|
</CommandCenterLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import {
|
|||||||
Gavel,
|
Gavel,
|
||||||
CreditCard,
|
CreditCard,
|
||||||
LayoutDashboard,
|
LayoutDashboard,
|
||||||
|
Tag,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
@ -39,6 +40,7 @@ export function Header() {
|
|||||||
// Public navigation - same for all visitors
|
// Public navigation - same for all visitors
|
||||||
const publicNavItems = [
|
const publicNavItems = [
|
||||||
{ href: '/auctions', label: 'Auctions', icon: Gavel },
|
{ href: '/auctions', label: 'Auctions', icon: Gavel },
|
||||||
|
{ href: '/buy', label: 'Marketplace', icon: Tag },
|
||||||
{ href: '/tld-pricing', label: 'TLD Intel', icon: TrendingUp },
|
{ href: '/tld-pricing', label: 'TLD Intel', icon: TrendingUp },
|
||||||
{ href: '/pricing', label: 'Pricing', icon: CreditCard },
|
{ href: '/pricing', label: 'Pricing', icon: CreditCard },
|
||||||
]
|
]
|
||||||
|
|||||||
2
frontend/src/components/Sidebar.tsx
Normal file → Executable file
2
frontend/src/components/Sidebar.tsx
Normal file → Executable file
@ -106,7 +106,7 @@ export function Sidebar({ collapsed: controlledCollapsed, onCollapsedChange }: S
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: '/command/listings',
|
href: '/command/listings',
|
||||||
label: 'For Sale',
|
label: 'Marketplace',
|
||||||
icon: Tag,
|
icon: Tag,
|
||||||
badge: null,
|
badge: null,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user