Skip to content

Commit

Permalink
fix: APP-528 registered credits in compliance credits tab (#2569)
Browse files Browse the repository at this point in the history
  • Loading branch information
blushi authored Dec 10, 2024
1 parent 27e158b commit 49c42cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ const GridItem: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => (
{children}
</Grid>
);
export type ProjectBatchTotalsProps = {
totals: BatchTotalsForProject & { registeredAmount?: number };
projectWithOrderData?: NormalizeProject;
soldOutProjectsIds: string[];
sx?: SxProps<Theme>;
className?: string;
};

export function ProjectBatchTotals({
totals,
projectWithOrderData,
soldOutProjectsIds,
sx = [],
className,
}: {
totals: BatchTotalsForProject;
projectWithOrderData?: NormalizeProject;
soldOutProjectsIds: string[];
sx?: SxProps<Theme>;
className?: string;
}): JSX.Element {
}: ProjectBatchTotalsProps): JSX.Element {
const { _ } = useLingui();
const isSoldOut = getIsSoldOut({
project: projectWithOrderData,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 49c42cd

Please sign in to comment.