Fix React warnings

[MAILPOET-2678]
This commit is contained in:
Amine Ben hammou
2020-03-20 01:55:12 +01:00
committed by Veljko V
parent b738ad3809
commit eeefaa3a02
2 changed files with 16 additions and 14 deletions

View File

@@ -1,4 +1,6 @@
import React from 'react'; import React, { Fragment } from 'react';
import ReactStringReplace from 'react-string-replace';
import { t, onChange } from 'common/functions'; import { t, onChange } from 'common/functions';
import { Label, Inputs } from 'settings/components'; import { Label, Inputs } from 'settings/components';
import { useSetting } from 'settings/store/hooks'; import { useSetting } from 'settings/store/hooks';
@@ -8,15 +10,17 @@ export default function EmailContent() {
const [body, setBody] = useSetting('signup_confirmation', 'body'); const [body, setBody] = useSetting('signup_confirmation', 'body');
if (!enabled) return null; if (!enabled) return null;
const descriptionLines = t('emailContentDescription').split('<br />').filter((x) => x);
return ( return (
<> <>
<Label <Label
title={t('emailContent')} title={t('emailContent')}
description={t('emailContentDescription').split('<br />').map((line) => ( description={descriptionLines.map((line) => (
<> <span key={line}>
{line} {line}
<br /> <br />
</> <br />
</span>
))} ))}
htmlFor="signup_confirmation-body" htmlFor="signup_confirmation-body"
/> />

View File

@@ -1,20 +1,18 @@
import React from 'react'; import React from 'react';
import { t } from 'common/functions'; import { t, onChange } from 'common/functions';
import { Label, Inputs } from 'settings/components'; import { Label, Inputs } from 'settings/components';
import { useSelector, useSetting } from 'settings/store/hooks'; import { useSelector, useSetting } from 'settings/store/hooks';
export default function EnableSignupConfirmation() { export default function EnableSignupConfirmation() {
const isMssActive = useSelector('isMssActive')(); const isMssActive = useSelector('isMssActive')();
const [enabled, setEnabled] = useSetting('signup_confirmation', 'enabled'); const [enabled, setEnabled] = useSetting('signup_confirmation', 'enabled');
const enable = () => { const handleChange = (value: '1' | '') => {
// eslint-disable-next-line no-alert // eslint-disable-next-line no-alert
if (window.confirm(t('subscribersNeedToActivateSub'))) { if (value === '1' && window.confirm(t('subscribersNeedToActivateSub'))) {
setEnabled('1'); setEnabled('1');
} }
};
const disable = () => {
// eslint-disable-next-line no-alert // eslint-disable-next-line no-alert
if (window.confirm(t('newSubscribersAutoConfirmed'))) { if (value === '' && window.confirm(t('newSubscribersAutoConfirmed'))) {
setEnabled(''); setEnabled('');
} }
}; };
@@ -45,18 +43,18 @@ export default function EnableSignupConfirmation() {
<input <input
id="signup_confirmation-enabled" id="signup_confirmation-enabled"
type="radio" type="radio"
defaultChecked={enabled === '1'} checked={enabled === '1'}
value="1" value="1"
onClick={enable} onChange={onChange(handleChange)}
data-automation-id="enable_signup_confirmation" data-automation-id="enable_signup_confirmation"
/> />
{t('yes')} {t('yes')}
{' '} {' '}
<input <input
type="radio" type="radio"
defaultChecked={enabled === ''} checked={enabled === ''}
value="" value=""
onClick={disable} onChange={onChange(handleChange)}
data-automation-id="disable_signup_confirmation" data-automation-id="disable_signup_confirmation"
/> />
{t('no')} {t('no')}