Add score to stats page

[MAILPOET-3525]
This commit is contained in:
Pavel Dohnal
2021-04-21 12:21:02 +02:00
committed by Veljko V
parent 8e1103465e
commit 74f9505772
3 changed files with 26 additions and 1 deletions

View File

@ -17,6 +17,7 @@ export type StatsType = {
total_sent: number;
open: number;
click: number;
engagement_score: number;
woocommerce: {
currency: string;
value: number;
@ -68,6 +69,10 @@ export const SubscriberStats: React.FunctionComponent = () => {
click={stats.click}
open={stats.open}
totalSent={stats.total_sent}
subscriber={{
id: match.params.id,
engagement_score: stats.engagement_score,
}}
/>
{stats.woocommerce && (
<WoocommerceRevenues

View File

@ -1,14 +1,24 @@
import React from 'react';
import MailPoet from 'mailpoet';
import Tag from 'common/tag/tag';
import { ListingsEngagementScore } from '../listings_engagement_score';
export type PropTypes = {
totalSent: number;
open: number;
click: number;
subscriber: {
id: string;
engagement_score?: number;
};
}
export default ({ totalSent, open, click }: PropTypes): JSX.Element => {
export default ({
totalSent,
open,
click,
subscriber,
}: PropTypes): JSX.Element => {
let openPercent = 0;
let clickPercent = 0;
let notOpenPercent = 0;
@ -71,6 +81,15 @@ export default ({ totalSent, open, click }: PropTypes): JSX.Element => {
)}
</td>
</tr>
<tr>
<td>{MailPoet.I18n.t('statisticsColumn')}</td>
<td>
<div className="mailpoet-listing-stats">
<ListingsEngagementScore subscriber={subscriber} />
</div>
</td>
<td />
</tr>
</tbody>
</table>
</div>

View File

@ -45,6 +45,7 @@ class SubscriberStats extends APIEndpoint {
'total_sent' => $statistics->getTotalSentCount(),
'open' => $statistics->getOpenCount(),
'click' => $statistics->getClickCount(),
'engagement_score' => $subscriber->getEngagementScore(),
];
$woocommerce = $statistics->getWooCommerceRevenue();
if ($woocommerce instanceof WooCommerceRevenue) {