import apis from '../../config/api'
import request from '../../utils/request'

export default {
  namespaced: true,
  state: {
    list: [],
    detail: {},
  },
  mutations: {},
  actions: {
    getConsultants (context, payload) {
      return request({
        ...apis.consultant.list,
        params: payload,
      })
    },
    getConsultant (context, payload) {
      return request({
        ...apis.consultant.detail,
        urlData: payload,
      })
    },
    editConsultant (context, payload) {
      window.console.log(payload)

      const config = payload.personId ?
        {
          ...apis.consultant.edit,
          urlData: { id: payload.personId },
          data: payload,
        } :
        {
          ...apis.consultant.add,
          data: payload,
        }

      return request(config)
    },
  },
}