feat(types, medusa, core-flows): add delete-stock-location endpoint to api-v2 (#6801)
* initial create * add changeset * redo changes for stock locatino module' * initial delete stock location * add changeset * pr prep * propagate deletion with common step * move integration tests --------- Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
This commit is contained in:
co-authored by
Riqwan Thamir
parent
71efa15088
commit
deab12e27e
@@ -0,0 +1,22 @@
|
||||
import { MedusaRequest, MedusaResponse } from "../../../../types/routing"
|
||||
|
||||
import { deleteStockLocationsWorkflow } from "@medusajs/core-flows"
|
||||
|
||||
export const DELETE = async (req: MedusaRequest, res: MedusaResponse) => {
|
||||
const { id } = req.params
|
||||
|
||||
const { errors } = await deleteStockLocationsWorkflow(req.scope).run({
|
||||
input: { ids: [id] },
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
if (Array.isArray(errors) && errors[0]) {
|
||||
throw errors[0].error
|
||||
}
|
||||
|
||||
res.status(200).json({
|
||||
id,
|
||||
object: "stock_location",
|
||||
deleted: true,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user