From 0f6cd57f3dc14145db0cec12f37368a19f797d78 Mon Sep 17 00:00:00 2001 From: Felix Schulze Date: Wed, 30 Apr 2025 19:37:28 +0200 Subject: [PATCH] result style --- src/app/components/FireCalculatorForm.tsx | 344 ++++++++++++---------- 1 file changed, 185 insertions(+), 159 deletions(-) diff --git a/src/app/components/FireCalculatorForm.tsx b/src/app/components/FireCalculatorForm.tsx index 3c4e4ec..253abe1 100644 --- a/src/app/components/FireCalculatorForm.tsx +++ b/src/app/components/FireCalculatorForm.tsx @@ -541,180 +541,206 @@ export default function FireCalculatorForm() { {result && ( - <> - - - Results - - - {result.error ? ( +
+ {result.error ? ( + +

{result.error}

- ) : ( -
-
- -

+ + + ) : ( + <> + + + FIRE Number + + Required capital at retirement using{" "} + {form.getValues().retirementStrategy} + + + +

+

{formatNumber(result.fireNumber)}

-
- -

+ + + + + + Retirement Age + + Estimated age when you can retire + + + +

+

{result.retirementAge ?? "N/A"}

- {result.inflationAdjustedAllowance && ( -
- -

+ + + + {result.inflationAdjustedAllowance && ( + + + Monthly Allowance + + At retirement (inflation adjusted) + + + +

+

{formatNumber(result.inflationAdjustedAllowance)}

- )} - {result.retirementYears && ( -
- -

+ + + )} + + {result.retirementYears && ( + + + Retirement Duration + + Years in retirement + + + +

+

{result.retirementYears}

- )} -
+ + )} - - - - {result.yearlyData && result.yearlyData.length > 0 && ( - - - Financial Projection - - Projected balance growth and FIRE number threshold - - - - - - - - { - if (value >= 1000000) { - return `${(value / 1000000).toFixed(1)}M`; - } else if (value >= 1000) { - return `${(value / 1000).toFixed(0)}K`; - } - return value.toString(); - }} - width={80} - /> - { - if (active && payload?.[0]?.payload) { - const data = payload[0] - .payload as (typeof result.yearlyData)[0]; - return ( -
-

{`Year: ${data.year.toString()} (Age: ${data.age.toString()})`}

-

{`Balance: ${formatNumber(data.balance)}`}

- {result.fireNumber !== null && ( -

{`Target FIRE Number: ${formatNumber(result.fireNumber)}`}

- )} -

{`Phase: ${data.phase === "accumulation" ? "Accumulation" : "Retirement"}`}

-
- ); - } - return null; - }} - /> - - - - - - - - {result.fireNumber && ( - - )} - {result.retirementAge && ( - - )} -
-
-
-
+ )} - +
+ )} + + {result?.yearlyData && result.yearlyData.length > 0 && ( + + + Financial Projection + + Projected balance growth and FIRE number threshold + + + + + + + + { + if (value >= 1000000) { + return `${(value / 1000000).toFixed(1)}M`; + } else if (value >= 1000) { + return `${(value / 1000).toFixed(0)}K`; + } + return value.toString(); + }} + width={80} + /> + { + if (active && payload?.[0]?.payload) { + const data = payload[0] + .payload as (typeof result.yearlyData)[0]; + return ( +
+

{`Year: ${data.year.toString()} (Age: ${data.age.toString()})`}

+

{`Balance: ${formatNumber(data.balance)}`}

+ {result.fireNumber !== null && ( +

{`Target FIRE Number: ${formatNumber(result.fireNumber)}`}

+ )} +

{`Phase: ${data.phase === "accumulation" ? "Accumulation" : "Retirement"}`}

+
+ ); + } + return null; + }} + /> + + + + + + + + {result.fireNumber && ( + + )} + {result.retirementAge && ( + + )} +
+
+
+
)}
);