From bd6cdf6ad08e455939fa7a0df9f8bad3aed4c7f5 Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 12 Jan 2024 16:07:05 +0530 Subject: [PATCH] Update AssetFilter component to handle null facility value --- src/Components/Assets/AssetFilter.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Components/Assets/AssetFilter.tsx b/src/Components/Assets/AssetFilter.tsx index 9aeac85e734..5d2ad9e30ae 100644 --- a/src/Components/Assets/AssetFilter.tsx +++ b/src/Components/Assets/AssetFilter.tsx @@ -20,7 +20,7 @@ const getDate = (value: any) => function AssetFilter(props: any) { const { filter, onChange, closeFilter, removeFilters } = props; - const [facility, setFacility] = useState({ name: "" }); + const [facility, setFacility] = useState(null); const [asset_type, setAssetType] = useState( filter.asset_type ? filter.asset_type : "" ); @@ -51,7 +51,7 @@ function AssetFilter(props: any) { setLocationId( facility?.id === qParams.facility ? qParams.location ?? "" : "" ); - }, [facility.id, qParams.facility, qParams.location]); + }, [facility?.id, qParams.facility, qParams.location]); const clearFilter = useCallback(() => { removeFilters([ @@ -81,8 +81,8 @@ function AssetFilter(props: any) { onChange(data); }; - const handleFacilitySelect = (selected: FacilityModel) => { - setFacility(selected ? selected : facility); + const handleFacilitySelect = (selected: FacilityModel | null) => { + setFacility(selected); handleLocationSelect(""); }; const handleLocationSelect = (selectedId: string) => { @@ -107,7 +107,7 @@ function AssetFilter(props: any) { - handleFacilitySelect(selected as FacilityModel) + handleFacilitySelect(selected as FacilityModel | null) } selected={facility} errors=""