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