/** * External dependencies */ import { parse, stringify } from 'qs'; import { DateRangeFilterPicker } from '@woocommerce/components'; import { useSettings } from '@woocommerce/data'; /** * Internal dependencies */ import { getCurrentDates, getDateParamsFromQuery, isoDateFormat, } from '../../lib/date'; const DefaultDate = ( { value, onChange } ) => { const { wcAdminSettings } = useSettings( 'wc_admin', [ 'wcAdminSettings', ] ); const { woocommerce_default_date_range: defaultDateRange, } = wcAdminSettings; const change = ( query ) => { onChange( { target: { name: 'woocommerce_default_date_range', value: stringify( query ), }, } ); }; const query = parse( value.replace( /&/g, '&' ) ); const { period, compare, before, after } = getDateParamsFromQuery( query, defaultDateRange ); const { primary: primaryDate, secondary: secondaryDate } = getCurrentDates( query, defaultDateRange ); const dateQuery = { period, compare, before, after, primaryDate, secondaryDate, }; return ( ); }; export default DefaultDate;