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:
Riqwan Thamir
2025-02-19 08:05:52 +00:00
committed by GitHub
parent b60e1c855e
commit 30171f3dc4
2 changed files with 20 additions and 22 deletions
@@ -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,7 +159,8 @@ 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"
/** /**
@@ -193,9 +191,7 @@ export const cancelOrderFulfillmentWorkflowId = "cancel-order-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,
}, },
}) })
) )