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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user