import Link from 'next/link'; import { requireAdmin } from '@/lib/admin/auth'; import { dataQuality, matchCandidatesForRecord } from '@/lib/admin/queries'; import { manualMatchAction, saleStatusAction } from '@/lib/admin/actions'; import { AdminShell, ActionButton, Kpi, StatusPill, fmtTs, n } from '@/components/admin/shell'; import { Table, th, td, tdNum } from '@/components/ui/primitives'; export default async function DataQualityPage({ searchParams }: { searchParams: Promise<{ match?: string }> }) { await requireAdmin(); const sp = await searchParams; const dq = await dataQuality(); const q = (dq.quality ?? {}) as Record; const matching = sp.match ? await matchCandidatesForRecord(sp.match) : null; return (
{matching?.record ? (

Manual match

close

{String((matching.record.payload as { rawTitle?: string }).rawTitle ?? matching.record.id)}

    {matching.candidates.length === 0 ?
  • No similar asset titles. Reject or leave for the resolver.
  • : null} {matching.candidates.map((c) => (
  • {String(c.title)} {String(c.category_slug)} · {Math.round(Number(c.score) * 100)}%
  • ))}
) : null}

Flagged & excluded sales

{dq.flagged.length === 0 ? : null} {dq.flagged.map((s) => ( ))}
AssetStatusFlagsPriceDateSourceLast reasonActions
No flagged or excluded sales.
{String(s.title)}
{String(s.raw_title)}
{(s.flags as string[]).join(', ')} {n(s.price, 2)} {String(s.currency)}
${n(s.price_usd)}
{fmtTs(s.sale_date).slice(0, 10)} {String(s.source_id)} {String(s.last_reason ?? '')}
{(['valid', 'flagged', 'excluded'] as const).filter((x) => x !== s.status).map((x) => (
))}

Unmatched / rejected normalized records

{dq.unmatched.length === 0 ? : null} {dq.unmatched.map((r) => ( ))}
TitleConnectorKindCategoryPriceReasonCreated
Nothing waiting for a manual decision.
{String(r.raw_title ?? r.id)} {String(r.connector_id)} {String(r.kind)} {String(r.category_slug ?? '—')} {r.price ? `${n(r.price, 2)} ${String(r.currency ?? '')}` : '—'} {String(r.reject_reason ?? '')} {fmtTs(r.created_at)} match

Cross-listing groups

{dq.duplicates.length === 0 ? : null} {dq.duplicates.map((d) => )}
GroupListingsSourcesSample
No cross-listing groups detected yet.
{String(d.cross_listing_group_id)}{n(d.n)}{(d.sources as string[]).join(', ')}{String(d.sample_title)}
); }