summaryrefslogtreecommitdiff
path: root/frontend/components/prism/SensitivityTable.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/components/prism/SensitivityTable.tsx')
-rw-r--r--frontend/components/prism/SensitivityTable.tsx72
1 files changed, 72 insertions, 0 deletions
diff --git a/frontend/components/prism/SensitivityTable.tsx b/frontend/components/prism/SensitivityTable.tsx
new file mode 100644
index 0000000..ef86e9b
--- /dev/null
+++ b/frontend/components/prism/SensitivityTable.tsx
@@ -0,0 +1,72 @@
+"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 (
+ <div className="psm-val-sensitivity">
+ <div className="psm-val-sensitivity-head">
+ <span className="psm-val-sensitivity-title">Implied Price Sensitivity</span>
+ <span className="psm-val-sensitivity-subtitle">WACC × Terminal Growth</span>
+ </div>
+ <table className="psm-val-sensitivity-table">
+ <thead>
+ <tr>
+ <th className="psm-val-sensitivity-corner">WACC \ g</th>
+ {terminal_growth.map((g, i) => (
+ <th
+ key={i}
+ className={`psm-val-sensitivity-col-header${
+ i === centerCol ? " is-center" : ""
+ }`}
+ >
+ {fmtPct(g)}
+ </th>
+ ))}
+ </tr>
+ </thead>
+ <tbody>
+ {wacc.map((w, rowIdx) => (
+ <tr key={rowIdx}>
+ <th
+ className={`psm-val-sensitivity-row-header${
+ rowIdx === centerRow ? " is-center" : ""
+ }`}
+ >
+ {fmtPct(w)}
+ </th>
+ {implied_prices[rowIdx]?.map((price, colIdx) => {
+ const isCenter = rowIdx === centerRow && colIdx === centerCol;
+ const isNegative = price != null && price < 0;
+ return (
+ <td
+ key={colIdx}
+ className={`psm-val-sensitivity-cell${isCenter ? " is-center" : ""}${isNegative ? " negative" : ""}`}
+ >
+ {price != null && !isNegative ? fmtCurrency(price, 2, currency) : "—"}
+ </td>
+ );
+ })}
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ );
+}