Skip to content

Commit

Permalink
chore: Add donation button for complete and partially_finances if che…
Browse files Browse the repository at this point in the history
…ckeed
  • Loading branch information
sashko9807 committed Oct 9, 2024
1 parent 6fd57db commit b5dafcc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/components/client/campaigns/CampaignCard/CampaignCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import theme from 'common/theme'
import Link from 'components/common/Link'
import CampaignProgress from 'components/client/campaigns/CampaignProgress'
import SuccessfullCampaignTag from '../SuccessfullCampaignTag'
import { CampaignState } from '../helpers/campaign.enums'
import { CampaignState, canAcceptDonationState } from '../helpers/campaign.enums'

import { Root } from './CampaignCard.styled'
import {
Expand Down Expand Up @@ -92,14 +92,15 @@ export default function ActiveCampaignCard({ campaign, index }: Props) {
</StyledContent>
</Link>
<StyledCardActions disableSpacing>
{(campaignState === CampaignState.complete && !allowDonationOnComplete) || (
<DonateButton
href={routes.campaigns.oneTimeDonation(slug)}
variant="contained"
color="secondary">
{t('cta.support')}
</DonateButton>
)}
{campaignState === CampaignState.active ||
(canAcceptDonationState.has(campaignState) && !allowDonationOnComplete) || (
<DonateButton
href={routes.campaigns.oneTimeDonation(slug)}
variant="contained"
color="secondary">
{t('cta.support')}
</DonateButton>
)}
</StyledCardActions>
</Root>
)
Expand Down
5 changes: 5 additions & 0 deletions src/components/client/campaigns/helpers/campaign.enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export enum CampaignState {
deleted = 'deleted',
}

export const canAcceptDonationState = new Set([
CampaignState.partially_financed,
CampaignState.complete,
])

export enum StatisticsGroupBy {
DAY = 'day',
WEEK = 'week',
Expand Down

0 comments on commit b5dafcc

Please sign in to comment.