Skip to content

Commit

Permalink
Load all months and use the most recent one
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Jan 8, 2025
1 parent 580e7b1 commit 6eb69ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
query MachineCalculatedGoal($accountListId: ID!, $month: ISO8601Date!) {
healthIndicatorData(
accountListId: $accountListId
beginDate: $month
endDate: $month
) {
query MachineCalculatedGoal($accountListId: ID!) {
healthIndicatorData(accountListId: $accountListId) {
id
machineCalculatedGoal
machineCalculatedGoalCurrency
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { ReactElement, useMemo } from 'react';
import { Box, Button, TextField, Tooltip } from '@mui/material';
import { Formik } from 'formik';
import { DateTime } from 'luxon';
import { useSnackbar } from 'notistack';
import { useTranslation } from 'react-i18next';
import * as yup from 'yup';
Expand Down Expand Up @@ -62,12 +61,12 @@ export const MonthlyGoalAccordion: React.FC<MonthlyGoalAccordionProps> = ({
const { data } = useMachineCalculatedGoalQuery({
variables: {
accountListId,
month: DateTime.now().startOf('month').toISODate(),
},
});
const calculatedGoal = data?.healthIndicatorData[0]?.machineCalculatedGoal;
const calculatedCurrency =
data?.healthIndicatorData[0]?.machineCalculatedGoalCurrency;
const {
machineCalculatedGoal: calculatedGoal,
machineCalculatedGoalCurrency: calculatedCurrency,
} = data?.healthIndicatorData.at(-1) ?? {};
const formattedCalculatedGoal = useMemo(
() =>
formatMonthlyGoal(
Expand Down

0 comments on commit 6eb69ac

Please sign in to comment.