feat(core-flows, order): add workflow to create change order actions (#8056)

what:

- adds workflow to create change order actions
This commit is contained in:
Riqwan Thamir
2024-07-10 12:35:03 +02:00
committed by GitHub
parent 04ec8e758f
commit bec2dcd667
37 changed files with 290 additions and 46 deletions
@@ -0,0 +1,34 @@
import {
CreateOrderChangeActionDTO,
IOrderModuleService,
} from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const createOrderChangeActionsStepId = "create-order-change-actions"
export const createOrderChangeActionsStep = createStep(
createOrderChangeActionsStepId,
async (data: CreateOrderChangeActionDTO[], { container }) => {
const service = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
)
const created = await service.addOrderAction(data)
return new StepResponse(
created,
created.map((c) => c.id)
)
},
async (ids, { container }) => {
if (!ids?.length) {
return
}
const service = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
)
await service.deleteOrderChangeActions(ids)
}
)
@@ -6,6 +6,7 @@ export * from "./cancel-orders"
export * from "./cancel-return"
export * from "./complete-orders"
export * from "./create-order-change"
export * from "./create-order-change-actions"
export * from "./create-orders"
export * from "./decline-order-change"
export * from "./delete-order-change"
@@ -0,0 +1,16 @@
import {
CreateOrderChangeActionDTO,
OrderChangeActionDTO,
} from "@medusajs/types"
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
import { createOrderChangeActionsStep } from "../steps"
export const createOrderChangeActionsWorkflowId = "create-order-change-actions"
export const createOrderChangeActionsWorkflow = createWorkflow(
createOrderChangeActionsWorkflowId,
(
input: WorkflowData<CreateOrderChangeActionDTO[]>
): WorkflowData<OrderChangeActionDTO[]> => {
return createOrderChangeActionsStep(input)
}
)
@@ -6,6 +6,7 @@ export * from "./cancel-return"
export * from "./complete-orders"
export * from "./create-fulfillment"
export * from "./create-order-change"
export * from "./create-order-change-actions"
export * from "./create-orders"
export * from "./create-return"
export * from "./create-shipment"