From 49c42cdd53454a62eec6b583134847ceca2a90f2 Mon Sep 17 00:00:00 2001 From: Marie Gauthier Date: Tue, 10 Dec 2024 09:49:36 +0100 Subject: [PATCH] fix: APP-528 registered credits in compliance credits tab (#2569) --- .../ProjectBatchTotals/ProjectBatchTotals.tsx | 21 ++++++++++++------- .../ProjectTopSection/ProjectTopSection.tsx | 9 ++++---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/web-marketplace/src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx b/web-marketplace/src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx index 48d83b965c..55da35805c 100644 --- a/web-marketplace/src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx +++ b/web-marketplace/src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx @@ -31,6 +31,13 @@ const GridItem: React.FC> = ({ children }) => ( {children} ); +export type ProjectBatchTotalsProps = { + totals: BatchTotalsForProject & { registeredAmount?: number }; + projectWithOrderData?: NormalizeProject; + soldOutProjectsIds: string[]; + sx?: SxProps; + className?: string; +}; export function ProjectBatchTotals({ totals, @@ -38,13 +45,7 @@ export function ProjectBatchTotals({ soldOutProjectsIds, sx = [], className, -}: { - totals: BatchTotalsForProject; - projectWithOrderData?: NormalizeProject; - soldOutProjectsIds: string[]; - sx?: SxProps; - className?: string; -}): JSX.Element { +}: ProjectBatchTotalsProps): JSX.Element { const { _ } = useLingui(); const isSoldOut = getIsSoldOut({ project: projectWithOrderData, @@ -86,7 +87,11 @@ export function ProjectBatchTotals({ ? _(REGISTERED_CREDITS_TOOLTIP) : _(ISSUED_CREDITS_TOOLTIP) } - number={totals.tradableAmount + totals.retiredAmount} + number={ + isComplianceProject + ? totals.registeredAmount + : totals.tradableAmount + totals.retiredAmount + } formatNumberOptions={{ ...quantityFormatNumberOptions, maximumFractionDigits: MAX_FRACTION_DIGITS_PROJECT_CREDITS, diff --git a/web-marketplace/src/components/organisms/ProjectTopSection/ProjectTopSection.tsx b/web-marketplace/src/components/organisms/ProjectTopSection/ProjectTopSection.tsx index b9a9701055..5cbbf31153 100644 --- a/web-marketplace/src/components/organisms/ProjectTopSection/ProjectTopSection.tsx +++ b/web-marketplace/src/components/organisms/ProjectTopSection/ProjectTopSection.tsx @@ -14,7 +14,6 @@ import Section from 'web-components/src/components/section'; import { Body, Label, Title } from 'web-components/src/components/typography'; import { pxToRem } from 'web-components/src/theme/muiTheme'; -import { BatchTotalsForProject } from 'types/ledger/ecocredit'; import { useLedger } from 'ledger'; import { selectedLanguageAtom } from 'lib/atoms/languageSwitcher.atoms'; import { client as sanityClient } from 'lib/clients/sanity'; @@ -44,7 +43,7 @@ import { Prefinance } from 'components/templates/ProjectDetails/ProjectDetails.P import TerrasosCreditsInfo from 'components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo'; import { useTags } from 'hooks/useTags'; -import { ProjectBatchTotals } from '../../molecules'; +import { ProjectBatchTotals, ProjectBatchTotalsProps } from '../../molecules'; import { ProjectTopSectionCreditClassCard } from './ProjectTopSection.CreditClassCard'; import { ProjectTopSectionQuoteMark, @@ -216,12 +215,12 @@ function ProjectTopSection({ const isTerrasosProjectPage = projectPageMetadata?.['@type'] === 'TerrasosProjectInfo'; - const batchTotals: BatchTotalsForProject = { - cancelledAmount: + const batchTotals = { + registeredAmount: normalizedProject?.complianceCredits.creditsRegistered ?? 0, retiredAmount: normalizedProject?.complianceCredits.creditsRetired ?? 0, tradableAmount: normalizedProject?.complianceCredits.creditsAvailable ?? 0, - }; + } as ProjectBatchTotalsProps['totals']; const isComplianceProject = normalizedProject?.marketType?.includes(COMPLIANCE_MARKET) ?? false;