
import { ROLE_CODE } from '@/constants/user'
import { fetch } from '@/utils/request'
import { API_REPORT_CUETOMER, API_USER_ADD_CUSTOMER, API_CHANNEL_REPORT } from '@/constants/api'

export default function getSubmitor(person) {
  const { personType } = person

  const builder = (url) => (payload) => fetch({ url, method: 'post', payload })
  let fn = () => undefined
  switch (personType) {
    case ROLE_CODE.CONSULTANT:
      fn = builder(API_REPORT_CUETOMER)
      break
    case ROLE_CODE.CHANNEL_AGENT:
      fn = builder(API_CHANNEL_REPORT)
      break
    case ROLE_CODE.CUSTOMER:
      fn = builder(API_USER_ADD_CUSTOMER)
      break
    default:
      break
  }
  
  return fn;
}
