import * as actionTypes from './action-types';

let defaultState = {
  orderSum: '', //金额
  name: '1', //姓名
  phoneNo: '', //手机号
  imgpath: '', //图片地址
}
// 首页表单数据
//state+action=newstate
export const formData = (state = defaultState, action = {}) => {
  switch (action.type) {
    case actionTypes.SAVEFORMDATA:
      return { ...state, ...{ [action.datatype]: action.value } };
    case actionTypes.SAVEIMG:
      return { ...state, ...{ imgpath: action.path } };
    case actionTypes.CLEARDATA:
      return { ...state, ...defaultState };
    default:
      return state;
  }
}