diff --git a/assets/js/src/subscribers/list.jsx b/assets/js/src/subscribers/list.jsx index 3ebbd39b4b..f8adcf54ab 100644 --- a/assets/js/src/subscribers/list.jsx +++ b/assets/js/src/subscribers/list.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Link } from 'react-router-dom'; +import { Link, useLocation } from 'react-router-dom'; import jQuery from 'jquery'; import MailPoet from 'mailpoet'; @@ -264,18 +264,20 @@ const itemActions = [ }, ]; -class SubscriberList extends React.Component { - getSegmentFromId = (segmentId) => { - let result = false; - window.mailpoet_segments.forEach((segment) => { - if (segment.id === segmentId) { - result = segment; - } - }); - return result; - }; +const getSegmentFromId = (segmentId) => { + let result = false; + window.mailpoet_segments.forEach((segment) => { + if (segment.id === segmentId) { + result = segment; + } + }); + return result; +}; - renderItem = (subscriber, actions) => { +const SubscriberList = ({ match }) => { + const location = useLocation(); + + const renderItem = (subscriber, actions) => { const rowClasses = classNames( 'manage-column', 'column-primary', @@ -318,7 +320,7 @@ class SubscriberList extends React.Component { const subscribedSegments = []; subscriber.subscriptions.forEach((subscription) => { - const segment = this.getSegmentFromId(subscription.segment_id); + const segment = getSegmentFromId(subscription.segment_id); if (segment === false) return; if (subscription.status === 'subscribed') { subscribedSegments.push(segment.name); @@ -338,7 +340,12 @@ class SubscriberList extends React.Component { { subscriber.email } @@ -363,70 +370,67 @@ class SubscriberList extends React.Component { ); }; - render() { - return ( -
-

- {MailPoet.I18n.t('pageTitle')} - {' '} - - {MailPoet.I18n.t('new')} - - - {MailPoet.I18n.t('import')} - - - {MailPoet.I18n.t('export')} - -

+ return ( +
+

+ {MailPoet.I18n.t('pageTitle')} + {' '} + + {MailPoet.I18n.t('new')} + + + {MailPoet.I18n.t('import')} + + + {MailPoet.I18n.t('export')} + +

- + - - + + - -
- ); - } -} + +
+ ); +}; SubscriberList.propTypes = { - location: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types match: PropTypes.shape({ params: PropTypes.object, // eslint-disable-line react/forbid-prop-types }).isRequired,