2020-07-02 02:33:10 +01:00
|
|
|
import {
|
|
|
|
SHOP_FEATURED_PRODUCTS_FETCH_REQUEST,
|
|
|
|
SHOP_FEATURED_PRODUCTS_FETCH_SUCCESS,
|
|
|
|
SHOP_FEATURED_PRODUCTS_FETCH_FAIL,
|
|
|
|
} from '../actions/shop'
|
|
|
|
import {
|
|
|
|
Map as ImmutableMap,
|
|
|
|
List as ImmutableList,
|
|
|
|
fromJS,
|
|
|
|
} from 'immutable'
|
|
|
|
|
|
|
|
const initialState = ImmutableMap({
|
|
|
|
featured: ImmutableMap({
|
2020-09-14 17:44:34 +01:00
|
|
|
items: [],
|
2020-07-02 02:33:10 +01:00
|
|
|
isError: false,
|
|
|
|
isLoading: false,
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
|
|
|
|
export default function suggestionsReducer(state = initialState, action) {
|
|
|
|
switch(action.type) {
|
|
|
|
case SHOP_FEATURED_PRODUCTS_FETCH_REQUEST:
|
|
|
|
return state.withMutations((map) => {
|
|
|
|
map.setIn([action.listType, 'isError'], false)
|
|
|
|
map.setIn([action.listType, 'isLoading'], true)
|
|
|
|
})
|
|
|
|
case SHOP_FEATURED_PRODUCTS_FETCH_SUCCESS:
|
|
|
|
return state.withMutations((map) => {
|
|
|
|
map.setIn([action.listType, 'items'], action.items)
|
|
|
|
map.setIn([action.listType, 'isError'], false)
|
|
|
|
map.setIn([action.listType, 'isLoading'], false)
|
|
|
|
})
|
|
|
|
case SHOP_FEATURED_PRODUCTS_FETCH_FAIL:
|
|
|
|
return state.withMutations((map) => {
|
|
|
|
map.setIn([action.listType, 'isError'], true)
|
|
|
|
map.setIn([action.listType, 'isLoading'], false)
|
|
|
|
})
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|