reducers.js 659 Bytes
Newer Older
1
import {RECEIVE_COURSES_DETAIL, ADD_COURSES_TO_CART} from './actions'
xuzhenghua committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15

const initialState = {

}


export default function detailInfo(state = initialState, action) {
    switch (action.type) {
        case RECEIVE_COURSES_DETAIL:
            let courseInfo = action.payload
            return {
                ...state,
                ...courseInfo
            }
16 17 18 19 20 21
        case ADD_COURSES_TO_CART:
            const { course_info } = state;
            const obj = {
                course_info: Object.assign({}, course_info, {in_cart: true})
            };
            return Object.assign({}, state, obj);
xuzhenghua committed
22 23 24 25
        default:
            return state
    }
}