2023-01-17 18:04:42 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
import type { Reducer } from 'redux';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { State } from './types';
|
|
|
|
import { Action } from './actions';
|
|
|
|
import { TYPES } from './action-types';
|
|
|
|
|
|
|
|
const initialState = {
|
2023-01-31 16:52:35 +00:00
|
|
|
registeredChannels: {
|
2023-01-17 18:04:42 +00:00
|
|
|
data: undefined,
|
|
|
|
error: undefined,
|
|
|
|
},
|
2023-01-19 11:33:51 +00:00
|
|
|
recommendedChannels: {
|
|
|
|
data: undefined,
|
|
|
|
error: undefined,
|
|
|
|
},
|
2023-01-17 18:04:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const reducer: Reducer< State, Action > = (
|
|
|
|
state = initialState,
|
|
|
|
action
|
|
|
|
) => {
|
|
|
|
switch ( action.type ) {
|
2023-01-31 16:52:35 +00:00
|
|
|
case TYPES.RECEIVE_REGISTERED_CHANNELS_SUCCESS:
|
2023-01-17 18:04:42 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2023-01-31 16:52:35 +00:00
|
|
|
registeredChannels: {
|
2023-01-17 18:04:42 +00:00
|
|
|
data: action.payload,
|
|
|
|
},
|
|
|
|
};
|
2023-01-31 16:52:35 +00:00
|
|
|
case TYPES.RECEIVE_REGISTERED_CHANNELS_ERROR:
|
2023-01-17 18:04:42 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2023-01-31 16:52:35 +00:00
|
|
|
registeredChannels: {
|
2023-01-17 18:04:42 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
};
|
2023-01-17 18:04:42 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|