import type { Metadata } from 'next'; import Link from 'next/link'; import { requireUser } from '@/lib/auth/session'; import { dealRadar } from '@/lib/account/queries'; import { getDisplay } from '@/lib/account/display'; import { PageHeader, btnSecondary } from '@/components/account/page-header'; import { Card, CardHeader, EmptyState, Table, th, td, tdNum, Badge } from '@/components/ui/primitives'; import { fmtPct, fmtRelative, confidenceLabel } from '@/lib/format'; export const metadata: Metadata = { title: 'Deal Radar', robots: { index: false } }; export default async function DealsPage({ searchParams }: { searchParams: Promise> }) { const sp = await searchParams; const u = await requireUser('/deals'); const d = await getDisplay(); const min = Math.min(0.9, Math.max(0.05, Number(sp.min ?? 15) / 100)); const rows = await dealRadar(u.id, { minDiscount: min, limit: 100 }); return ( <> {[10, 15, 25, 40].map((p) => ( ≥ {p}% below RIV ))} } /> {rows.length === 0 ? ( Manage watchlist} /> ) : ( {rows.map((r) => ( ))}
Listing Ask RIV Discount Confidence Grade Source Seen
{r.hero_image_url ? ( // eslint-disable-next-line @next/next/no-img-element ) : ( )}
{String(r.title)}

{String(r.category_slug).replace(/_/g, ' ')} {r.watched ? ( watched ) : null}

{d.money(Number(r.price_usd))} {d.money(Number(r.riv_usd))} {fmtPct(Number(r.discount_to_riv))} {confidenceLabel(Number(r.riv_confidence))} · {Number(r.riv_sample_size)} sales {r.grader ? `${String(r.grader).toUpperCase()} ${r.grade ?? ''}` : (r.condition as string | null) ?? '—'} {String(r.source_id)} ↗ {fmtRelative(new Date(String(r.last_seen_at)))}
)}
); }