import request from '@/utils/request'

export function sendVerifyCode(param) {
  return request({
    url: '/TrialSiteSurvey/sendVerifyCode',
    method: 'post',
    data: param
  })
}

export function verifySendCode(param) {
  return request({
    url: '/TrialSiteSurvey/verifySendCode',
    method: 'post',
    data: param
  })
}

export function getTrialSurveyInitInfo(trialId) {
  return request({
    url: `/TrialSiteSurvey/getTrialSurveyInitInfo/${trialId}`,
    method: 'get'
  })
}

export function getSiteSurveyInfo(trialId, id) {
  return request({
    url: `/TrialSiteSurvey/getSiteSurveyInfo/${trialId}/${id}`,
    method: 'get'
  })
}

export function addOrUpdateTrialSiteSurvey(param) {
  return request({
    url: '/TrialSiteSurvey/addOrUpdateTrialSiteSurvey',
    method: 'post',
    data: param
  })
}

export function getTrialSiteUserSurveyList(trialSiteSurveyId) {
  return request({
    url: `/TrialSiteUserSurvey/getTrialSiteUserSurveyList/${trialSiteSurveyId}`,
    method: 'get'
  })
}

export function addOrUpdateTrialSiteUserSurvey(trialId, param) {
  return request({
    url: `/TrialSiteUserSurvey/addOrUpdateTrialSiteUserSurvey/${trialId}`,
    method: 'post',
    data: param
  })
}

export function deleteTrialSiteUserSurvey(trialSiteUserSurveyId, trialId) {
  return request({
    url: `/TrialSiteUserSurvey/deleteTrialSiteUserSurvey/${trialSiteUserSurveyId}/${trialId}`,
    method: 'delete'
  })
}

export function getTrialSiteEquipmentSurveyList(trialSiteSurveyId) {
  return request({
    url: `/TrialSiteEquipmentSurvey/getTrialSiteEquipmentSurveyList/${trialSiteSurveyId}`,
    method: 'get'
  })
}

export function addOrUpdateTrialSiteEquipmentSurvey(trialId, param) {
  return request({
    url: `/TrialSiteEquipmentSurvey/addOrUpdateTrialSiteEquipmentSurvey/${trialId}`,
    method: 'post',
    data: param
  })
}
export function deleteTrialSiteEquipmentSurvey(trialSiteEquipmentSurveyId, trialId) {
  return request({
    url: `/TrialSiteEquipmentSurvey/deleteTrialSiteEquipmentSurvey/${trialSiteEquipmentSurveyId}/${trialId}`,
    method: 'delete'
  })
}

// export function trialSurveySubmmit(trialId, trialSiteSurveyId) {
//   const loginUrl = `${location.protocol}//${location.host}/#/login`
//   const joinUrl = `${location.protocol}//${location.host}/#/joinVerify`
//   return request({
//     url: `/TrialSiteSurvey/trialSurveySubmit/${trialId}/${trialSiteSurveyId}/${loginUrl}/${joinUrl}`,
//     method: 'put'
//   })
// }

export function trialSurveySubmit(param) {
  return request({
    url: `/TrialSiteSurvey/trialSurveySubmit`,
    method: 'post',
    data: param
  })
}
export function submissionRejection(param) {
  return request({
    url: `/TrialSiteSurvey/submissionRejection`,
    method: 'post',
    data: param
  })
}

export function trialSurveyLock(trialSiteSurveyId, trialId, isLock) {
  return request({
    url: `/TrialSiteSurvey/trialSurveyLock/${trialSiteSurveyId}/${trialId}/${isLock}`,
    method: 'post'
  })
}

export function getUserTypeList(userTypeEnum) {
  return request({
    url: `/UserTypeRole/getUserTypeList/${userTypeEnum}`,
    method: 'get'
  })
}
