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-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 ( = ({ .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); }