-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b02093
commit 3244a02
Showing
4 changed files
with
98 additions
and
113 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
src/wizards/audience/components/cover-fees-settings/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { CheckboxControl } from '@wordpress/components'; | ||
import { useDispatch } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { | ||
ActionCard, | ||
Button, | ||
Grid, | ||
TextControl, | ||
Wizard, | ||
} from '../../../../components/src'; | ||
import { READER_REVENUE_WIZARD_SLUG } from '../../constants'; | ||
|
||
export const CoverFeesSettings = () => { | ||
const { additional_settings: settings = {} } = Wizard.useWizardData( 'reader-revenue' ); | ||
const { updateWizardSettings } = useDispatch( Wizard.STORE_NAMESPACE ); | ||
const changeHandler = ( key, value ) => | ||
updateWizardSettings( { | ||
slug: READER_REVENUE_WIZARD_SLUG, | ||
path: [ 'additional_settings', key ], | ||
value, | ||
} ); | ||
|
||
const { saveWizardSettings } = useDispatch( Wizard.STORE_NAMESPACE ); | ||
const onSave = () => | ||
saveWizardSettings( { | ||
slug: READER_REVENUE_WIZARD_SLUG, | ||
section: 'settings', | ||
payloadPath: [ 'additional_settings' ], | ||
} ); | ||
|
||
return ( | ||
<ActionCard | ||
isMedium | ||
title={ __( 'Collect transaction fees', 'newspack-plugin' ) } | ||
description={ __( 'Allow donors to optionally cover transaction fees imposed by payment processors.', 'newspack-plugin' ) } | ||
notificationLevel="info" | ||
toggleChecked={ settings.allow_covering_fees } | ||
toggleOnChange={ () => { | ||
changeHandler( 'allow_covering_fees', ! settings.allow_covering_fees ); | ||
onSave(); | ||
} } | ||
hasGreyHeader={ settings.allow_covering_fees } | ||
hasWhiteHeader={ ! settings.allow_covering_fees } | ||
actionContent={ settings.allow_covering_fees && ( | ||
<Button isPrimary onClick={ onSave }> | ||
{ __( 'Save Settings', 'newspack-plugin' ) } | ||
</Button> | ||
) } | ||
> | ||
{ settings.allow_covering_fees && ( | ||
<Grid noMargin rowGap={ 16 }> | ||
<TextControl | ||
type="number" | ||
step="0.1" | ||
value={ settings.fee_multiplier } | ||
label={ __( 'Fee multiplier', 'newspack-plugin' ) } | ||
onChange={ value => changeHandler( 'fee_multiplier', value ) } | ||
/> | ||
<TextControl | ||
type="number" | ||
step="0.1" | ||
value={ settings.fee_static } | ||
label={ __( 'Fee static portion', 'newspack-plugin' ) } | ||
onChange={ value => changeHandler( 'fee_static', value ) } | ||
/> | ||
<TextControl | ||
value={ settings.allow_covering_fees_label } | ||
label={ __( 'Custom message', 'newspack-plugin' ) } | ||
placeholder={ __( | ||
'A message to explain the transaction fee option (optional).', | ||
'newspack-plugin' | ||
) } | ||
onChange={ value => changeHandler( 'allow_covering_fees_label', value ) } | ||
/> | ||
<CheckboxControl | ||
label={ __( 'Cover fees by default', 'newspack-plugin' ) } | ||
checked={ settings.allow_covering_fees_default } | ||
onChange={ () => changeHandler( 'allow_covering_fees_default', ! settings.allow_covering_fees_default ) } | ||
help={ __( | ||
'If enabled, the option to cover the transaction fee will be checked by default.', | ||
'newspack-plugin' | ||
) } | ||
/> | ||
</Grid> | ||
) } | ||
</ActionCard> | ||
); | ||
} |
105 changes: 0 additions & 105 deletions
105
src/wizards/audience/components/payment-methods/additional-settings.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters