From 2057d3b24733680571ff977130b3e23bcc12d733 Mon Sep 17 00:00:00 2001 From: pepijn-vanvlaanderen Date: Tue, 31 Oct 2023 11:22:28 +0100 Subject: [PATCH] fix(admin-ui) Custom batch job activity card (#5288) --- .changeset/nervous-eels-explain.md | 5 +++++ .../organisms/batch-jobs-activity-list/index.tsx | 10 +++------- .../organisms/batch-jobs-activity-list/utils.ts | 7 +------ 3 files changed, 9 insertions(+), 13 deletions(-) create mode 100644 .changeset/nervous-eels-explain.md diff --git a/.changeset/nervous-eels-explain.md b/.changeset/nervous-eels-explain.md new file mode 100644 index 0000000000..bd360101e7 --- /dev/null +++ b/.changeset/nervous-eels-explain.md @@ -0,0 +1,5 @@ +--- +"@medusajs/admin-ui": patch +--- + +Fixes crash on the batch job activity card when using a custom batch job. diff --git a/packages/admin-ui/ui/src/components/organisms/batch-jobs-activity-list/index.tsx b/packages/admin-ui/ui/src/components/organisms/batch-jobs-activity-list/index.tsx index 2ebc12541c..e1ca0d92d5 100644 --- a/packages/admin-ui/ui/src/components/organisms/batch-jobs-activity-list/index.tsx +++ b/packages/admin-ui/ui/src/components/organisms/batch-jobs-activity-list/index.tsx @@ -18,7 +18,7 @@ import FileIcon from "../../fundamentals/icons/file-icon" import MedusaIcon from "../../fundamentals/icons/medusa-icon" import { ActivityCard } from "../../molecules/activity-card" import BatchJobFileCard from "../../molecules/batch-job-file-card" -import { batchJobDescriptionBuilder, BatchJobOperation } from "./utils" +import { batchJobDescriptionBuilder } from "./utils" import CrossIcon from "../../fundamentals/icons/cross-icon" /** @@ -86,12 +86,8 @@ const BatchJobActivityCard = (props: { batchJob: BatchJob }) => { to: batchJob.created_at, }) - const operation = { - "product-import": BatchJobOperation.Import, - "price-list-import": BatchJobOperation.Import, - "product-export": BatchJobOperation.Export, - "order-export": BatchJobOperation.Export, - }[batchJob.type] + let operation = batchJob.type.split("-").pop() + operation = operation.charAt(0).toUpperCase() + operation.slice(1) const batchJobActivityDescription = batchJobDescriptionBuilder( batchJob, diff --git a/packages/admin-ui/ui/src/components/organisms/batch-jobs-activity-list/utils.ts b/packages/admin-ui/ui/src/components/organisms/batch-jobs-activity-list/utils.ts index a962de25f6..db9e2fe4b7 100644 --- a/packages/admin-ui/ui/src/components/organisms/batch-jobs-activity-list/utils.ts +++ b/packages/admin-ui/ui/src/components/organisms/batch-jobs-activity-list/utils.ts @@ -1,13 +1,8 @@ import { BatchJob } from "@medusajs/medusa/dist" -export enum BatchJobOperation { - Import = "Import", - Export = "Export", -} - export function batchJobDescriptionBuilder( batchJob: BatchJob, - operation: BatchJobOperation, + operation: string, elapsedTime?: number ): string { let description = ""