Update code after react replace string upgrade

[MAILPOET-3724]
This commit is contained in:
Pavel Dohnal
2021-09-24 13:59:51 +02:00
committed by Veljko V
parent a7153d71b6
commit 72b018355b

View File

@@ -1,5 +1,4 @@
import React, { useEffect } from 'react';
import ReactStringReplace from 'react-string-replace';
import { useSelect, useDispatch } from '@wordpress/data';
import { Grid } from 'common/grid';
@@ -17,6 +16,12 @@ function replaceElementsInDaysSentence(fn): JSX.Element[] {
.map(fn);
}
function replaceEmailActionOpensSentence(fn): JSX.Element[] {
return MailPoet.I18n.t('emailActionOpensSentence')
.split(/({condition})|({opens})|(\b[a-zA-Z]+\b)/gim)
.map(fn);
}
type Props = {
filterIndex: number;
}
@@ -37,10 +42,7 @@ export const EmailOpensAbsoluteCountFields: React.FunctionComponent<Props> = ({
return (
<>
<Grid.CenteredRow>
{ReactStringReplace(
MailPoet.I18n.t('emailActionOpensSentence'),
// ReactStringReplace is buggy, a simpler version of this regex doesn't work
/({condition})|( )|({opens})|( )|(\b[a-zA-Z]+\b)/gim,
{replaceEmailActionOpensSentence(
(match) => {
if (match === '{condition}') {
return (