From f167c27b5e8dc2961bdd9cce01dd1f0b5600add8 Mon Sep 17 00:00:00 2001 From: Jonathan Belcher Date: Fri, 16 Nov 2018 08:39:29 -0500 Subject: [PATCH] Adds UI wiring for Coupons chart and summary (https://github.com/woocommerce/woocommerce-admin/pull/724) * Adds UI wiring for Coupons chart and summary * Update for changes in master * Update to use current method * Remove accidental paste * Fix typo * Seperate WooCommerce deps --- .../client/analytics/report/coupons/config.js | 52 ++++++++++++++++++- .../client/analytics/report/coupons/index.js | 31 +++++++++-- plugins/woocommerce-admin/lib/admin.php | 8 +++ 3 files changed, 86 insertions(+), 5 deletions(-) diff --git a/plugins/woocommerce-admin/client/analytics/report/coupons/config.js b/plugins/woocommerce-admin/client/analytics/report/coupons/config.js index 5fb8d7bbf3e..ff5adcd4954 100644 --- a/plugins/woocommerce-admin/client/analytics/report/coupons/config.js +++ b/plugins/woocommerce-admin/client/analytics/report/coupons/config.js @@ -10,6 +10,54 @@ import { __ } from '@wordpress/i18n'; import { getRequestByIdString } from 'lib/async-requests'; import { NAMESPACE } from 'store/constants'; +export const charts = [ + { + key: 'avg_items_per_order', + label: __( 'Average Items Per Order', 'wc-admin' ), + type: 'number', + }, + { + key: 'avg_order_value', + label: __( 'Average Order Value', 'wc-admin' ), + type: 'currency', + }, + { + key: 'coupons', + label: __( 'Coupons', 'wc-admin' ), + type: 'number', + }, + { + key: 'net_revenue', + label: __( 'Net Revenue', 'wc-admin' ), + type: 'currency', + }, + { + key: 'num_items_sold', + label: __( 'Number of Items Sold', 'wc-admin' ), + type: 'number', + }, + { + key: 'num_new_customers', + label: __( 'Number of New Customers', 'wc-admin' ), + type: 'number', + }, + { + key: 'num_returning_customers', + label: __( 'Number of Returning Customers', 'wc-admin' ), + type: 'number', + }, + { + key: 'orders_count', + label: __( 'Orders Count', 'wc-admin' ), + type: 'number', + }, + { + key: 'products', + label: __( 'Products', 'wc-admin' ), + type: 'number', + }, +]; + export const filters = [ { label: __( 'Show', 'wc-admin' ), @@ -20,10 +68,10 @@ export const filters = [ { label: __( 'All Coupons', 'wc-admin' ), value: 'all' }, { label: __( 'Comparison', 'wc-admin' ), - value: 'compare', + value: 'compare-coupons', settings: { type: 'coupons', - param: 'coupon', + param: 'coupons', getLabels: getRequestByIdString( NAMESPACE + 'coupons', coupon => ( { id: coupon.id, label: coupon.code, diff --git a/plugins/woocommerce-admin/client/analytics/report/coupons/index.js b/plugins/woocommerce-admin/client/analytics/report/coupons/index.js index 688d621d844..0078c34c5a0 100644 --- a/plugins/woocommerce-admin/client/analytics/report/coupons/index.js +++ b/plugins/woocommerce-admin/client/analytics/report/coupons/index.js @@ -3,23 +3,48 @@ * External dependencies */ import { Component, Fragment } from '@wordpress/element'; +import PropTypes from 'prop-types'; + +/** + * WooCommerce dependencies + */ +import { ReportFilters } from '@woocommerce/components'; /** * Internal dependencies */ -import { filters } from './config'; +import { charts, filters } from './config'; import CouponsReportTable from './table'; -import { ReportFilters } from '@woocommerce/components'; +import getSelectedChart from 'lib/get-selected-chart'; +import ReportChart from 'analytics/components/report-chart'; +import ReportSummary from 'analytics/components/report-summary'; -export default class extends Component { +export default class CouponsReport extends Component { render() { const { query, path } = this.props; return ( + + ); } } + +CouponsReport.propTypes = { + query: PropTypes.object.isRequired, +}; diff --git a/plugins/woocommerce-admin/lib/admin.php b/plugins/woocommerce-admin/lib/admin.php index ecdbf030416..41d9c6fc632 100644 --- a/plugins/woocommerce-admin/lib/admin.php +++ b/plugins/woocommerce-admin/lib/admin.php @@ -125,6 +125,14 @@ function wc_admin_register_pages() { ) ); + wc_admin_register_page( + array( + 'title' => __( 'Coupons', 'wc-admin' ), + 'parent' => '/analytics/revenue', + 'path' => '/analytics/coupons', + ) + ); + wc_admin_register_page( array( 'title' => __( 'Categories', 'wc-admin' ),