chore(order): cancel order (#7586)
This commit is contained in:
committed by
GitHub
parent
fdd9022376
commit
122186a78d
@@ -1,3 +1,4 @@
|
||||
import { cancelOrderWorkflow } from "@medusajs/core-flows"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
@@ -15,7 +16,13 @@ export const GET = async (
|
||||
|
||||
const variables = { id: req.params.id }
|
||||
|
||||
// TODO: cancel order - v1.x - packages/medusa/src/api/routes/admin/orders/cancel-order.ts
|
||||
const input = {
|
||||
order_id: req.params.id,
|
||||
}
|
||||
|
||||
await cancelOrderWorkflow(req.scope).run({
|
||||
input,
|
||||
})
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "order",
|
||||
|
||||
@@ -22,15 +22,10 @@ export const POST = async (
|
||||
order_id: req.params.id,
|
||||
}
|
||||
|
||||
const { errors } = await cancelOrderFulfillmentWorkflow(req.scope).run({
|
||||
await cancelOrderFulfillmentWorkflow(req.scope).run({
|
||||
input,
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
if (Array.isArray(errors) && errors[0]) {
|
||||
throw errors[0].error
|
||||
}
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "order",
|
||||
variables,
|
||||
|
||||
@@ -24,15 +24,10 @@ export const POST = async (
|
||||
labels: req.validatedBody.labels ?? [],
|
||||
}
|
||||
|
||||
const { errors } = await createOrderShipmentWorkflow(req.scope).run({
|
||||
await createOrderShipmentWorkflow(req.scope).run({
|
||||
input,
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
if (Array.isArray(errors) && errors[0]) {
|
||||
throw errors[0].error
|
||||
}
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "order",
|
||||
variables,
|
||||
|
||||
@@ -22,15 +22,10 @@ export const POST = async (
|
||||
order_id: req.params.id,
|
||||
}
|
||||
|
||||
const { errors } = await createOrderFulfillmentWorkflow(req.scope).run({
|
||||
await createOrderFulfillmentWorkflow(req.scope).run({
|
||||
input,
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
if (Array.isArray(errors) && errors[0]) {
|
||||
throw errors[0].error
|
||||
}
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "order",
|
||||
variables,
|
||||
|
||||
Reference in New Issue
Block a user