From 259374eb6c3a047129dc8183bcc6fc2b608b1684 Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Wed, 8 Jan 2025 15:35:37 -0600 Subject: [PATCH] Refactor nested ternary --- .../MonthlyGoalAccordion.tsx | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx b/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx index 3d225ef63..d0323e1b0 100644 --- a/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx +++ b/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx @@ -110,19 +110,25 @@ export const MonthlyGoalAccordion: React.FC = ({ handleSetupChange(); }; - const instructions = calculatedGoal - ? initialMonthlyGoal === null - ? t( - 'Based on the past year, NetSuite estimates that you need at least {{goal}} of monthly support. You can choose your own target monthly goal or leave it blank to use the estimate.', - { goal: formattedCalculatedGoal }, - ) - : t( - 'Based on the past year, NetSuite estimates that you need at least {{goal}} of monthly support. You can choose your own target monthly goal or reset it to the estimate.', - { goal: formattedCalculatedGoal }, - ) - : t( + const getInstructions = () => { + if (typeof calculatedGoal !== 'number') { + return t( 'This amount should be set to the amount your organization has determined is your target monthly goal. If you do not know, make your best guess for now. You can change it at any time.', ); + } + + if (initialMonthlyGoal) { + return t( + 'Based on the past year, NetSuite estimates that you need at least {{goal}} of monthly support. You can choose your own target monthly goal or leave it blank to use the estimate.', + { goal: formattedCalculatedGoal }, + ); + } else { + return t( + 'Based on the past year, NetSuite estimates that you need at least {{goal}} of monthly support. You can choose your own target monthly goal or reset it to use the estimate.', + { goal: formattedCalculatedGoal }, + ); + } + }; return ( = ({ handleChange, }): ReactElement => (
- +