From 0463bfa4ed29543a97338f3b180780e852a90109 Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Mon, 6 Jan 2025 14:23:18 -0600 Subject: [PATCH] Show the machine calculated goal currency Previously the account currency was being used instead of the currency of the machine calculated goal --- .../MonthlyGoalAccordion/MachineCalculatedGoal.graphql | 1 + .../MonthlyGoalAccordion/MonthlyGoalAccordion.test.tsx | 7 +++++-- .../MonthlyGoalAccordion/MonthlyGoalAccordion.tsx | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MachineCalculatedGoal.graphql b/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MachineCalculatedGoal.graphql index 0e9e00ead..5a28784fe 100644 --- a/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MachineCalculatedGoal.graphql +++ b/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MachineCalculatedGoal.graphql @@ -6,5 +6,6 @@ query MachineCalculatedGoal($accountListId: ID!, $month: ISO8601Date!) { ) { id machineCalculatedGoal + machineCalculatedGoalCurrency } } diff --git a/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.test.tsx b/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.test.tsx index 3a6ad99c3..73713f73c 100644 --- a/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.test.tsx +++ b/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.test.tsx @@ -35,12 +35,14 @@ const mutationSpy = jest.fn(); interface ComponentsProps { monthlyGoal: number | null; machineCalculatedGoal?: number; + machineCalculatedGoalCurrency?: string; expandedPanel: string; } const Components: React.FC = ({ monthlyGoal, machineCalculatedGoal, + machineCalculatedGoalCurrency = null, expandedPanel, }) => ( @@ -52,7 +54,7 @@ const Components: React.FC = ({ mocks={{ MachineCalculatedGoal: { healthIndicatorData: machineCalculatedGoal - ? [{ machineCalculatedGoal }] + ? [{ machineCalculatedGoal, machineCalculatedGoalCurrency }] : [], }, }} @@ -155,13 +157,14 @@ describe('MonthlyGoalAccordion', () => { , ); expect( await findByText( - /Based on the past year, NetSuite estimates that you need at least \$1,500 of monthly support./, + /Based on the past year, NetSuite estimates that you need at least €1,500 of monthly support./, ), ).toBeInTheDocument(); diff --git a/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx b/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx index d60712214..81d6f569a 100644 --- a/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx +++ b/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx @@ -66,9 +66,11 @@ export const MonthlyGoalAccordion: React.FC = ({ }, }); const calculatedGoal = data?.healthIndicatorData[0]?.machineCalculatedGoal; + const calculatedCurrency = + data?.healthIndicatorData[0]?.machineCalculatedGoalCurrency ?? currency; const formattedCalculatedGoal = useMemo( - () => formatMonthlyGoal(calculatedGoal ?? null, currency, locale), - [calculatedGoal, currency, locale], + () => formatMonthlyGoal(calculatedGoal ?? null, calculatedCurrency, locale), + [calculatedGoal, calculatedCurrency, locale], ); const formattedMonthlyGoal = useMemo(