2018-10-16 17:42:13 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { Component, Fragment } from '@wordpress/element';
|
|
|
|
import { find } from 'lodash';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import ReportChart from 'analytics/components/report-chart';
|
|
|
|
import ReportSummary from 'analytics/components/report-summary';
|
|
|
|
|
2018-10-23 08:07:23 +00:00
|
|
|
class RevenueReportChart extends Component {
|
2018-10-16 17:42:13 +00:00
|
|
|
getCharts() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
key: 'gross_revenue',
|
|
|
|
label: __( 'Gross Revenue', 'wc-admin' ),
|
|
|
|
type: 'currency',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'refunds',
|
|
|
|
label: __( 'Refunds', 'wc-admin' ),
|
|
|
|
type: 'currency',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'coupons',
|
|
|
|
label: __( 'Coupons', 'wc-admin' ),
|
|
|
|
type: 'currency',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'taxes',
|
|
|
|
label: __( 'Taxes', 'wc-admin' ),
|
|
|
|
type: 'currency',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'shipping',
|
|
|
|
label: __( 'Shipping', 'wc-admin' ),
|
|
|
|
type: 'currency',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'net_revenue',
|
|
|
|
label: __( 'Net Revenue', 'wc-admin' ),
|
|
|
|
type: 'currency',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
getSelectedChart() {
|
|
|
|
const { query } = this.props;
|
|
|
|
const charts = this.getCharts();
|
|
|
|
const chart = find( charts, { key: query.chart } );
|
|
|
|
if ( chart ) {
|
|
|
|
return chart;
|
|
|
|
}
|
|
|
|
|
|
|
|
return charts[ 0 ];
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { query } = this.props;
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<ReportSummary
|
|
|
|
charts={ this.getCharts() }
|
|
|
|
endpoint="revenue"
|
|
|
|
query={ query }
|
|
|
|
selectedChart={ this.getSelectedChart() }
|
|
|
|
/>
|
|
|
|
<ReportChart
|
|
|
|
charts={ this.getCharts() }
|
|
|
|
endpoint="revenue"
|
|
|
|
query={ query }
|
|
|
|
selectedChart={ this.getSelectedChart() }
|
|
|
|
/>
|
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-23 08:07:23 +00:00
|
|
|
RevenueReportChart.propTypes = {
|
2018-10-16 17:42:13 +00:00
|
|
|
query: PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
|
2018-10-23 08:07:23 +00:00
|
|
|
export default RevenueReportChart;
|