woocommerce/plugins/woocommerce-admin/client/store/notes/reducer.js

32 lines
577 B
JavaScript
Raw Normal View History

2018-10-11 23:33:18 +00:00
/** @format */
2018-10-12 19:20:48 +00:00
2018-10-16 19:46:00 +00:00
/**
* External dependencies
*/
import { merge } from 'lodash';
/**
* Internal dependencies
*/
import { ERROR } from 'store/constants';
import { getJsonString } from 'store/utils';
const DEFAULT_STATE = {};
2018-10-12 19:20:48 +00:00
export default function notesReducer( state = DEFAULT_STATE, action ) {
2018-10-16 19:46:00 +00:00
const queryKey = getJsonString( action.query );
2018-10-12 19:20:48 +00:00
switch ( action.type ) {
case 'SET_NOTES':
2018-10-16 19:46:00 +00:00
return merge( {}, state, {
[ queryKey ]: action.notes,
} );
case 'SET_NOTES_ERROR':
return merge( {}, state, {
[ queryKey ]: ERROR,
} );
2018-10-12 19:20:48 +00:00
}
return state;
}