Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Fix product id check in process detail (#251)
Browse files Browse the repository at this point in the history
- null type is object, so correctly added it to as type and check if product is not false.
  • Loading branch information
tjeerddie authored Oct 3, 2023
1 parent 61a752d commit 00bb233
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/pages/ProcessDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ function ProcessDetail({ match, query, setQuery }: IProps) {
if (stepUserInput && localStepUserInput) return;
const localTabs = localStepUserInput ? ["user_input", "process"] : ["process"];
const localSelectedTab = localStepUserInput ? "user_input" : "process";
const getProductId = (product: string | { product_id: string }) =>
typeof product === "object" ? product.product_id : product;
const getProductId = (product: string | { product_id: string } | null) =>
product && typeof product === "object" ? product.product_id : product;
const product_id = getProductId(processInstance.product);
setProductName(productNameById(product_id, products));
if (product_id) {
setProductName(productNameById(product_id, products));
}
setCustomerName(organisationNameByUuid(processInstance.customer, organisations));
setProcess(processInstance);
setStepUserInput(localStepUserInput);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export interface Process {
export interface ProcessWithDetails {
id: string;
workflow_name: string;
product: string | { product_id: string };
product: string | { product_id: string } | null;
customer: string;
assignee: Assignee;
last_status: string;
Expand Down

0 comments on commit 00bb233

Please sign in to comment.