From 256a7034bc46193bcb72991a0237e39a5bc6620c Mon Sep 17 00:00:00 2001 From: Alexander Petkov Date: Wed, 13 Dec 2023 16:05:00 +0200 Subject: [PATCH] client/Campaigns: Fix NaN due to guaranteedAmount missing --- src/components/client/campaigns/CampaignCard/CampaignCard.tsx | 2 +- src/components/client/campaigns/CampaignDetails.tsx | 4 ++-- src/components/client/campaigns/InlineDonation.tsx | 2 +- .../ActiveCampaignCard/ActiveCampaignCard.tsx | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/client/campaigns/CampaignCard/CampaignCard.tsx b/src/components/client/campaigns/CampaignCard/CampaignCard.tsx index d99672f4f..cf1ab0d60 100644 --- a/src/components/client/campaigns/CampaignCard/CampaignCard.tsx +++ b/src/components/client/campaigns/CampaignCard/CampaignCard.tsx @@ -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 diff --git a/src/components/client/campaigns/CampaignDetails.tsx b/src/components/client/campaigns/CampaignDetails.tsx index 0c6987e4e..3a9bf57de 100644 --- a/src/components/client/campaigns/CampaignDetails.tsx +++ b/src/components/client/campaigns/CampaignDetails.tsx @@ -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 ( @@ -219,7 +219,7 @@ const CampaignFinanceSummary = ({ campaign, expenses }: CampaignFinanceProps) => - Гарантирани: {moneyPublic(campaign.summary.guaranteedAmount)} + Гарантирани: {moneyPublic(campaign.summary.guaranteedAmount ?? 0)}