Use React.useContext instead of Context.Consumer
This commit is contained in:
committed by
M. Shull
parent
a327d7f80a
commit
a49a6a6a65
@@ -8,69 +8,60 @@ function SelectImportMethod({
|
||||
activeMethod,
|
||||
onMethodChange,
|
||||
}) {
|
||||
const renderSelection = () => (
|
||||
<form className="mailpoet_import_selection_form">
|
||||
<span className="mailpoet_import_heading">{MailPoet.I18n.t('methodSelectionHead')}</span>
|
||||
<label htmlFor="import-paste-method">
|
||||
<input
|
||||
type="radio"
|
||||
name="select_method"
|
||||
data-automation-id="import-paste-method"
|
||||
id="import-paste-method"
|
||||
checked={activeMethod === 'paste-method'}
|
||||
onChange={() => onMethodChange('paste-method')}
|
||||
/>
|
||||
{MailPoet.I18n.t('methodPaste')}
|
||||
</label>
|
||||
<label htmlFor="import-csv-method">
|
||||
<input
|
||||
type="radio"
|
||||
name="select_method"
|
||||
data-automation-id="import-csv-method"
|
||||
id="import-csv-method"
|
||||
checked={activeMethod === 'file-method'}
|
||||
onChange={() => onMethodChange('file-method')}
|
||||
/>
|
||||
{MailPoet.I18n.t('methodUpload')}
|
||||
</label>
|
||||
<label htmlFor="import-mailchimp-method">
|
||||
<input
|
||||
type="radio"
|
||||
name="select_method"
|
||||
data-automation-id="import-mailchimp-method"
|
||||
id="import-mailchimp-method"
|
||||
checked={activeMethod === 'mailchimp-method'}
|
||||
onChange={() => onMethodChange('mailchimp-method')}
|
||||
/>
|
||||
{MailPoet.I18n.t('methodMailChimp')}
|
||||
</label>
|
||||
</form>
|
||||
const { isNewUser } = React.useContext(ImportContext);
|
||||
const badgeClasses = classNames(
|
||||
'mailpoet_badge',
|
||||
'mailpoet_badge_video',
|
||||
{ mailpoet_badge_video_grey: !isNewUser }
|
||||
);
|
||||
|
||||
return (
|
||||
<ImportContext.Consumer>
|
||||
{({ isNewUser }) => {
|
||||
const badgeClasses = classNames(
|
||||
'mailpoet_badge',
|
||||
'mailpoet_badge_video',
|
||||
{ mailpoet_badge_video_grey: !isNewUser }
|
||||
);
|
||||
return (
|
||||
<>
|
||||
{renderSelection()}
|
||||
<a
|
||||
className={badgeClasses}
|
||||
href="https://kb.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<span className="dashicons dashicons-format-video" />
|
||||
{MailPoet.I18n.t('seeVideo')}
|
||||
</a>
|
||||
</>
|
||||
);
|
||||
}}
|
||||
</ImportContext.Consumer>
|
||||
<>
|
||||
<form className="mailpoet_import_selection_form">
|
||||
<span className="mailpoet_import_heading">{MailPoet.I18n.t('methodSelectionHead')}</span>
|
||||
<label htmlFor="import-paste-method">
|
||||
<input
|
||||
type="radio"
|
||||
name="select_method"
|
||||
data-automation-id="import-paste-method"
|
||||
id="import-paste-method"
|
||||
checked={activeMethod === 'paste-method'}
|
||||
onChange={() => onMethodChange('paste-method')}
|
||||
/>
|
||||
{MailPoet.I18n.t('methodPaste')}
|
||||
</label>
|
||||
<label htmlFor="import-csv-method">
|
||||
<input
|
||||
type="radio"
|
||||
name="select_method"
|
||||
data-automation-id="import-csv-method"
|
||||
id="import-csv-method"
|
||||
checked={activeMethod === 'file-method'}
|
||||
onChange={() => onMethodChange('file-method')}
|
||||
/>
|
||||
{MailPoet.I18n.t('methodUpload')}
|
||||
</label>
|
||||
<label htmlFor="import-mailchimp-method">
|
||||
<input
|
||||
type="radio"
|
||||
name="select_method"
|
||||
data-automation-id="import-mailchimp-method"
|
||||
id="import-mailchimp-method"
|
||||
checked={activeMethod === 'mailchimp-method'}
|
||||
onChange={() => onMethodChange('mailchimp-method')}
|
||||
/>
|
||||
{MailPoet.I18n.t('methodMailChimp')}
|
||||
</label>
|
||||
</form>
|
||||
<a
|
||||
className={badgeClasses}
|
||||
href="https://kb.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<span className="dashicons dashicons-format-video" />
|
||||
{MailPoet.I18n.t('seeVideo')}
|
||||
</a>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user