From d10cc8809d8eddf6d3b53ce3ea22639bd5697461 Mon Sep 17 00:00:00 2001 From: Mohammad Torkashvand Date: Tue, 3 Oct 2023 13:28:14 +0200 Subject: [PATCH] Fix UI Refresh Issue due to product_id Type Variance (#248) * Handle varying product_id types to prevent UI refresh interruptions * make product comparesion more genaral --------- Co-authored-by: Mohammad Torkashvand --- src/pages/ProcessDetail.tsx | 6 ++++-- src/utils/types.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/ProcessDetail.tsx b/src/pages/ProcessDetail.tsx index ee62db4a..71d3b207 100644 --- a/src/pages/ProcessDetail.tsx +++ b/src/pages/ProcessDetail.tsx @@ -78,8 +78,10 @@ function ProcessDetail({ match, query, setQuery }: IProps) { if (stepUserInput && localStepUserInput) return; const localTabs = localStepUserInput ? ["user_input", "process"] : ["process"]; const localSelectedTab = localStepUserInput ? "user_input" : "process"; - - setProductName(productNameById(processInstance.product, products)); + const getProductId = (product: string | { product_id: string }) => + typeof product === 'object' ? product : product.product_id; + const product_id = getProductId(processInstance.product); + setProductName(productNameById(product_id, products)); setCustomerName(organisationNameByUuid(processInstance.customer, organisations)); setProcess(processInstance); setStepUserInput(localStepUserInput); diff --git a/src/utils/types.ts b/src/utils/types.ts index d755ec2b..e83d3329 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -234,7 +234,7 @@ export interface Process { export interface ProcessWithDetails { id: string; workflow_name: string; - product: string; + product: string | { product_id: string }; customer: string; assignee: Assignee; last_status: string;