2018-07-05 03:14:40 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { dispatch } from '@wordpress/data';
|
2018-08-21 19:02:49 +00:00
|
|
|
import apiFetch from '@wordpress/api-fetch';
|
2018-07-05 03:14:40 +00:00
|
|
|
|
2018-10-16 08:50:07 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { stringifyQuery } from 'lib/nav-utils';
|
|
|
|
import { NAMESPACE } from 'store/constants';
|
|
|
|
|
2018-07-05 03:14:40 +00:00
|
|
|
export default {
|
2018-10-16 08:50:07 +00:00
|
|
|
async getOrders( state, query ) {
|
2018-07-05 03:14:40 +00:00
|
|
|
try {
|
2018-10-16 08:50:07 +00:00
|
|
|
const orders = await apiFetch( { path: NAMESPACE + 'orders' + stringifyQuery( query ) } );
|
|
|
|
dispatch( 'wc-admin' ).setOrders( orders, query );
|
2018-07-05 03:14:40 +00:00
|
|
|
} catch ( error ) {
|
2018-10-16 08:50:07 +00:00
|
|
|
dispatch( 'wc-admin' ).setOrdersError( query );
|
2018-07-05 03:14:40 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|