import api from 'src/api'

export const updateScheduleStatus = async (id, status) => {
  const { data } = await api.patch(`/schedule/${id}/status`, { status })
  return data.payload
}

export const cancelSchedule = async (id, cancelText) => {
  const { data } = await api.patch(`/schedule/${id}/cancel`, { cancel_text: cancelText })
  return data.payload
}

export const verifyScheduleCode = async (scheduleId, code) => {
  const response = await api.post(`/custom-schedule-verify-code/${scheduleId}`, { code })
  return response.data
}

export const acceptServicePackage = async (packageId) => {
  const { data } = await api.patch(`/service-packages/${packageId}/accept`)
  return data.payload
}

export const rejectServicePackage = async (packageId) => {
  const { data } = await api.patch(`/service-packages/${packageId}/refuse`)
  return data.payload
}

export const payServicePackage = async (packageId, paymentMethod = 'pix') => {
  const { data } = await api.post(`/payment/service-package/${packageId}/pay`, {
    payment_method: paymentMethod,
  })
  return data.payload
}
