feat(dashboard): shipping management (#6995)
**What** - shipping flow - shipping profile pages - delete fulfillment set endpoint - delete shipping profile endpoint
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 deleteFulfillmentSetsStepId = "delete-fulfillment-sets"
|
||||
export const deleteFulfillmentSetsStep = createStep(
|
||||
deleteFulfillmentSetsStepId,
|
||||
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)
|
||||
}
|
||||
)
|
||||
@@ -5,6 +5,7 @@ export * from "./create-service-zones"
|
||||
export * from "./upsert-shipping-options"
|
||||
export * from "./delete-service-zones"
|
||||
export * from "./delete-shipping-options"
|
||||
export * from "./delete-fulfillment-sets"
|
||||
export * from "./create-shipping-profiles"
|
||||
export * from "./remove-rules-from-fulfillment-shipping-option"
|
||||
export * from "./set-shipping-options-prices"
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { deleteFulfillmentSetsStep } from "../steps"
|
||||
import { removeRemoteLinkStep } from "../../common"
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
|
||||
export const deleteFulfillmentSetsWorkflowId =
|
||||
"delete-fulfillment-sets-workflow"
|
||||
export const deleteFulfillmentSetsWorkflow = createWorkflow(
|
||||
deleteFulfillmentSetsWorkflowId,
|
||||
(input: WorkflowData<{ ids: string[] }>) => {
|
||||
deleteFulfillmentSetsStep(input.ids)
|
||||
|
||||
removeRemoteLinkStep({
|
||||
[Modules.FULFILLMENT]: { fulfillment_set_id: input.ids },
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -4,6 +4,7 @@ export * from "./create-shipping-options"
|
||||
export * from "./create-shipping-profiles"
|
||||
export * from "./delete-service-zones"
|
||||
export * from "./delete-shipping-options"
|
||||
export * from "./delete-fulfillment-sets"
|
||||
export * from "./remove-rules-from-fulfillment-shipping-option"
|
||||
export * from "./update-service-zones"
|
||||
export * from "./update-shipping-options"
|
||||
|
||||
@@ -22,6 +22,7 @@ export * from "./reservation"
|
||||
export * from "./region"
|
||||
export * from "./sales-channel"
|
||||
export * from "./shipping-options"
|
||||
export * from "./shipping-profile"
|
||||
export * from "./stock-location"
|
||||
export * from "./store"
|
||||
export * from "./tax"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from "./steps"
|
||||
export * from "./workflows"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IFulfillmentModuleService } from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteShippingProfilesStepId = "delete-shipping-profile"
|
||||
export const deleteShippingProfilesStep = createStep(
|
||||
deleteShippingProfilesStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
const service = container.resolve<IFulfillmentModuleService>(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
|
||||
await service.softDeleteShippingProfiles(ids)
|
||||
|
||||
return new StepResponse(void 0, ids)
|
||||
},
|
||||
async (prevIds, { container }) => {
|
||||
if (!prevIds?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const service = container.resolve<IFulfillmentModuleService>(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
|
||||
await service.restoreShippingProfiles(prevIds)
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./delete-shipping-profile"
|
||||
@@ -0,0 +1,18 @@
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
|
||||
import { deleteShippingProfilesStep } from "../steps"
|
||||
import { removeRemoteLinkStep } from "../../common"
|
||||
|
||||
export const deleteShippingProfileWorkflowId =
|
||||
"delete-shipping-profile-workflow"
|
||||
export const deleteShippingProfileWorkflow = createWorkflow(
|
||||
deleteShippingProfileWorkflowId,
|
||||
(input: WorkflowData<{ ids: string[] }>) => {
|
||||
deleteShippingProfilesStep(input.ids)
|
||||
|
||||
removeRemoteLinkStep({
|
||||
[Modules.FULFILLMENT]: { shipping_profile_id: input.ids },
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./delete-shipping-profile"
|
||||
Reference in New Issue
Block a user