From bbeab06d34e7d0a8ff3bb2181c6468a6eeedbe90 Mon Sep 17 00:00:00 2001 From: Aditya Jindal Date: Fri, 27 Sep 2024 16:20:59 +0530 Subject: [PATCH] Fix: Clearing Facilities Field Causes White Screen #8610 (#8629) Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> --- cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts | 4 ++-- cypress/e2e/patient_spec/PatientPrescription.cy.ts | 2 +- src/Components/Users/UserAdd.tsx | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts index a27d560e1a0..6f9bf2b03e0 100644 --- a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts +++ b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts @@ -35,7 +35,7 @@ describe("Patient Consultation in multiple combination", () => { const patientWeight = "70"; const patientHeight = "170"; const medicineOne = "DOLOLUP"; - const patientIpNumber = Math.random().toString(36).substring(7); + const patientIpNumber = `${Math.floor(Math.random() * 90 + 10)}/${Math.floor(Math.random() * 9000 + 1000)}`; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -94,7 +94,7 @@ describe("Patient Consultation in multiple combination", () => { cy.submitButton("Create Consultation"); // the above submit should fail as IP number is missing patientConsultationPage.typePatientNumber(patientIpNumber); - patientConsultationPage.selectBed("Dummy Bed 1"); + patientConsultationPage.selectBed("Dummy Bed 6"); cy.submitButton("Create Consultation"); cy.verifyNotification("Consultation created successfully"); // Below code for the prescription module only present while creating a new consultation diff --git a/cypress/e2e/patient_spec/PatientPrescription.cy.ts b/cypress/e2e/patient_spec/PatientPrescription.cy.ts index de4e121a9db..86ca4122082 100644 --- a/cypress/e2e/patient_spec/PatientPrescription.cy.ts +++ b/cypress/e2e/patient_spec/PatientPrescription.cy.ts @@ -5,7 +5,7 @@ import { PatientPage } from "../../pageobject/Patient/PatientCreation"; const patientPrescription = new PatientPrescription(); const loginPage = new LoginPage(); const patientPage = new PatientPage(); -const medicineNameOne = "DOLO"; +const medicineNameOne = "AGCON"; const medicineNameTwo = "FDEP PLUS"; const medicineBaseDosage = "4"; const medicineTargetDosage = "9"; diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index 86d27bc84d7..9ee1e722ee1 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -325,7 +325,12 @@ export const UserAdd = (props: UserProps) => { }, [state.form.phone_number_is_whatsapp, state.form.phone_number]); const setFacility = (selected: FacilityModel | FacilityModel[] | null) => { - setSelectedFacility(selected as FacilityModel[]); + const newSelectedFacilities = selected + ? Array.isArray(selected) + ? selected + : [selected] + : []; + setSelectedFacility(newSelectedFacilities as FacilityModel[]); const form = { ...state.form }; form.facilities = selected ? (selected as FacilityModel[]).map((i) => i.id!)