diff --git a/packages/modules/b2c-core/src/workflows/seller/workflows/import-seller-products.ts b/packages/modules/b2c-core/src/workflows/seller/workflows/import-seller-products.ts index 679732d1d..b56e3d0cd 100644 --- a/packages/modules/b2c-core/src/workflows/seller/workflows/import-seller-products.ts +++ b/packages/modules/b2c-core/src/workflows/seller/workflows/import-seller-products.ts @@ -42,7 +42,7 @@ export const importSellerProductsWorkflow = createWorkflow( product_id: p.id, }, submitter_id: input.submitter_id, - type: "product", + type: "product_import", status: "pending" as RequestStatus, })); } diff --git a/packages/modules/requests/src/api/admin/requests/validators.ts b/packages/modules/requests/src/api/admin/requests/validators.ts index a8a66896c..50dd1d223 100644 --- a/packages/modules/requests/src/api/admin/requests/validators.ts +++ b/packages/modules/requests/src/api/admin/requests/validators.ts @@ -12,6 +12,7 @@ export const AdminGetRequestsParams = createFindParams({ 'product_collection', 'product_category', 'product', + 'product_import', 'seller', 'review_remove', 'product_type', diff --git a/packages/modules/requests/src/workflows/requests/utils/select-workflow.ts b/packages/modules/requests/src/workflows/requests/utils/select-workflow.ts index 4bf62f63b..c5368bf03 100644 --- a/packages/modules/requests/src/workflows/requests/utils/select-workflow.ts +++ b/packages/modules/requests/src/workflows/requests/utils/select-workflow.ts @@ -5,41 +5,21 @@ import { acceptProductTagRequestWorkflow, acceptProductTypeRequestWorkflow, acceptReviewRemoveRequestWorkflow, - acceptSellerCreationRequestWorkflow -} from '../workflows' - -export const getRequestWorkflowByType = (type: string) => { - if (type === 'product_collection') { - return acceptProductCollectionRequestWorkflow - } - - if (type === 'product_category') { - return acceptProductCategoryRequestWorkflow - } - - if (type === 'product') { - return acceptProductRequestWorkflow - } - - if (type === 'product_update') { - return acceptProductRequestWorkflow - } - - if (type === 'seller') { - return acceptSellerCreationRequestWorkflow - } - - if (type === 'review_remove') { - return acceptReviewRemoveRequestWorkflow - } - - if (type === 'product_type') { - return acceptProductTypeRequestWorkflow - } - - if (type === 'product_tag') { - return acceptProductTagRequestWorkflow - } - - return null -} + acceptSellerCreationRequestWorkflow, + updateRequestWorkflow, +} from "../workflows"; + +const workflowMap: Record = { + product: acceptProductRequestWorkflow, + product_import: acceptProductRequestWorkflow, + product_update: acceptProductRequestWorkflow, + product_collection: acceptProductCollectionRequestWorkflow, + product_category: acceptProductCategoryRequestWorkflow, + product_type: acceptProductTypeRequestWorkflow, + product_tag: acceptProductTagRequestWorkflow, + seller: acceptSellerCreationRequestWorkflow, + review_remove: acceptReviewRemoveRequestWorkflow, +}; + +export const getRequestWorkflowByType = (type: string) => + workflowMap[type] ?? updateRequestWorkflow;