import {handleActions} from 'redux-actions';
import {combineReducer} from 'redux';

const contract = handleActions({
    ['FETCH_CONTRACT_ITEM'](state){
        return {...state, loading: true}
    },
    ['FETCH_CONTRACT_ITEM_SUCCESS'](state, action){
        return {...state, loading: false, trade: action.trade, shipping: action.shipping}
    },
    ['FETCH_CONTRACT_ITEM_FAILED'](state, action){
        return {...state, err: action.err, loading: false, trade: null, shipping: null}
    },
    ['UPDATE_CONTRACT_ITEM'](state){
        return {...state, loading: true}
    },
    ['UPDATE_CONTRACT_ITEM_SUCCESS'](state, action){
        return {...state, loading: false, shipping: action.shipping}
    },
    ['UPDATE_CONTRACT_ITEM_FAILED'](state, action){
        return {...state, err: action.err, loading: false}
    }
}, {
    loading: false,
});

export default contract;
