import { string } from 'alga-js'
import sendcloudHelper from "../../../../utils/sendcloudHelper"

export default defineEventHandler(async (event) => {
  let data: any = {}
  const body = await readBody(event)

  try {
    const res: any = await sendcloudHelper(`parcels/${body.id}/cancel`, 'POST', null)
    if(res) {
      data['parcel'] = res
    }
  } catch(error: any) {
    data['status'] = 500
    data['message'] = error?.message ?? 'Parcel is not being properly cancelled!'
  }

  return data
})