Skip to content

Commit

Permalink
fix: add frequency tab options for donations, even when tiers are dis…
Browse files Browse the repository at this point in the history
…abled (#2930)
  • Loading branch information
laurelfulford authored Feb 15, 2024
1 parent f3a6e55 commit cb7eb7b
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions assets/wizards/readerRevenue/views/donation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,24 +208,44 @@ export const DonationAmounts = () => {
) : (
<Card isMedium>
<Grid columns={ 3 } rowGap={ 16 }>
{ availableFrequencies.map( section => (
<MoneyInput
currencySymbol={ currencySymbol }
label={ section.staticLabel }
value={ amounts[ section.key ][ 3 ] }
min={ minimumDonationFloat }
error={
amounts[ section.key ][ 3 ] < minimumDonationFloat
? __(
'Warning: suggested donations should be at least the minimum donation amount.',
'newspack'
)
: null
}
onChange={ changeHandler( [ 'amounts', section.key, 3 ] ) }
key={ section.key }
/>
) ) }
{ availableFrequencies.map( section => {
const isFrequencyDisabled = disabledFrequencies[ section.key ];
const isOneFrequencyActive =
Object.values( disabledFrequencies ).filter( Boolean ).length ===
FREQUENCY_SLUGS.length - 1;
return (
<Grid columns={ 1 } gutter={ 16 } key={ section.key }>
<ToggleControl
checked={ ! isFrequencyDisabled }
onChange={ () =>
changeHandler( [ 'disabledFrequencies', section.key ] )(
! isFrequencyDisabled
)
}
label={ section.tieredLabel }
disabled={ ! isFrequencyDisabled && isOneFrequencyActive }
/>
{ ! isFrequencyDisabled && (
<MoneyInput
currencySymbol={ currencySymbol }
label={ section.staticLabel }
value={ amounts[ section.key ][ 3 ] }
min={ minimumDonationFloat }
error={
amounts[ section.key ][ 3 ] < minimumDonationFloat
? __(
'Warning: suggested donations should be at least the minimum donation amount.',
'newspack'
)
: null
}
onChange={ changeHandler( [ 'amounts', section.key, 3 ] ) }
key={ section.key }
/>
) }
</Grid>
);
} ) }
</Grid>
</Card>
) }
Expand Down

0 comments on commit cb7eb7b

Please sign in to comment.