feat(medusa, core-flows): Create service zones (#6979)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
CreateServiceZoneDTO,
|
||||
IFulfillmentModuleService,
|
||||
} from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type StepInput = CreateServiceZoneDTO[]
|
||||
|
||||
export const createServiceZonesStepId = "create-service-zones"
|
||||
export const createServiceZonesStep = createStep(
|
||||
createServiceZonesStepId,
|
||||
async (input: StepInput, { container }) => {
|
||||
const service = container.resolve<IFulfillmentModuleService>(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
|
||||
const createdServiceZones = await service.createServiceZones(input)
|
||||
|
||||
return new StepResponse(
|
||||
createdServiceZones,
|
||||
createdServiceZones.map((createdZone) => createdZone.id)
|
||||
)
|
||||
},
|
||||
async (createdServiceZones, { container }) => {
|
||||
if (!createdServiceZones?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const service = container.resolve<IFulfillmentModuleService>(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
|
||||
await service.deleteServiceZones(createdServiceZones)
|
||||
}
|
||||
)
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from "./add-rules-to-fulfillment-shipping-option"
|
||||
export * from "./create-fulfillment-set"
|
||||
export * from "./remove-rules-from-fulfillment-shipping-option"
|
||||
export * from "./create-shipping-options"
|
||||
export * from "./add-shipping-options-prices"
|
||||
export * from "./create-fulfillment-set"
|
||||
export * from "./create-service-zones"
|
||||
export * from "./create-shipping-options"
|
||||
export * from "./remove-rules-from-fulfillment-shipping-option"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { FulfillmentWorkflow } from "@medusajs/types"
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { createServiceZonesStep } from "../steps"
|
||||
|
||||
export const createServiceZonesWorkflowId = "create-service-zones-workflow"
|
||||
export const createServiceZonesWorkflow = createWorkflow(
|
||||
createServiceZonesWorkflowId,
|
||||
(
|
||||
input: WorkflowData<FulfillmentWorkflow.CreateServiceZonesWorkflowInput>
|
||||
): WorkflowData => {
|
||||
const serviceZones = createServiceZonesStep(input.data)
|
||||
|
||||
return serviceZones
|
||||
}
|
||||
)
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./add-rules-to-fulfillment-shipping-option"
|
||||
export * from "./remove-rules-from-fulfillment-shipping-option"
|
||||
export * from "./create-service-zones"
|
||||
export * from "./create-shipping-options"
|
||||
export * from "./remove-rules-from-fulfillment-shipping-option"
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
interface StepInput {
|
||||
input: {
|
||||
|
||||
Reference in New Issue
Block a user