/** * External dependencies */ import { __, _x } from '@wordpress/i18n'; import { applyFilters } from '@wordpress/hooks'; import { dispatch } from '@wordpress/data'; import { STORE_KEY as CES_STORE_KEY } from '@woocommerce/customer-effort-score'; /** * Internal dependencies */ import { getCouponLabels } from '../../../lib/async-requests'; const COUPON_REPORT_CHARTS_FILTER = 'woocommerce_admin_coupons_report_charts'; const COUPON_REPORT_FILTERS_FILTER = 'woocommerce_admin_coupons_report_filters'; const COUPON_REPORT_ADVANCED_FILTERS_FILTER = 'woocommerce_admin_coupon_report_advanced_filters'; const { addCesSurveyForAnalytics } = dispatch( CES_STORE_KEY ); /** * @typedef {import('../index.js').chart} chart */ /** * Coupons Report charts filter. * * @filter woocommerce_admin_coupons_report_charts * @param {Array.} charts Report charts. */ export const charts = applyFilters( COUPON_REPORT_CHARTS_FILTER, [ { key: 'orders_count', label: __( 'Discounted orders', 'woocommerce' ), order: 'desc', orderby: 'orders_count', type: 'number', }, { key: 'amount', label: __( 'Amount', 'woocommerce' ), order: 'desc', orderby: 'amount', type: 'currency', }, ] ); /** * Coupons Report Advanced Filters. * * @filter woocommerce_admin_coupon_report_advanced_filters * @param {Object} advancedFilters Report Advanced Filters. * @param {string} advancedFilters.title Interpolated component string for Advanced Filters title. * @param {Object} advancedFilters.filters An object specifying a report's Advanced Filters. */ export const advancedFilters = applyFilters( COUPON_REPORT_ADVANCED_FILTERS_FILTER, { filters: {}, title: _x( 'Coupons match