countryRedux.js 601 Bytes
Newer Older
zhanghaozhe committed
1 2
const ADD_COUNTRY_NUM = "ADD_COUNTRY_NUM"
const DEL_COUNTRY_NUM = "DEL_COUNTRY_NUM"
3 4

export const addCountryNum = (payload) => ({
zhanghaozhe committed
5 6 7
  type: "ADD_COUNTRY_NUM",
  payload,
})
8 9

export const delCountryNum = () => ({
zhanghaozhe committed
10 11
  type: "DEL_COUNTRY_NUM",
})
12

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