woocommerce/plugins/woocommerce-admin/client/analytics/settings/default-date.js

25 lines
548 B
JavaScript
Raw Normal View History

2019-05-22 21:43:04 +00:00
/** @format */
/**
* External dependencies
*/
import { parse, stringify } from 'qs';
/**
* WooCommerce dependencies
*/
import { DateRangeFilterPicker } from '@woocommerce/components';
const DefaultDate = ( { value, onChange } ) => {
const change = query => {
onChange( {
target: {
name: 'woocommerce_default_date_range',
value: stringify( query ),
},
} );
};
const query = parse( value.replace( /&/g, '&' ) );
return <DateRangeFilterPicker query={ query } onRangeSelect={ change } />;
};
export default DefaultDate;