From 4d911fef703027639125548550365caf59a785e8 Mon Sep 17 00:00:00 2001 From: tomjeatt <40243778+tomjeatt@users.noreply.github.com> Date: Fri, 9 Feb 2024 14:55:18 +0000 Subject: [PATCH] fix: chart counter enum and lower value for collateral (#1638) --- src/config/charts.ts | 7 +++++-- src/pages/Dashboard/IssuedChart/index.tsx | 4 ++-- src/pages/Dashboard/cards/ActiveVaultsCard/index.tsx | 4 ++-- .../sub-pages/Home/LockedCollateralsCard/index.tsx | 6 +++--- .../RedeemRequests/UpperContent/RedeemedChart/index.tsx | 4 ++-- .../sub-pages/Vaults/LockedCollateralCard/index.tsx | 4 ++-- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/config/charts.ts b/src/config/charts.ts index a275b118ca..b00549289c 100644 --- a/src/config/charts.ts +++ b/src/config/charts.ts @@ -1,3 +1,6 @@ -const COUNT_OF_DATES_FOR_CHART = 180; +enum CountOfDatesForChart { + SIX_MONTHS = 180, + ONE_MONTH = 30 +} -export { COUNT_OF_DATES_FOR_CHART }; +export { CountOfDatesForChart }; diff --git a/src/pages/Dashboard/IssuedChart/index.tsx b/src/pages/Dashboard/IssuedChart/index.tsx index c3f3c3a117..ed45d754e1 100644 --- a/src/pages/Dashboard/IssuedChart/index.tsx +++ b/src/pages/Dashboard/IssuedChart/index.tsx @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next'; import { useQuery } from 'react-query'; import { getLastMidnightTimestamps } from '@/common/utils/utils'; -import { COUNT_OF_DATES_FOR_CHART } from '@/config/charts'; +import { CountOfDatesForChart } from '@/config/charts'; import { WRAPPED_TOKEN, WRAPPED_TOKEN_SYMBOL } from '@/config/relay-chains'; import ErrorFallback from '@/legacy-components/ErrorFallback'; import cumulativeVolumesFetcher, { @@ -17,7 +17,7 @@ import { KUSAMA, POLKADOT } from '@/utils/constants/relay-chain-names'; import LineChart from '../LineChart'; -const cutoffTimestamps = getLastMidnightTimestamps(COUNT_OF_DATES_FOR_CHART, true); +const cutoffTimestamps = getLastMidnightTimestamps(CountOfDatesForChart.SIX_MONTHS, true); const IssuedChart = (): JSX.Element => { const { t } = useTranslation(); diff --git a/src/pages/Dashboard/cards/ActiveVaultsCard/index.tsx b/src/pages/Dashboard/cards/ActiveVaultsCard/index.tsx index cf433a86c5..077acc781c 100644 --- a/src/pages/Dashboard/cards/ActiveVaultsCard/index.tsx +++ b/src/pages/Dashboard/cards/ActiveVaultsCard/index.tsx @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'; import { useQuery } from 'react-query'; import { formatNumber, getLastMidnightTimestamps } from '@/common/utils/utils'; -import { COUNT_OF_DATES_FOR_CHART } from '@/config/charts'; +import { CountOfDatesForChart } from '@/config/charts'; import ErrorFallback from '@/legacy-components/ErrorFallback'; import graphqlFetcher, { GRAPHQL_FETCHER, GraphqlReturn } from '@/services/fetchers/graphql-fetcher'; import { INTERLAY_DENIM, KINTSUGI_SUNDOWN } from '@/utils/constants/colors'; @@ -23,7 +23,7 @@ interface VaultRegistration { registrationTimestamp: number; } -const cutoffTimestamps = getLastMidnightTimestamps(COUNT_OF_DATES_FOR_CHART, true); +const cutoffTimestamps = getLastMidnightTimestamps(CountOfDatesForChart.SIX_MONTHS, true); const ActiveVaultsCard = ({ hasLinks }: Props): JSX.Element => { const { t } = useTranslation(); diff --git a/src/pages/Dashboard/sub-pages/Home/LockedCollateralsCard/index.tsx b/src/pages/Dashboard/sub-pages/Home/LockedCollateralsCard/index.tsx index 617d95f1f7..f759239434 100644 --- a/src/pages/Dashboard/sub-pages/Home/LockedCollateralsCard/index.tsx +++ b/src/pages/Dashboard/sub-pages/Home/LockedCollateralsCard/index.tsx @@ -3,7 +3,7 @@ import { useErrorHandler, withErrorBoundary } from 'react-error-boundary'; import { useTranslation } from 'react-i18next'; import { convertMonetaryAmountToValueInUSD, formatUSD, getLastMidnightTimestamps } from '@/common/utils/utils'; -import { COUNT_OF_DATES_FOR_CHART } from '@/config/charts'; +import { CountOfDatesForChart } from '@/config/charts'; import { useGetPrices } from '@/hooks/api/use-get-prices'; import useAllCumulativeVaultCollateralVolumes from '@/hooks/use-all-cumulative-vault-collateral-volumes'; import ErrorFallback from '@/legacy-components/ErrorFallback'; @@ -16,7 +16,7 @@ import DashboardCard from '../../../cards/DashboardCard'; import LineChart from '../../../LineChart'; import Stats, { StatsDd, StatsDt, StatsRouterLink } from '../../../Stats'; -const cutoffTimestamps = getLastMidnightTimestamps(COUNT_OF_DATES_FOR_CHART, true); +const cutoffTimestamps = getLastMidnightTimestamps(CountOfDatesForChart.ONE_MONTH, true); const LockedCollateralsCard = (): JSX.Element => { const { t } = useTranslation(); @@ -31,7 +31,7 @@ const LockedCollateralsCard = (): JSX.Element => { const cumulativeUSDVolumes = React.useMemo(() => { if (allCumulativeVaultCollateralVolumes === undefined) return; - return Array(COUNT_OF_DATES_FOR_CHART) + return Array(CountOfDatesForChart.ONE_MONTH) .fill(0) .map((_, index) => { const collateralTickers = Object.keys(allCumulativeVaultCollateralVolumes); diff --git a/src/pages/Dashboard/sub-pages/RedeemRequests/UpperContent/RedeemedChart/index.tsx b/src/pages/Dashboard/sub-pages/RedeemRequests/UpperContent/RedeemedChart/index.tsx index 095ff5999f..db13989d86 100644 --- a/src/pages/Dashboard/sub-pages/RedeemRequests/UpperContent/RedeemedChart/index.tsx +++ b/src/pages/Dashboard/sub-pages/RedeemRequests/UpperContent/RedeemedChart/index.tsx @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next'; import { useQuery } from 'react-query'; import { getLastMidnightTimestamps } from '@/common/utils/utils'; -import { COUNT_OF_DATES_FOR_CHART } from '@/config/charts'; +import { CountOfDatesForChart } from '@/config/charts'; import { WRAPPED_TOKEN } from '@/config/relay-chains'; import ErrorFallback from '@/legacy-components/ErrorFallback'; import cumulativeVolumesFetcher, { @@ -17,7 +17,7 @@ import { KUSAMA, POLKADOT } from '@/utils/constants/relay-chain-names'; import LineChart from '../../../../LineChart'; -const cutoffTimestamps = getLastMidnightTimestamps(COUNT_OF_DATES_FOR_CHART, true); +const cutoffTimestamps = getLastMidnightTimestamps(CountOfDatesForChart.SIX_MONTHS, true); const RedeemedChart = (): JSX.Element => { const { t } = useTranslation(); diff --git a/src/pages/Dashboard/sub-pages/Vaults/LockedCollateralCard/index.tsx b/src/pages/Dashboard/sub-pages/Vaults/LockedCollateralCard/index.tsx index 982c6341ff..3388aed28c 100644 --- a/src/pages/Dashboard/sub-pages/Vaults/LockedCollateralCard/index.tsx +++ b/src/pages/Dashboard/sub-pages/Vaults/LockedCollateralCard/index.tsx @@ -7,7 +7,7 @@ import { displayMonetaryAmountInUSDFormat, getLastMidnightTimestamps } from '@/common/utils/utils'; -import { COUNT_OF_DATES_FOR_CHART } from '@/config/charts'; +import { CountOfDatesForChart } from '@/config/charts'; import useCumulativeCollateralVolumes from '@/hooks/use-cumulative-collateral-volumes'; import ErrorFallback from '@/legacy-components/ErrorFallback'; import DashboardCard from '@/pages/Dashboard/cards/DashboardCard'; @@ -16,7 +16,7 @@ import Stats, { StatsDd, StatsDt } from '@/pages/Dashboard/Stats'; import { INTERLAY_DENIM, KINTSUGI_SUPERNOVA } from '@/utils/constants/colors'; import { KUSAMA, POLKADOT } from '@/utils/constants/relay-chain-names'; -const cutoffTimestamps = getLastMidnightTimestamps(COUNT_OF_DATES_FOR_CHART, true); +const cutoffTimestamps = getLastMidnightTimestamps(CountOfDatesForChart.SIX_MONTHS, true); interface Props { collateralToken: CollateralCurrencyExt;