From cc860db58f3dd92d1737ea7ebbcaab43345b871e Mon Sep 17 00:00:00 2001 From: Makombe Kennedy Date: Wed, 14 Aug 2024 15:43:48 +0300 Subject: [PATCH 1/2] (fix): Fix undefined thrown when selecting an operation (#193) --- src/core/api/types/stockOperation/StockOperationType.ts | 2 +- src/core/components/table/table.component.tsx | 4 ++-- src/core/utils/datetimeUtils.ts | 2 +- .../concepts-selector/concepts-selector.component.tsx | 4 ++-- .../add-stock-user-role-scope.component.tsx | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/api/types/stockOperation/StockOperationType.ts b/src/core/api/types/stockOperation/StockOperationType.ts index 30bc27d3..0170d349 100644 --- a/src/core/api/types/stockOperation/StockOperationType.ts +++ b/src/core/api/types/stockOperation/StockOperationType.ts @@ -36,7 +36,7 @@ export enum OperationType { } export function operationFromString(str: string): OperationType | undefined { - str = str.toLowerCase(); + str = str?.toLowerCase(); if (str === OperationType.TRANSFER_OUT_OPERATION_TYPE) return OperationType.TRANSFER_OUT_OPERATION_TYPE; if (str === OperationType.DISPOSED_OPERATION_TYPE) diff --git a/src/core/components/table/table.component.tsx b/src/core/components/table/table.component.tsx index 0768fb7a..3f6567c1 100644 --- a/src/core/components/table/table.component.tsx +++ b/src/core/components/table/table.component.tsx @@ -85,13 +85,13 @@ const DataList: React.FC = ({ headers.some(({ key }) => { const cellId = getCellId(rowId, key); const filterableValue = cellsById[cellId].value; - const filterTerm = inputValue.toLowerCase(); + const filterTerm = inputValue?.toLowerCase(); if (typeof filterableValue === "boolean") { return false; } - return ("" + filterableValue).toLowerCase().includes(filterTerm); + return ("" + filterableValue)?.toLowerCase().includes(filterTerm); }) ); }; diff --git a/src/core/utils/datetimeUtils.ts b/src/core/utils/datetimeUtils.ts index 24e971f9..b5cdf938 100644 --- a/src/core/utils/datetimeUtils.ts +++ b/src/core/utils/datetimeUtils.ts @@ -48,7 +48,7 @@ export const ParseDate = (value: string | null | undefined) => { let date = null; try { if (!value) return date; - value = value.toLowerCase(); + value = value?.toLowerCase(); if (value.includes("jan")) value = value.replace("jan", "01"); else if (value.includes("feb")) value = value.replace("feb", "02"); else if (value.includes("mar")) value = value.replace("mar", "03"); diff --git a/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx b/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx index dab3d6eb..8f53c61b 100644 --- a/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx +++ b/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx @@ -33,8 +33,8 @@ const ConceptsSelector = (props: ConceptsSelectorProps) => { ? concepts : concepts.filter((concept) => concept.display - .toLowerCase() - .includes(inputValue.trim().toLowerCase()) + ?.toLowerCase() + .includes(inputValue.trim()?.toLowerCase()) ); }, [inputValue, concepts]); diff --git a/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx b/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx index b6a93762..91babe8d 100644 --- a/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx +++ b/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx @@ -114,7 +114,7 @@ const AddStockUserRoleScope: React.FC = ({ .filter((item: any) => item.uuid !== loggedInUserUuid) .filter((item: any) => { const displayName = item?.person?.display ?? item?.display ?? ""; - return displayName.toLowerCase().includes(query.toLowerCase()); + return displayName?.toLowerCase().includes(query?.toLowerCase()); }); setFilteredItems(filtered); } From eefbd59197c1fc901eb6762a95127bd2828c5e21 Mon Sep 17 00:00:00 2001 From: Captain David <75360744+DavidSaruni@users.noreply.github.com> Date: Mon, 19 Aug 2024 10:26:28 +0300 Subject: [PATCH 2/2] Fixed Form State on Assign Responsible Person as Default Person on Stock Management Operations based on User Login (#200) --- .../base-operation-details.component.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stock-operations/add-stock-operation/base-operation-details.component.tsx b/src/stock-operations/add-stock-operation/base-operation-details.component.tsx index d9aa9050..2e884f6f 100644 --- a/src/stock-operations/add-stock-operation/base-operation-details.component.tsx +++ b/src/stock-operations/add-stock-operation/base-operation-details.component.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO"; import { SaveStockOperation } from "../../stock-items/types"; @@ -83,6 +83,12 @@ const BaseOperationDetails: React.FC = ({ const [isOtherUser, setIsOtherUser] = useState(); const [isSaving, setIsSaving] = useState(false); + useEffect(() => { + if (defaultLoggedUserUuid) { + setValue("responsiblePersonUuid", defaultLoggedUserUuid); + } + }, [defaultLoggedUserUuid, setValue]); + if (isLoading) { return (