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

33 lines
582 B
JavaScript
Raw Normal View History

/** @format */
/**
* External dependencies
*/
import { merge } from 'lodash';
/**
* Internal dependencies
*/
import { ERROR } from 'store/constants';
import { getJsonString } from 'store/utils';
const DEFAULT_STATE = {};
export default function ordersReducer( state = DEFAULT_STATE, action ) {
const queryKey = getJsonString( action.query );
switch ( action.type ) {
case 'SET_ORDERS':
return merge( {}, state, {
[ queryKey ]: action.orders,
} );
case 'SET_ORDERS_ERROR':
return merge( {}, state, {
[ queryKey ]: ERROR,
} );
}
return state;
}