Skip to content

Commit

Permalink
client/Campaigns: Fix NaN due to guaranteedAmount missing
Browse files Browse the repository at this point in the history
  • Loading branch information
sashko9807 committed Dec 13, 2023
1 parent 852970f commit 256a703
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function ActiveCampaignCard({ campaign, index }: Props) {

const campaignImagesUrl = campaignListPictureUrl(campaign)

const reached = summary ? summary.reachedAmount + summary.guaranteedAmount : 0
const reached = summary ? summary.reachedAmount + (summary.guaranteedAmount ?? 0) : 0
const reachedAmount = moneyPublic(reached)
const targetAmount = moneyPublic(campaign.targetAmount)
const percentage = (reached / target) * 100
Expand Down
4 changes: 2 additions & 2 deletions src/components/client/campaigns/CampaignDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ type CampaignFinanceProps = Props & {
expenses: number
}
const CampaignFinanceSummary = ({ campaign, expenses }: CampaignFinanceProps) => {
const total = campaign.summary.guaranteedAmount + campaign.summary.reachedAmount
const total = (campaign.summary.guaranteedAmount ?? 0) + campaign.summary.reachedAmount
const transferred = campaign.summary.blockedAmount + campaign.summary.withdrawnAmount
return (
<StyledGrid item>
Expand All @@ -219,7 +219,7 @@ const CampaignFinanceSummary = ({ campaign, expenses }: CampaignFinanceProps) =>
</Tooltip>
</Typography>
<Typography className={classes.financeSummary}>
Гарантирани: {moneyPublic(campaign.summary.guaranteedAmount)}
Гарантирани: {moneyPublic(campaign.summary.guaranteedAmount ?? 0)}
<Tooltip
enterTouchDelay={0}
title={
Expand Down
2 changes: 1 addition & 1 deletion src/components/client/campaigns/InlineDonation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export default function InlineDonation({ campaign }: Props) {
state: campaignState,
slug: campaignSlug,
} = campaign
const reached = summary ? summary.reachedAmount + summary.guaranteedAmount : 0
const reached = summary ? summary.reachedAmount + (summary.guaranteedAmount ?? 0) : 0
const reachedAmount = moneyPublic(reached)
const targetAmount = moneyPublic(campaign.targetAmount)
const donors = summary?.donors ?? 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function ActiveCampaignCard({ campaign, index }: Props) {
const { id, slug, title, summary, targetAmount: target } = campaign
const campaignImagesUrl = campaignListPictureUrl(campaign)

const reached = summary ? summary.reachedAmount + campaign.summary.guaranteedAmount : 0
const reached = summary ? summary.reachedAmount + (summary.guaranteedAmount ?? 0) : 0

const reachedAmount = moneyPublic(reached)
const targetAmount = moneyPublic(campaign.targetAmount)
Expand Down

0 comments on commit 256a703

Please sign in to comment.