"use client"; import { fmtCurrency, fmtPct } from "@/lib/format"; import type { SensitivityMatrix } from "@/types/api"; type Props = { matrix: SensitivityMatrix; centerWacc?: number; centerTerminalGrowth?: number; currency: string; }; export function SensitivityTable({ matrix, centerWacc, centerTerminalGrowth, currency }: Props) { const { wacc, terminal_growth, implied_prices } = matrix; const centerRow = centerWacc != null ? wacc.findIndex((v) => Math.abs(v - centerWacc) < 1e-9) : -1; const centerCol = centerTerminalGrowth != null ? terminal_growth.findIndex((v) => Math.abs(v - centerTerminalGrowth) < 1e-9) : -1; return (
| WACC \ g | {terminal_growth.map((g, i) => ({fmtPct(g)} | ))}
|---|---|
| {fmtPct(w)} | {implied_prices[rowIdx]?.map((price, colIdx) => { const isCenter = rowIdx === centerRow && colIdx === centerCol; const isNegative = price != null && price < 0; return ({price != null && !isNegative ? fmtCurrency(price, 2, currency) : "—"} | ); })}