2018-10-11 23:33:18 +00:00
|
|
|
/** @format */
|
2018-10-16 19:46:00 +00:00
|
|
|
|
2018-10-12 19:20:48 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { dispatch } from '@wordpress/data';
|
|
|
|
import apiFetch from '@wordpress/api-fetch';
|
|
|
|
|
2018-10-16 19:46:00 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { stringifyQuery } from 'lib/nav-utils';
|
|
|
|
import { NAMESPACE } from 'store/constants';
|
|
|
|
|
2018-10-12 19:20:48 +00:00
|
|
|
export default {
|
2018-10-16 19:46:00 +00:00
|
|
|
async getNotes( state, query ) {
|
2018-10-12 19:20:48 +00:00
|
|
|
try {
|
2018-10-16 19:46:00 +00:00
|
|
|
const notes = await apiFetch( { path: NAMESPACE + 'admin/notes' + stringifyQuery( query ) } );
|
|
|
|
dispatch( 'wc-admin' ).setNotes( notes, query );
|
2018-10-12 19:20:48 +00:00
|
|
|
} catch ( error ) {
|
2018-10-16 19:46:00 +00:00
|
|
|
dispatch( 'wc-admin' ).setNotesError( query );
|
2018-10-12 19:20:48 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|