fix(core-flows): add no_notification to fulfillment created event (#11507)
what: - passes no notification toggle to events - fulfillment created and canceled fixes https://github.com/medusajs/medusa/issues/11505
This commit is contained in:
@@ -38,7 +38,7 @@ export type CancelOrderFulfillmentValidateOrderStep = {
|
|||||||
order: OrderDTO & {
|
order: OrderDTO & {
|
||||||
/**
|
/**
|
||||||
* The order's fulfillments.
|
* The order's fulfillments.
|
||||||
*/
|
*/
|
||||||
fulfillments: FulfillmentDTO[]
|
fulfillments: FulfillmentDTO[]
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -48,16 +48,16 @@ export type CancelOrderFulfillmentValidateOrderStep = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This step validates that an order fulfillment can be canceled. If
|
* This step validates that an order fulfillment can be canceled. If
|
||||||
* the fulfillment doesn't exist, or it has already been shipped, the step throws an error.
|
* the fulfillment doesn't exist, or it has already been shipped, the step throws an error.
|
||||||
*
|
*
|
||||||
* :::note
|
* :::note
|
||||||
*
|
*
|
||||||
* You can retrieve an order and fulfillment details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
* You can retrieve an order and fulfillment details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
||||||
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
||||||
*
|
*
|
||||||
* :::
|
* :::
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* const data = cancelOrderFulfillmentValidateOrder({
|
* const data = cancelOrderFulfillmentValidateOrder({
|
||||||
* order: {
|
* order: {
|
||||||
@@ -78,10 +78,7 @@ export type CancelOrderFulfillmentValidateOrderStep = {
|
|||||||
*/
|
*/
|
||||||
export const cancelOrderFulfillmentValidateOrder = createStep(
|
export const cancelOrderFulfillmentValidateOrder = createStep(
|
||||||
"cancel-fulfillment-validate-order",
|
"cancel-fulfillment-validate-order",
|
||||||
({
|
({ order, input }: CancelOrderFulfillmentValidateOrderStep) => {
|
||||||
order,
|
|
||||||
input,
|
|
||||||
}: CancelOrderFulfillmentValidateOrderStep) => {
|
|
||||||
throwIfOrderIsCancelled({ order })
|
throwIfOrderIsCancelled({ order })
|
||||||
|
|
||||||
const fulfillment = order.fulfillments.find(
|
const fulfillment = order.fulfillments.find(
|
||||||
@@ -162,17 +159,18 @@ function prepareInventoryUpdate({
|
|||||||
/**
|
/**
|
||||||
* The data to cancel an order's fulfillment, along with custom data that's passed to the workflow's hooks.
|
* The data to cancel an order's fulfillment, along with custom data that's passed to the workflow's hooks.
|
||||||
*/
|
*/
|
||||||
export type CancelOrderFulfillmentWorkflowInput = OrderWorkflow.CancelOrderFulfillmentWorkflowInput & AdditionalData
|
export type CancelOrderFulfillmentWorkflowInput =
|
||||||
|
OrderWorkflow.CancelOrderFulfillmentWorkflowInput & AdditionalData
|
||||||
|
|
||||||
export const cancelOrderFulfillmentWorkflowId = "cancel-order-fulfillment"
|
export const cancelOrderFulfillmentWorkflowId = "cancel-order-fulfillment"
|
||||||
/**
|
/**
|
||||||
* This workflow cancels an order's fulfillment. It's used by the [Cancel Order's Fulfillment Admin API Route](https://docs.medusajs.com/api/admin#orders_postordersidfulfillmentsfulfillment_idcancel).
|
* This workflow cancels an order's fulfillment. It's used by the [Cancel Order's Fulfillment Admin API Route](https://docs.medusajs.com/api/admin#orders_postordersidfulfillmentsfulfillment_idcancel).
|
||||||
*
|
*
|
||||||
* This workflow has a hook that allows you to perform custom actions on the canceled fulfillment. For example, you can pass under `additional_data` custom data that
|
* This workflow has a hook that allows you to perform custom actions on the canceled fulfillment. For example, you can pass under `additional_data` custom data that
|
||||||
* allows you to update custom data models linked to the fulfillment.
|
* allows you to update custom data models linked to the fulfillment.
|
||||||
*
|
*
|
||||||
* You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around canceling a fulfillment.
|
* You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around canceling a fulfillment.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* const { result } = await cancelOrderFulfillmentWorkflow(container)
|
* const { result } = await cancelOrderFulfillmentWorkflow(container)
|
||||||
* .run({
|
* .run({
|
||||||
@@ -184,18 +182,16 @@ export const cancelOrderFulfillmentWorkflowId = "cancel-order-fulfillment"
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* })
|
* })
|
||||||
*
|
*
|
||||||
* @summary
|
* @summary
|
||||||
*
|
*
|
||||||
* Cancel an order's fulfillment.
|
* Cancel an order's fulfillment.
|
||||||
*
|
*
|
||||||
* @property hooks.orderFulfillmentCanceled - This hook is executed after the fulfillment is canceled. You can consume this hook to perform custom actions on the canceled fulfillment.
|
* @property hooks.orderFulfillmentCanceled - This hook is executed after the fulfillment is canceled. You can consume this hook to perform custom actions on the canceled fulfillment.
|
||||||
*/
|
*/
|
||||||
export const cancelOrderFulfillmentWorkflow = createWorkflow(
|
export const cancelOrderFulfillmentWorkflow = createWorkflow(
|
||||||
cancelOrderFulfillmentWorkflowId,
|
cancelOrderFulfillmentWorkflowId,
|
||||||
(
|
(input: WorkflowData<CancelOrderFulfillmentWorkflowInput>) => {
|
||||||
input: WorkflowData<CancelOrderFulfillmentWorkflowInput>
|
|
||||||
) => {
|
|
||||||
const order: OrderDTO & { fulfillments: FulfillmentDTO[] } =
|
const order: OrderDTO & { fulfillments: FulfillmentDTO[] } =
|
||||||
useRemoteQueryStep({
|
useRemoteQueryStep({
|
||||||
entry_point: "orders",
|
entry_point: "orders",
|
||||||
@@ -227,10 +223,11 @@ export const cancelOrderFulfillmentWorkflow = createWorkflow(
|
|||||||
prepareInventoryUpdate
|
prepareInventoryUpdate
|
||||||
)
|
)
|
||||||
|
|
||||||
const eventData = transform({ order, fulfillment }, (data) => {
|
const eventData = transform({ order, fulfillment, input }, (data) => {
|
||||||
return {
|
return {
|
||||||
order_id: data.order.id,
|
order_id: data.order.id,
|
||||||
fulfillment_id: data.fulfillment.id,
|
fulfillment_id: data.fulfillment.id,
|
||||||
|
no_notification: data.input.no_notification,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -467,6 +467,7 @@ export const createOrderFulfillmentWorkflow = createWorkflow(
|
|||||||
data: {
|
data: {
|
||||||
order_id: input.order_id,
|
order_id: input.order_id,
|
||||||
fulfillment_id: fulfillment.id,
|
fulfillment_id: fulfillment.id,
|
||||||
|
no_notification: input.no_notification,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user