feat: Add support for category deletion (#7679)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IProductModuleService } from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteProductCategoryStepId = "delete-product-category"
|
||||
export const deleteProductCategoryStep = createStep(
|
||||
deleteProductCategoryStepId,
|
||||
async (id: string, { container }) => {
|
||||
const service = container.resolve<IProductModuleService>(
|
||||
ModuleRegistrationName.PRODUCT
|
||||
)
|
||||
|
||||
await service.deleteCategory(id)
|
||||
return new StepResponse(void 0, id)
|
||||
},
|
||||
async (prevId, { container }) => {
|
||||
if (!prevId) {
|
||||
return
|
||||
}
|
||||
|
||||
const service = container.resolve<IProductModuleService>(
|
||||
ModuleRegistrationName.PRODUCT
|
||||
)
|
||||
|
||||
// TODO: There is no soft delete support for categories yet
|
||||
// await service.restoreCategory(prevId)
|
||||
}
|
||||
)
|
||||
@@ -1 +1,3 @@
|
||||
export * from "./create-product-category"
|
||||
export * from "./update-product-category"
|
||||
export * from "./delete-product-category"
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { deleteProductCategoryStep } from "../steps"
|
||||
|
||||
export const deleteProductCategoryWorkflowId = "delete-product-category"
|
||||
export const deleteProductCategoryWorkflow = createWorkflow(
|
||||
deleteProductCategoryWorkflowId,
|
||||
(input: WorkflowData<string>) => {
|
||||
return deleteProductCategoryStep(input)
|
||||
}
|
||||
)
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./create-product-category"
|
||||
export * from "./update-product-category"
|
||||
export * from "./delete-product-category"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ProductCategoryWorkflow } from "@medusajs/types"
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { updateProductCategoryStep } from "../steps/update-product-category"
|
||||
import { updateProductCategoryStep } from "../steps"
|
||||
|
||||
type WorkflowInputData =
|
||||
ProductCategoryWorkflow.UpdateProductCategoryWorkflowInput
|
||||
|
||||
Reference in New Issue
Block a user