index.js 859 Bytes
Newer Older
zhanghaozhe committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
export const ADD_MESSAGE = 'ADD_MESSAGE'
export const ADD_RESULT = 'ADD_RESULT'
export const RESELECT = 'RESELECT'

export const addMessage = payload => {
  return {
    type: ADD_MESSAGE,
    payload,
  }
}

export const addResult = payload => {
  return {
    type: ADD_RESULT,
    payload,
  }
}

export const reselect = () => {
  return {
    type: RESELECT
  }
}

const initialState = {
  processing: [],
  result: {},
}

export default function intelligentRecommend(state = initialState, action) {
  switch (action.type) {
    case ADD_MESSAGE:
      return {
        processing: [...state.processing, action.payload],
        result: state.result,
      }
    case ADD_RESULT:
      return {
        processing: state.processing,
        result: action.payload,
      }
    case RESELECT:
      return initialState
    default:
      return state
  }
}