33 lines
586 B
JavaScript
33 lines
586 B
JavaScript
/** @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 couponsReducer( state = DEFAULT_STATE, action ) {
|
|
const queryKey = getJsonString( action.query );
|
|
|
|
switch ( action.type ) {
|
|
case 'SET_COUPONS':
|
|
return merge( {}, state, {
|
|
[ queryKey ]: action.coupons,
|
|
} );
|
|
|
|
case 'SET_COUPONS_ERROR':
|
|
return merge( {}, state, {
|
|
[ queryKey ]: ERROR,
|
|
} );
|
|
}
|
|
|
|
return state;
|
|
}
|