Skip to content

Commit

Permalink
Show the machine calculated goal currency
Browse files Browse the repository at this point in the history
Previously the account currency was being used instead of the currency
of the machine calculated goal
  • Loading branch information
canac committed Jan 6, 2025
1 parent 35fe64e commit 0463bfa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ query MachineCalculatedGoal($accountListId: ID!, $month: ISO8601Date!) {
) {
id
machineCalculatedGoal
machineCalculatedGoalCurrency
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ const mutationSpy = jest.fn();
interface ComponentsProps {
monthlyGoal: number | null;
machineCalculatedGoal?: number;
machineCalculatedGoalCurrency?: string;
expandedPanel: string;
}

const Components: React.FC<ComponentsProps> = ({
monthlyGoal,
machineCalculatedGoal,
machineCalculatedGoalCurrency = null,
expandedPanel,
}) => (
<SnackbarProvider>
Expand All @@ -52,7 +54,7 @@ const Components: React.FC<ComponentsProps> = ({
mocks={{
MachineCalculatedGoal: {
healthIndicatorData: machineCalculatedGoal
? [{ machineCalculatedGoal }]
? [{ machineCalculatedGoal, machineCalculatedGoalCurrency }]
: [],
},
}}
Expand Down Expand Up @@ -155,13 +157,14 @@ describe('MonthlyGoalAccordion', () => {
<Components
monthlyGoal={1000}
machineCalculatedGoal={1500}
machineCalculatedGoalCurrency="EUR"
expandedPanel={label}
/>,
);

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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ export const MonthlyGoalAccordion: React.FC<MonthlyGoalAccordionProps> = ({
},
});
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(
Expand Down

0 comments on commit 0463bfa

Please sign in to comment.