countryRedux.js 602 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
const ADD_COUNTRY_NUM = 'ADD_COUNTRY_NUM';
const DEL_COUNTRY_NUM = 'DEL_COUNTRY_NUM';

export const addCountryNum = (payload) => ({
  type: 'ADD_COUNTRY_NUM',
  payload
});

export const delCountryNum = () => ({
  type: 'DEL_COUNTRY_NUM'
});

zhanghaozhe committed
13
export default (state = {num: 86, code: null}, action) => {
14 15 16 17 18 19 20 21 22 23 24
  const { type, payload } = action;
  switch (type) {
    case ADD_COUNTRY_NUM:
      return {
        ...state,
        ...payload
      };
    case DEL_COUNTRY_NUM:
      return {
        ...state,
        num: '',
FE committed
25 26
        code: '',
        from: ''
27 28 29 30 31
      };
    default:
      return state;
  }
}