import { Fragment } from 'react'; import { Panel } from '@/components/ui/panel'; import { formatCompactCurrency, formatScaledNumber } from '@/lib/format'; import type { CompanyAnalysis } from '@/lib/types'; type ValuationFactsTableProps = { analysis: CompanyAnalysis; }; function formatRatio(value: number | null) { return value === null ? '—' : `${value.toFixed(2)}x`; } function formatShares(value: number | null) { return value === null ? '—' : formatScaledNumber(value, { maximumFractionDigits: 2 }); } function formatCompactCurrencyOrDash(value: number | null) { return value === null ? '—' : formatCompactCurrency(value); } export function ValuationFactsTable(props: ValuationFactsTableProps) { const items = [ { label: 'Source', value: props.analysis.valuationSnapshot.source }, { label: 'Market cap', value: formatCompactCurrencyOrDash(props.analysis.valuationSnapshot.marketCap) }, { label: 'Enterprise value', value: formatCompactCurrencyOrDash(props.analysis.valuationSnapshot.enterpriseValue) }, { label: 'Shares outstanding', value: formatShares(props.analysis.valuationSnapshot.sharesOutstanding) }, { label: 'Trailing P/E', value: formatRatio(props.analysis.valuationSnapshot.trailingPe) }, { label: 'EV / Revenue', value: formatRatio(props.analysis.valuationSnapshot.evToRevenue) }, { label: 'EV / EBITDA', value: formatRatio(props.analysis.valuationSnapshot.evToEbitda) } ]; const rows = Array.from({ length: Math.ceil(items.length / 2) }, (_, index) => items.slice(index * 2, index * 2 + 2)); return (
{rows.map((row) => ( item.label).join('-')} className="border-t border-[color:var(--line-weak)]"> {row.map((item) => ( ))} {row.length === 1 ? ( <> ))}
{item.label} {item.value} ) : null}
); }