// DELETE /api/printers/:id - Eliminar una impresora
import { deletePrinter } from '../../utils/printers'

export default defineEventHandler(async (event) => {
  try {
    const id = getRouterParam(event, 'id')

    if (!id) {
      return {
        ok: false,
        error: 'ID requerido'
      }
    }

    const deleted = await deletePrinter(id)

    if (!deleted) {
      return {
        ok: false,
        error: 'Impresora no encontrada'
      }
    }

    return {
      ok: true,
      message: 'Impresora eliminada'
    }
  } catch (err: any) {
    return {
      ok: false,
      error: err.message
    }
  }
})
