From ce8b1e752bf05158832381df06da321e893a3beb Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Fri, 9 Jun 2023 00:11:14 +0530 Subject: [PATCH 1/2] fixes #4982 --- src/Common/constants.tsx | 20 ++--- src/Components/Patient/SampleFilters.tsx | 100 ++++++++++----------- src/Components/Patient/SampleViewAdmin.tsx | 2 +- 3 files changed, 57 insertions(+), 65 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 258352a65fd..5736327e16e 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -465,16 +465,16 @@ export const BLOOD_GROUPS = [ ]; export const SAMPLE_TYPE_CHOICES = [ - { id: 0, text: "UNKNOWN" }, - { id: 1, text: "BA/ETA" }, - { id: 2, text: "TS/NPS/NS" }, - { id: 3, text: "Blood in EDTA" }, - { id: 4, text: "Acute Sera" }, - { id: 5, text: "Covalescent sera" }, - { id: 6, text: "Biopsy" }, - { id: 7, text: "AMR" }, - { id: 8, text: "Communicable Diseases" }, - { id: 9, text: "OTHER TYPE" }, + { id: "0", text: "UNKNOWN" }, + { id: "1", text: "BA/ETA" }, + { id: "2", text: "TS/NPS/NS" }, + { id: "3", text: "Blood in EDTA" }, + { id: "4", text: "Acute Sera" }, + { id: "5", text: "Covalescent sera" }, + { id: "6", text: "Biopsy" }, + { id: "7", text: "AMR" }, + { id: "8", text: "Communicable Diseases" }, + { id: "9", text: "OTHER TYPE" }, ]; export const ICMR_CATEGORY = [ diff --git a/src/Components/Patient/SampleFilters.tsx b/src/Components/Patient/SampleFilters.tsx index a7be9852642..db22e54ac80 100644 --- a/src/Components/Patient/SampleFilters.tsx +++ b/src/Components/Patient/SampleFilters.tsx @@ -1,5 +1,4 @@ import { useState, useEffect } from "react"; -import { LegacySelectField } from "../Common/HelperInputFields"; import { SAMPLE_TEST_STATUS, SAMPLE_TEST_RESULT, @@ -10,9 +9,12 @@ import { FacilitySelect } from "../Common/FacilitySelect"; import { FacilityModel } from "../Facility/models"; import { getAnyFacility } from "../../Redux/actions"; import { useDispatch } from "react-redux"; -import { CircularProgress } from "@material-ui/core"; import useMergeState from "../../Common/hooks/useMergeState"; import FiltersSlideover from "../../CAREUI/interactive/FiltersSlideover"; +import CircularProgress from "../Common/components/CircularProgress"; +import { FieldLabel } from "../Form/FormFields/FormField"; +import { SelectFormField } from "../Form/FormFields/SelectFormField"; +import { FieldChangeEvent } from "../Form/FormFields/Utils"; const clearFilterState = { status: "", @@ -36,13 +38,8 @@ export default function UserFilter(props: any) { const [isFacilityLoading, setFacilityLoading] = useState(false); const dispatch: any = useDispatch(); - const handleChange = (event: any) => { - const { name, value } = event.target; - - const filterData: any = { ...filterState }; - filterData[name] = value; - - setFilterState(filterData); + const handleChange = ({ name, value }: FieldChangeEvent) => { + setFilterState({ ...filterState, [name]: value }); }; const applyFilter = () => { @@ -70,6 +67,8 @@ export default function UserFilter(props: any) { fetchData(); }, [dispatch]); + console.log(filterState.sample_type); + return ( -
-
Status
- { - return { id, text: text.replaceAll("_", " ") }; - }), - ]} - onChange={handleChange} - errors="" - /> -
+ { + return { id, text: text.replaceAll("_", " ") }; + })} + optionValue={(option) => option.id} + optionLabel={(option) => option.text} + labelClassName="text-sm" + errorClassName="hidden" + /> -
-
Result
- -
+ option.id} + optionLabel={(option) => option.text} + labelClassName="text-sm" + errorClassName="hidden" + /> -
-
Sample Test Type
- -
+ option.id} + optionLabel={(option) => option.text} + labelClassName="text-sm" + errorClassName="hidden" + />
- Facility -
+ Facility +
{isFacilityLoading ? ( - + ) : ( )} diff --git a/src/Components/Patient/SampleViewAdmin.tsx b/src/Components/Patient/SampleViewAdmin.tsx index b7105ef2fd5..2f1204a34c4 100644 --- a/src/Components/Patient/SampleViewAdmin.tsx +++ b/src/Components/Patient/SampleViewAdmin.tsx @@ -401,7 +401,7 @@ export default function SampleViewAdmin() { "Sample Test Type", "sample_type", SAMPLE_TYPE_CHOICES.find( - (type) => type.id.toString() === qParams.sample_type + (type) => type.id === qParams.sample_type )?.text || "" ), value("Facility", "facility", facilityName), From fae19c37524d6e5a45b8aea09a743cf3f6704b78 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Sat, 10 Jun 2023 14:12:38 +0530 Subject: [PATCH 2/2] minor fix for CYPRESS --- cypress/e2e/sample_test_spec/filter.cy.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/sample_test_spec/filter.cy.ts b/cypress/e2e/sample_test_spec/filter.cy.ts index 23bf48e8fd8..8fe8fa50b81 100644 --- a/cypress/e2e/sample_test_spec/filter.cy.ts +++ b/cypress/e2e/sample_test_spec/filter.cy.ts @@ -13,15 +13,24 @@ describe("Sample Filter", () => { }); it("Filter by Status", () => { - cy.get("[name='status']").select("APPROVED"); + cy.get("#status").click(); + cy.get("li[role='option']") + .contains(/^APPROVED$/) + .click(); }); it("Filter by Asset Type", () => { - cy.get("[name='result']").select("POSITIVE"); + cy.get("#result").click(); + cy.get("li[role='option']") + .contains(/^POSITIVE$/) + .click(); }); it("Filter by sample type", () => { - cy.get("[name='sample_type']").select("Biopsy"); + cy.get("#sample_type").click(); + cy.get("li[role='option']") + .contains(/^Biopsy$/) + .click(); }); afterEach(() => {