/** * External dependencies */ import { __, _x } from '@wordpress/i18n'; import { decodeEntities } from '@wordpress/html-entities'; import { applyFilters } from '@wordpress/hooks'; import { resolveSelect } from '@wordpress/data'; import { NAMESPACE, COUNTRIES_STORE_NAME } from '@woocommerce/data'; /** * Internal dependencies */ import { getCustomerLabels, getRequestByIdString, } from '../../../lib/async-requests'; const CUSTOMERS_REPORT_FILTERS_FILTER = 'woocommerce_admin_customers_report_filters'; const CUSTOMERS_REPORT_ADVANCED_FILTERS_FILTER = 'woocommerce_admin_customers_report_advanced_filters'; /** * @typedef {import('../index.js').filter} filter */ /** * Customers Report Filters. * * @filter woocommerce_admin_customers_report_filters * @param {Array.} filters Report filters. */ export const filters = applyFilters( CUSTOMERS_REPORT_FILTERS_FILTER, [ { label: __( 'Show', 'woocommerce' ), staticParams: [ 'paged', 'per_page' ], param: 'filter', showFilters: () => true, filters: [ { label: __( 'All Customers', 'woocommerce' ), value: 'all' }, { label: __( 'Single Customer', 'woocommerce' ), value: 'select_customer', chartMode: 'item-comparison', subFilters: [ { component: 'Search', value: 'single_customer', chartMode: 'item-comparison', path: [ 'select_customer' ], settings: { type: 'customers', param: 'customers', getLabels: getCustomerLabels, labels: { placeholder: __( 'Type to search for a customer', 'woocommerce' ), button: __( 'Single Customer', 'woocommerce' ), }, }, }, ], }, { label: __( 'Advanced filters', 'woocommerce' ), value: 'advanced', }, ], }, ] ); /*eslint-disable max-len*/ /** * Customers Report Advanced Filters. * * @filter woocommerce_admin_customers_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( CUSTOMERS_REPORT_ADVANCED_FILTERS_FILTER, { title: _x( 'Customers match