Reports: Update summary number label based on selected compare interval (https://github.com/woocommerce/woocommerce-admin/pull/506)

This commit is contained in:
Kelly Dwan 2018-10-11 13:46:56 -04:00 committed by GitHub
parent f8468ddcf4
commit 3d297a8f5c
1 changed files with 10 additions and 3 deletions

View File

@ -30,11 +30,12 @@ import { formatCurrency, getCurrencyFormatDecimal } from 'lib/currency';
import { getAdminLink, getNewPath, onQueryChange } from 'lib/nav-utils'; import { getAdminLink, getNewPath, onQueryChange } from 'lib/nav-utils';
import { getReportChartData } from 'store/reports/utils'; import { getReportChartData } from 'store/reports/utils';
import { import {
getCurrentDates,
getPreviousDate,
getIntervalForQuery,
getAllowedIntervalsForQuery, getAllowedIntervalsForQuery,
getCurrentDates,
getDateFormatsForInterval, getDateFormatsForInterval,
getDateParamsFromQuery,
getIntervalForQuery,
getPreviousDate,
} from 'lib/date'; } from 'lib/date';
import { MAX_PER_PAGE } from 'store/constants'; import { MAX_PER_PAGE } from 'store/constants';
@ -269,6 +270,7 @@ export class RevenueReport extends Component {
const totals = this.state.primaryTotals || {}; const totals = this.state.primaryTotals || {};
const secondaryTotals = this.state.secondaryTotals || {}; const secondaryTotals = this.state.secondaryTotals || {};
const { compare } = getDateParamsFromQuery( this.props.query );
const summaryNumbers = map( this.getCharts(), chart => { const summaryNumbers = map( this.getCharts(), chart => {
const { key, label, type } = chart; const { key, label, type } = chart;
@ -300,6 +302,11 @@ export class RevenueReport extends Component {
label={ label } label={ label }
selected={ isSelected } selected={ isSelected }
prevValue={ secondaryValue } prevValue={ secondaryValue }
prevLabel={
'previous_period' === compare
? __( 'Previous Period:', 'wc-admin' )
: __( 'Previous Year:', 'wc-admin' )
}
delta={ delta } delta={ delta }
href={ href } href={ href }
/> />