From 3d297a8f5c0ed1ed85c1c326b39ea3b6db16f79a Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Thu, 11 Oct 2018 13:46:56 -0400 Subject: [PATCH] Reports: Update summary number label based on selected compare interval (https://github.com/woocommerce/woocommerce-admin/pull/506) --- .../client/analytics/report/revenue/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/woocommerce-admin/client/analytics/report/revenue/index.js b/plugins/woocommerce-admin/client/analytics/report/revenue/index.js index 8ffdd0395fe..4674ebbb751 100644 --- a/plugins/woocommerce-admin/client/analytics/report/revenue/index.js +++ b/plugins/woocommerce-admin/client/analytics/report/revenue/index.js @@ -30,11 +30,12 @@ import { formatCurrency, getCurrencyFormatDecimal } from 'lib/currency'; import { getAdminLink, getNewPath, onQueryChange } from 'lib/nav-utils'; import { getReportChartData } from 'store/reports/utils'; import { - getCurrentDates, - getPreviousDate, - getIntervalForQuery, getAllowedIntervalsForQuery, + getCurrentDates, getDateFormatsForInterval, + getDateParamsFromQuery, + getIntervalForQuery, + getPreviousDate, } from 'lib/date'; import { MAX_PER_PAGE } from 'store/constants'; @@ -269,6 +270,7 @@ export class RevenueReport extends Component { const totals = this.state.primaryTotals || {}; const secondaryTotals = this.state.secondaryTotals || {}; + const { compare } = getDateParamsFromQuery( this.props.query ); const summaryNumbers = map( this.getCharts(), chart => { const { key, label, type } = chart; @@ -300,6 +302,11 @@ export class RevenueReport extends Component { label={ label } selected={ isSelected } prevValue={ secondaryValue } + prevLabel={ + 'previous_period' === compare + ? __( 'Previous Period:', 'wc-admin' ) + : __( 'Previous Year:', 'wc-admin' ) + } delta={ delta } href={ href } />