2018-08-02 21:27:27 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
|
2018-09-11 07:58:11 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2018-09-17 02:26:34 +00:00
|
|
|
import { getRequestByIdString } from 'lib/async-requests';
|
|
|
|
import { NAMESPACE } from 'store/constants';
|
2018-09-11 07:58:11 +00:00
|
|
|
|
2018-09-19 21:14:52 +00:00
|
|
|
const { orderStatuses } = wcSettings;
|
|
|
|
|
2018-08-02 21:27:27 +00:00
|
|
|
export const filters = [
|
|
|
|
{ label: __( 'All Orders', 'wc-admin' ), value: 'all' },
|
|
|
|
{
|
|
|
|
label: __( 'Single Order', 'wc-admin' ),
|
|
|
|
value: 'single',
|
|
|
|
subFilters: [
|
|
|
|
{
|
|
|
|
component: 'Search',
|
|
|
|
value: 'single_order',
|
2018-08-22 20:20:19 +00:00
|
|
|
path: [ 'single' ],
|
2018-08-02 21:27:27 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{ label: __( 'Top Orders by Items Sold', 'wc-admin' ), value: 'top_items' },
|
|
|
|
{ label: __( 'Top Orders by Gross Sales', 'wc-admin' ), value: 'top_sales' },
|
|
|
|
{ label: __( 'Advanced Filters', 'wc-admin' ), value: 'advanced' },
|
|
|
|
];
|
|
|
|
|
|
|
|
export const advancedFilterConfig = {
|
|
|
|
status: {
|
2018-09-19 17:23:57 +00:00
|
|
|
labels: {
|
|
|
|
add: __( 'Order Status', 'wc-admin' ),
|
|
|
|
remove: __( 'Remove order status filter', 'wc-admin' ),
|
|
|
|
rule: __( 'Select an order status filter match', 'wc-admin' ),
|
|
|
|
title: __( 'Order Status', 'wc-admin' ),
|
|
|
|
},
|
2018-08-02 21:27:27 +00:00
|
|
|
rules: [
|
|
|
|
{ value: 'is', label: __( 'Is', 'wc-admin' ) },
|
2018-09-03 02:08:13 +00:00
|
|
|
{ value: 'is_not', label: __( 'Is Not', 'wc-admin' ) },
|
2018-08-02 21:27:27 +00:00
|
|
|
],
|
|
|
|
input: {
|
|
|
|
component: 'SelectControl',
|
2018-09-19 21:14:52 +00:00
|
|
|
options: Object.keys( orderStatuses ).map( key => ( {
|
|
|
|
value: key,
|
|
|
|
label: orderStatuses[ key ],
|
|
|
|
} ) ),
|
|
|
|
defaultOption: 'wc-cancelled',
|
2018-08-02 21:27:27 +00:00
|
|
|
},
|
|
|
|
},
|
2018-09-03 02:08:13 +00:00
|
|
|
product_id: {
|
2018-09-19 17:23:57 +00:00
|
|
|
labels: {
|
|
|
|
add: __( 'Products', 'wc-admin' ),
|
|
|
|
placeholder: __( 'Search products', 'wc-admin' ),
|
|
|
|
remove: __( 'Remove products filter', 'wc-admin' ),
|
|
|
|
rule: __( 'Select a product filter match', 'wc-admin' ),
|
|
|
|
title: __( 'Product', 'wc-admin' ),
|
|
|
|
},
|
2018-08-02 21:27:27 +00:00
|
|
|
rules: [
|
|
|
|
{ value: 'includes', label: __( 'Includes', 'wc-admin' ) },
|
|
|
|
{ value: 'excludes', label: __( 'Excludes', 'wc-admin' ) },
|
|
|
|
{ value: 'is', label: __( 'Is', 'wc-admin' ) },
|
2018-09-03 02:08:13 +00:00
|
|
|
{ value: 'is_not', label: __( 'Is Not', 'wc-admin' ) },
|
2018-08-02 21:27:27 +00:00
|
|
|
],
|
|
|
|
input: {
|
2018-09-03 02:08:13 +00:00
|
|
|
component: 'Search',
|
|
|
|
type: 'products',
|
2018-09-17 02:26:34 +00:00
|
|
|
getLabels: getRequestByIdString( NAMESPACE + 'products', product => ( {
|
|
|
|
id: product.id,
|
|
|
|
label: product.name,
|
|
|
|
} ) ),
|
2018-08-02 21:27:27 +00:00
|
|
|
},
|
|
|
|
},
|
2018-09-03 02:08:13 +00:00
|
|
|
code: {
|
2018-09-19 17:23:57 +00:00
|
|
|
labels: {
|
|
|
|
add: __( 'Coupon Codes', 'wc-admin' ),
|
|
|
|
placeholder: __( 'Search coupons', 'wc-admin' ),
|
|
|
|
remove: __( 'Remove coupon filter', 'wc-admin' ),
|
|
|
|
rule: __( 'Select a coupon filter match', 'wc-admin' ),
|
|
|
|
title: __( 'Coupon Code', 'wc-admin' ),
|
|
|
|
},
|
2018-08-02 21:27:27 +00:00
|
|
|
rules: [
|
|
|
|
{ value: 'includes', label: __( 'Includes', 'wc-admin' ) },
|
|
|
|
{ value: 'excludes', label: __( 'Excludes', 'wc-admin' ) },
|
|
|
|
{ value: 'is', label: __( 'Is', 'wc-admin' ) },
|
2018-09-03 02:08:13 +00:00
|
|
|
{ value: 'is_not', label: __( 'Is Not', 'wc-admin' ) },
|
2018-08-02 21:27:27 +00:00
|
|
|
],
|
|
|
|
input: {
|
2018-09-03 02:08:13 +00:00
|
|
|
component: 'Search',
|
2018-09-17 02:26:34 +00:00
|
|
|
type: 'coupons',
|
|
|
|
getLabels: getRequestByIdString( NAMESPACE + 'coupons', coupon => ( {
|
|
|
|
id: coupon.id,
|
|
|
|
label: coupon.code,
|
|
|
|
} ) ),
|
2018-08-02 21:27:27 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
customer: {
|
2018-09-19 17:23:57 +00:00
|
|
|
labels: {
|
|
|
|
add: __( 'Customer Type', 'wc-admin' ),
|
|
|
|
remove: __( 'Remove customer filter', 'wc-admin' ),
|
|
|
|
rule: __( 'Select a customer filter match', 'wc-admin' ),
|
|
|
|
title: __( 'Customer is', 'wc-admin' ),
|
|
|
|
},
|
2018-09-03 02:08:13 +00:00
|
|
|
input: {
|
|
|
|
component: 'SelectControl',
|
|
|
|
options: [
|
|
|
|
{ value: 'new', label: __( 'New', 'wc-admin' ) },
|
|
|
|
{ value: 'returning', label: __( 'Returning', 'wc-admin' ) },
|
|
|
|
],
|
2018-09-19 21:14:52 +00:00
|
|
|
defaultOption: 'new',
|
2018-09-03 02:08:13 +00:00
|
|
|
},
|
2018-08-02 21:27:27 +00:00
|
|
|
},
|
|
|
|
};
|