feat: Delete service zone (#6984)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IFulfillmentModuleService } from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteServiceZonesStepId = "delete-service-zones"
|
||||
export const deleteServiceZonesStep = createStep(
|
||||
deleteServiceZonesStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
const service = container.resolve<IFulfillmentModuleService>(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
|
||||
await service.softDelete(ids)
|
||||
|
||||
return new StepResponse(void 0, ids)
|
||||
},
|
||||
async (prevIds, { container }) => {
|
||||
if (!prevIds?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const service = container.resolve<IFulfillmentModuleService>(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
|
||||
await service.restore(prevIds)
|
||||
}
|
||||
)
|
||||
@@ -3,4 +3,5 @@ export * from "./add-shipping-options-prices"
|
||||
export * from "./create-fulfillment-set"
|
||||
export * from "./create-service-zones"
|
||||
export * from "./create-shipping-options"
|
||||
export * from "./delete-service-zones"
|
||||
export * from "./remove-rules-from-fulfillment-shipping-option"
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { deleteServiceZonesStep } from "../steps"
|
||||
|
||||
export const deleteServiceZonesWorkflowId = "delete-service-zones-workflow"
|
||||
export const deleteServiceZonesWorkflow = createWorkflow(
|
||||
deleteServiceZonesWorkflowId,
|
||||
(input: WorkflowData<{ ids: string[] }>) => {
|
||||
deleteServiceZonesStep(input.ids)
|
||||
}
|
||||
)
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from "./add-rules-to-fulfillment-shipping-option"
|
||||
export * from "./create-service-zones"
|
||||
export * from "./delete-service-zones"
|
||||
export * from "./create-shipping-options"
|
||||
export * from "./remove-rules-from-fulfillment-shipping-option"
|
||||
|
||||
Reference in New Issue
Block a user