woocommerce/plugins/woocommerce-admin/client/marketing/data-multichannel/reducer.ts

62 lines
1.0 KiB
TypeScript
Raw Normal View History

/**
* External dependencies
*/
import type { Reducer } from 'redux';
/**
* Internal dependencies
*/
import { State } from './types';
import { Action } from './actions';
import { TYPES } from './action-types';
const initialState = {
channels: {
data: undefined,
error: undefined,
},
2023-01-19 11:33:51 +00:00
recommendedChannels: {
data: undefined,
error: undefined,
},
};
export const reducer: Reducer< State, Action > = (
state = initialState,
action
) => {
switch ( action.type ) {
case TYPES.RECEIVE_CHANNELS_SUCCESS:
return {
...state,
channels: {
data: action.payload,
},
};
case TYPES.RECEIVE_CHANNELS_ERROR:
return {
...state,
channels: {
error: action.payload,
},
};
2023-01-19 11:33:51 +00:00
case TYPES.RECEIVE_RECOMMENDED_CHANNELS_SUCCESS:
return {
...state,
recommendedChannels: {
data: action.payload,
},
};
case TYPES.RECEIVE_RECOMMENDED_CHANNELS_ERROR:
return {
...state,
recommendedChannels: {
error: action.payload,
},
};
default:
return state;
}
};