feat(order,core-flows): added order change create workflow (#8033)
what: - adds anorder change create workflow - remove order change service, brings validation to entry point service
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { CreateOrderChangeDTO, IOrderModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createOrderChangeStepId = "create-order-change"
|
||||
export const createOrderChangeStep = createStep(
|
||||
createOrderChangeStepId,
|
||||
async (data: CreateOrderChangeDTO, { container }) => {
|
||||
const service = container.resolve<IOrderModuleService>(
|
||||
ModuleRegistrationName.ORDER
|
||||
)
|
||||
|
||||
const created = await service.createOrderChange(data)
|
||||
|
||||
return new StepResponse(created, created.id)
|
||||
},
|
||||
async (id, { container }) => {
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
|
||||
const service = container.resolve<IOrderModuleService>(
|
||||
ModuleRegistrationName.ORDER
|
||||
)
|
||||
|
||||
await service.deleteOrderChanges(id)
|
||||
}
|
||||
)
|
||||
@@ -4,6 +4,7 @@ export * from "./cancel-exchange"
|
||||
export * from "./cancel-orders"
|
||||
export * from "./cancel-return"
|
||||
export * from "./complete-orders"
|
||||
export * from "./create-order-change"
|
||||
export * from "./create-orders"
|
||||
export * from "./get-item-tax-lines"
|
||||
export * from "./register-fulfillment"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { CreateOrderChangeDTO, OrderChangeDTO } from "@medusajs/types"
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { createOrderChangeStep } from "../steps"
|
||||
|
||||
export const createOrderChangeWorkflowId = "create-order-change"
|
||||
export const createOrderChangeWorkflow = createWorkflow(
|
||||
createOrderChangeWorkflowId,
|
||||
(input: WorkflowData<CreateOrderChangeDTO>): WorkflowData<OrderChangeDTO> => {
|
||||
return createOrderChangeStep(input)
|
||||
}
|
||||
)
|
||||
@@ -4,6 +4,7 @@ export * from "./cancel-order-fulfillment"
|
||||
export * from "./cancel-return"
|
||||
export * from "./complete-orders"
|
||||
export * from "./create-fulfillment"
|
||||
export * from "./create-order-change"
|
||||
export * from "./create-orders"
|
||||
export * from "./create-return"
|
||||
export * from "./create-shipment"
|
||||
|
||||
Reference in New Issue
Block a user