Skip to content

Commit

Permalink
Update AssetFilter component to handle null facility value (#7014)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 authored Jan 12, 2024
1 parent 2fbdb85 commit f2bf161
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Components/Assets/AssetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getDate = (value: any) =>

function AssetFilter(props: any) {
const { filter, onChange, closeFilter, removeFilters } = props;
const [facility, setFacility] = useState<FacilityModel>({ name: "" });
const [facility, setFacility] = useState<FacilityModel | null>(null);
const [asset_type, setAssetType] = useState<string>(
filter.asset_type ? filter.asset_type : ""
);
Expand Down Expand Up @@ -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([
Expand Down Expand Up @@ -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) => {
Expand All @@ -107,7 +107,7 @@ function AssetFilter(props: any) {
<FacilitySelect
name="Facilities"
setSelected={(selected) =>
handleFacilitySelect(selected as FacilityModel)
handleFacilitySelect(selected as FacilityModel | null)
}
selected={facility}
errors=""
Expand Down

0 comments on commit f2bf161

Please sign in to comment.