import type { CompanyValuationSnapshot } from '@/lib/types'; import { formatCompactCurrency, formatScaledNumber } from '@/lib/format'; type ValuationStatGridProps = { valuation: CompanyValuationSnapshot; }; function formatRatio(value: number | null) { return value === null ? 'n/a' : `${value.toFixed(2)}x`; } function formatShares(value: number | null) { return value === null ? 'n/a' : formatScaledNumber(value, { maximumFractionDigits: 2 }); } export function ValuationStatGrid(props: ValuationStatGridProps) { const items = [ { label: 'Market cap', value: props.valuation.marketCap === null ? 'n/a' : formatCompactCurrency(props.valuation.marketCap) }, { label: 'Enterprise value', value: props.valuation.enterpriseValue === null ? 'n/a' : formatCompactCurrency(props.valuation.enterpriseValue) }, { label: 'Shares out.', value: formatShares(props.valuation.sharesOutstanding) }, { label: 'Trailing P/E', value: formatRatio(props.valuation.trailingPe) }, { label: 'EV / Revenue', value: formatRatio(props.valuation.evToRevenue) }, { label: 'EV / EBITDA', value: formatRatio(props.valuation.evToEbitda) } ]; return (
{items.map((item) => (

{item.label}

{item.value}

))}
); }