import type { Metadata } from 'next'; import Link from 'next/link'; import { requireUser } from '@/lib/auth/session'; import { listTargets } from '@/lib/account/queries'; import { getDisplay } from '@/lib/account/display'; import { deleteTargetAction } from '@/lib/account/actions'; import { PageHeader, btnDanger } from '@/components/account/page-header'; import { Card, CardHeader, EmptyState, Table, th, td, tdNum, Badge } from '@/components/ui/primitives'; import { Progress } from '@/components/account/charts'; import { fmtRelative } from '@/lib/format'; import { TargetForm } from './target-form'; export const metadata: Metadata = { title: 'Price targets', robots: { index: false } }; export default async function TargetsPage() { const u = await requireUser('/targets'); const d = await getDisplay(); const rows = await listTargets(u.id); return ( <>
{rows.length === 0 ? ( ) : ( {rows.map(({ target: t, asset, stats }) => { const now = stats?.rivUsd ?? null; const base = t.baselineUsd ?? now; let progress = 0; if (now !== null && base !== null && base !== t.targetUsd) progress = (now - base) / (t.targetUsd - base); const hit = t.hitAt !== null || (now !== null && (t.direction === 'above' ? now >= t.targetUsd : now <= t.targetUsd)); return ( ); })}
Asset Direction Baseline Now Target Progress Status
{asset.title}

set {fmtRelative(t.createdAt)} {t.note ? ` · ${t.note}` : ''}

{t.direction === 'above' ? 'sell above' : 'buy below'} {t.baselineUsd ? d.money(t.baselineUsd) : '—'} {now ? d.money(now) : —} {d.money(t.targetUsd)} {hit ? reached : now === null ? no RIV yet : {Math.round(Math.max(0, Math.min(1, progress)) * 100)}%}
)}
); }