Refactor components
This commit is contained in:
committed by
M. Shull
parent
ebe22aa98e
commit
7ddffb4dd5
@@ -7,46 +7,40 @@ import ReactStringReplace from 'react-string-replace';
|
|||||||
const userHostDomain = window.location.hostname.replace('www.', '');
|
const userHostDomain = window.location.hostname.replace('www.', '');
|
||||||
const suggestedEmailAddress = `contact@${userHostDomain}`;
|
const suggestedEmailAddress = `contact@${userHostDomain}`;
|
||||||
|
|
||||||
const OldInstallationWarning = ({ emailAddress }) => (
|
|
||||||
<React.Fragment>
|
|
||||||
<p
|
|
||||||
className="sender_email_address_warning"
|
|
||||||
data-acceptance-id="freemail-sender-warning-old-installation"
|
|
||||||
>
|
|
||||||
{MailPoet.I18n.t('senderEmailAddressWarning1')}
|
|
||||||
</p>
|
|
||||||
<p className="sender_email_address_warning">
|
|
||||||
{ReactStringReplace(
|
|
||||||
MailPoet.I18n.t('senderEmailAddressWarning2'),
|
|
||||||
/(%suggested|%originalSender|<em>.*<\/em>)/,
|
|
||||||
(match) => {
|
|
||||||
if (match === '%suggested') return suggestedEmailAddress;
|
|
||||||
if (match === '%originalSender') return <em key="sender-email">{ emailAddress }</em>;
|
|
||||||
return <em key="reply-to">{match.replace(/<\/?em>/g, '')}</em>;
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
<p className="sender_email_address_warning">
|
|
||||||
<a
|
|
||||||
href="https://kb.mailpoet.com/article/259-your-from-address-cannot-be-yahoo-com-gmail-com-outlook-com"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
{MailPoet.I18n.t('senderEmailAddressWarning3')}
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
|
|
||||||
OldInstallationWarning.propTypes = {
|
|
||||||
emailAddress: PropTypes.string.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
const SenderEmailAddressWarning = ({ emailAddress, mssActive }) => {
|
const SenderEmailAddressWarning = ({ emailAddress, mssActive }) => {
|
||||||
if (mssActive) return null
|
if (mssActive) return null
|
||||||
const emailAddressDomain = emailAddress.split('@').pop().toLowerCase();
|
const emailAddressDomain = emailAddress.split('@').pop().toLowerCase();
|
||||||
if (window.mailpoet_free_domains.indexOf(emailAddressDomain) > -1) {
|
if (window.mailpoet_free_domains.indexOf(emailAddressDomain) > -1) {
|
||||||
return <OldInstallationWarning emailAddress={emailAddress} />;
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<p
|
||||||
|
className="sender_email_address_warning"
|
||||||
|
data-acceptance-id="freemail-sender-warning-old-installation"
|
||||||
|
>
|
||||||
|
{MailPoet.I18n.t('senderEmailAddressWarning1')}
|
||||||
|
</p>
|
||||||
|
<p className="sender_email_address_warning">
|
||||||
|
{ReactStringReplace(
|
||||||
|
MailPoet.I18n.t('senderEmailAddressWarning2'),
|
||||||
|
/(%suggested|%originalSender|<em>.*<\/em>)/,
|
||||||
|
(match) => {
|
||||||
|
if (match === '%suggested') return suggestedEmailAddress;
|
||||||
|
if (match === '%originalSender') return <em key="sender-email">{ emailAddress }</em>;
|
||||||
|
return <em key="reply-to">{match.replace(/<\/?em>/g, '')}</em>;
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<p className="sender_email_address_warning">
|
||||||
|
<a
|
||||||
|
href="https://kb.mailpoet.com/article/259-your-from-address-cannot-be-yahoo-com-gmail-com-outlook-com"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
{MailPoet.I18n.t('senderEmailAddressWarning3')}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user