From 74f27379ca7edfb6c57ddf18e937fba692767d56 Mon Sep 17 00:00:00 2001 From: Onkar Jadhav Date: Mon, 15 Jan 2024 11:35:46 +0530 Subject: [PATCH 1/4] Fix inconsistent removal of facility filters --- src/Components/Facility/HospitalList.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index 075ad8de39e..36b5886c796 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -4,7 +4,7 @@ import { downloadFacilityDoctors, downloadFacilityTriage, } from "../../Redux/actions"; -import { lazy } from "react"; +import { lazy, useEffect } from "react"; import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; import CountBlock from "../../CAREUI/display/Count"; import ExportMenu from "../Common/Export"; @@ -35,6 +35,16 @@ export const HospitalList = () => { } = useFilters({ limit: 14, }); + + useEffect(() => { + if (!qParams.state) { + advancedFilter.removeFilters(["district", "local_body"]); + } + if (!qParams.district) { + advancedFilter.removeFilters(["local_body"]); + } + }, [advancedFilter, qParams]); + let manageFacilities: any = null; const { user_type } = useAuthUser(); const { t } = useTranslation(); From 05ebc9b77476bc2476526c023aef3efbb5204939 Mon Sep 17 00:00:00 2001 From: Onkar Jadhav Date: Wed, 17 Jan 2024 23:04:56 +0530 Subject: [PATCH 2/4] Fix filter cache problem --- src/Components/Facility/HospitalList.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index 36b5886c796..08dec009879 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -37,6 +37,7 @@ export const HospitalList = () => { }); useEffect(() => { + if (!Object.keys(qParams).length) return; if (!qParams.state) { advancedFilter.removeFilters(["district", "local_body"]); } From 6498da462bbb34896fcaad87cd525b77f6655130 Mon Sep 17 00:00:00 2001 From: Onkar Jadhav Date: Wed, 17 Jan 2024 23:09:44 +0530 Subject: [PATCH 3/4] Make the condition for empty qParam check more readable --- src/Components/Facility/HospitalList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index 08dec009879..7511f6e2cb2 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -37,7 +37,7 @@ export const HospitalList = () => { }); useEffect(() => { - if (!Object.keys(qParams).length) return; + if (Object.keys(qParams).length === 0) return; if (!qParams.state) { advancedFilter.removeFilters(["district", "local_body"]); } From 1ec5472e6f58b216524745cd2b13f2e84c0bea11 Mon Sep 17 00:00:00 2001 From: Onkar Jadhav Date: Fri, 19 Jan 2024 11:14:38 +0530 Subject: [PATCH 4/4] Apply review suggestions to filter inconsistency issue --- src/Components/Facility/HospitalList.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index 7511f6e2cb2..cdf08dc85e4 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -37,11 +37,10 @@ export const HospitalList = () => { }); useEffect(() => { - if (Object.keys(qParams).length === 0) return; - if (!qParams.state) { + if (!qParams.state && (qParams.district || qParams.local_body)) { advancedFilter.removeFilters(["district", "local_body"]); } - if (!qParams.district) { + if (!qParams.district && qParams.local_body) { advancedFilter.removeFilters(["local_body"]); } }, [advancedFilter, qParams]);