// Base
import type { ProcedureRoomOrder, CreateDto } from '~/models/procedure-room-order'
import * as base from './_crud-base'

const name = 'procedure-room-order'
const path = `/api/v1/${name}`

export function create(data: CreateDto) {
  return base.create(path, data, name)
}

export function getList(params: any = null) {
  return base.getList(path, params, name)
}

export function getDetail(id: number | string, params: any = null) {
  return base.getDetail(path, id, name, params)
}

export function update(id: number | string, data: ProcedureRoomOrder) {
  return base.update(path, id, data, name)
}

export function remove(id: number | string) {
  return base.remove(path, id, name)
}


export async function submit(id: number) {
  try {
    const resp = await xfetch(`${path}/${id}/submit`, 'PATCH')
    const result: any = {}
    if (resp.success) {
      result.success = resp.success
      result.body = (resp.body as Record<string, any>) || {}
      return result
    }
  } catch (error) {
    console.error(`Error submitting ${name}:`, error)
    throw new Error(`Failed to submit ${name}`)
  }
}
