2018-09-17 02:26:34 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2019-05-20 01:57:06 +00:00
|
|
|
import { applyFilters } from '@wordpress/hooks';
|
2018-09-17 02:26:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2019-01-24 09:35:27 +00:00
|
|
|
import { getCouponLabels } from 'lib/async-requests';
|
2018-09-17 02:26:34 +00:00
|
|
|
|
2019-05-20 01:57:06 +00:00
|
|
|
const COUPON_REPORT_CHART_FILTER = 'woocommerce_admin_coupon_report_chart_filter';
|
2019-08-23 16:41:42 +00:00
|
|
|
const COUPON_REPORT_FILTERS_FILTER = 'woocommerce_admin_coupon_report_filters';
|
2019-05-20 01:57:06 +00:00
|
|
|
|
|
|
|
export const charts = applyFilters( COUPON_REPORT_CHART_FILTER, [
|
2018-11-16 13:39:29 +00:00
|
|
|
{
|
2018-12-21 02:13:57 +00:00
|
|
|
key: 'orders_count',
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Discounted Orders', 'woocommerce-admin' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
order: 'desc',
|
|
|
|
orderby: 'orders_count',
|
2018-11-16 13:39:29 +00:00
|
|
|
type: 'number',
|
|
|
|
},
|
|
|
|
{
|
2018-12-21 02:13:57 +00:00
|
|
|
key: 'amount',
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Amount', 'woocommerce-admin' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
order: 'desc',
|
|
|
|
orderby: 'amount',
|
2018-11-16 13:39:29 +00:00
|
|
|
type: 'currency',
|
|
|
|
},
|
2019-05-20 01:57:06 +00:00
|
|
|
] );
|
2018-11-16 13:39:29 +00:00
|
|
|
|
2019-08-23 16:41:42 +00:00
|
|
|
export const filters = applyFilters( COUPON_REPORT_FILTERS_FILTER, [
|
2018-09-17 02:26:34 +00:00
|
|
|
{
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Show', 'woocommerce-admin' ),
|
2018-10-29 01:30:24 +00:00
|
|
|
staticParams: [],
|
|
|
|
param: 'filter',
|
|
|
|
showFilters: () => true,
|
|
|
|
filters: [
|
2019-03-13 17:14:02 +00:00
|
|
|
{ label: __( 'All Coupons', 'woocommerce-admin' ), value: 'all' },
|
2019-01-20 22:31:03 +00:00
|
|
|
{
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Single Coupon', 'woocommerce-admin' ),
|
2019-01-20 22:31:03 +00:00
|
|
|
value: 'select_coupon',
|
|
|
|
chartMode: 'item-comparison',
|
|
|
|
subFilters: [
|
|
|
|
{
|
|
|
|
component: 'Search',
|
|
|
|
value: 'single_coupon',
|
|
|
|
chartMode: 'item-comparison',
|
|
|
|
path: [ 'select_coupon' ],
|
|
|
|
settings: {
|
|
|
|
type: 'coupons',
|
|
|
|
param: 'coupons',
|
2019-01-24 09:35:27 +00:00
|
|
|
getLabels: getCouponLabels,
|
2019-01-20 22:31:03 +00:00
|
|
|
labels: {
|
2019-03-13 17:14:02 +00:00
|
|
|
placeholder: __( 'Type to search for a coupon', 'woocommerce-admin' ),
|
|
|
|
button: __( 'Single Coupon', 'woocommerce-admin' ),
|
2019-01-20 22:31:03 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-10-29 01:30:24 +00:00
|
|
|
{
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Comparison', 'woocommerce-admin' ),
|
2018-11-16 13:39:29 +00:00
|
|
|
value: 'compare-coupons',
|
2018-10-29 01:30:24 +00:00
|
|
|
settings: {
|
|
|
|
type: 'coupons',
|
2018-11-16 13:39:29 +00:00
|
|
|
param: 'coupons',
|
2019-01-24 09:35:27 +00:00
|
|
|
getLabels: getCouponLabels,
|
2018-10-29 01:30:24 +00:00
|
|
|
labels: {
|
2019-03-13 17:14:02 +00:00
|
|
|
title: __( 'Compare Coupon Codes', 'woocommerce-admin' ),
|
|
|
|
update: __( 'Compare', 'woocommerce-admin' ),
|
2019-03-15 01:00:48 +00:00
|
|
|
helpText: __( 'Check at least two coupon codes below to compare', 'woocommerce-admin' ),
|
2018-10-29 01:30:24 +00:00
|
|
|
},
|
|
|
|
},
|
2018-09-17 02:26:34 +00:00
|
|
|
},
|
2018-10-29 01:30:24 +00:00
|
|
|
],
|
2018-09-17 02:26:34 +00:00
|
|
|
},
|
2019-08-23 16:41:42 +00:00
|
|
|
] );
|