import type { FinanceEvent } from "@paperclipai/shared"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { financeDirectionDisplayName, financeEventKindDisplayName, formatCents, formatDateTime, providerDisplayName, } from "@/lib/utils"; interface FinanceTimelineCardProps { rows: FinanceEvent[]; emptyMessage?: string; } export function FinanceTimelineCard({ rows, emptyMessage = "No financial events recorded in this period. Events appear when reported through the API, CLI, or a supported integration.", }: FinanceTimelineCardProps) { return ( Recent financial events Provider charges, subscriptions, fees, and credits. Reported separately from run-cost estimates. {rows.length === 0 ? (

{emptyMessage}

) : ( rows.map((row) => (
{row.metadataJson?.source === "provider_cost_report" ? "Provider cost report" : financeEventKindDisplayName(row.eventKind)} {financeDirectionDisplayName(row.direction)} {formatDateTime(row.occurredAt)}
{providerDisplayName(row.biller)} {row.provider ? ` -> ${providerDisplayName(row.provider)}` : ""} {row.model ? {row.model} : null}
{(row.description || row.externalInvoiceId || row.region || row.pricingTier) && (
{row.description ?
{row.description}
: null} {row.externalInvoiceId ?
invoice {row.externalInvoiceId}
: null} {row.region ?
region {row.region}
: null} {row.pricingTier ?
tier {row.pricingTier}
: null}
)}
{formatCents(row.amountCents, row.currency)}
{row.currency}
{row.estimated ?
estimated
: null}
)) )}
); }