-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31b07ae
commit 84c35dc
Showing
13 changed files
with
363 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/core-flows/src/fulfillment/steps/update-service-zones.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ModuleRegistrationName } from "@medusajs/modules-sdk" | ||
import { FulfillmentWorkflow, IFulfillmentModuleService } from "@medusajs/types" | ||
import { getSelectsAndRelationsFromObjectArray } from "@medusajs/utils" | ||
import { StepResponse, createStep } from "@medusajs/workflows-sdk" | ||
|
||
type StepInput = FulfillmentWorkflow.UpdateServiceZonesWorkflowInput | ||
|
||
export const updateServiceZonesStepId = "update-service-zones" | ||
export const updateServiceZonesStep = createStep( | ||
updateServiceZonesStepId, | ||
async (input: StepInput, { container }) => { | ||
const service = container.resolve<IFulfillmentModuleService>( | ||
ModuleRegistrationName.FULFILLMENT | ||
) | ||
|
||
const { selects, relations } = getSelectsAndRelationsFromObjectArray([ | ||
input.update, | ||
]) | ||
|
||
const prevData = await service.listServiceZones(input.selector, { | ||
select: selects, | ||
relations, | ||
}) | ||
|
||
const updatedServiceZones = await service.updateServiceZones( | ||
input.selector, | ||
input.update | ||
) | ||
|
||
return new StepResponse(updatedServiceZones, prevData) | ||
}, | ||
async (prevData, { container }) => { | ||
if (!prevData?.length) { | ||
return | ||
} | ||
|
||
const service = container.resolve<IFulfillmentModuleService>( | ||
ModuleRegistrationName.FULFILLMENT | ||
) | ||
|
||
// TODO: Implement upsertServiceZones | ||
// await service.upsertServiceZones(prevData) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
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 "./delete-service-zones" | ||
export * from "./remove-rules-from-fulfillment-shipping-option" | ||
export * from "./update-service-zones" |
15 changes: 15 additions & 0 deletions
15
packages/core-flows/src/fulfillment/workflows/update-service-zones.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { FulfillmentWorkflow } from "@medusajs/types" | ||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk" | ||
import { updateServiceZonesStep } from "../steps/update-service-zones" | ||
|
||
export const updateServiceZonesWorkflowId = "update-service-zones-workflow" | ||
export const updateServiceZonesWorkflow = createWorkflow( | ||
updateServiceZonesWorkflowId, | ||
( | ||
input: WorkflowData<FulfillmentWorkflow.UpdateServiceZonesWorkflowInput> | ||
): WorkflowData => { | ||
const serviceZones = updateServiceZonesStep(input) | ||
|
||
return serviceZones | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.