From f4194937eeb5eeb4353c4043f1faf3901e4af0e1 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 9 Oct 2024 01:29:43 +0200 Subject: [PATCH 1/5] patient export test (#8745) --- .../e2e/patient_spec/PatientHomepage.cy.ts | 12 +++++++ cypress/pageobject/Patient/PatientHome.ts | 31 +++++++++++++++++++ src/Components/Patient/ManagePatients.tsx | 2 +- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/patient_spec/PatientHomepage.cy.ts b/cypress/e2e/patient_spec/PatientHomepage.cy.ts index c1575057fe4..0cf5936594d 100644 --- a/cypress/e2e/patient_spec/PatientHomepage.cy.ts +++ b/cypress/e2e/patient_spec/PatientHomepage.cy.ts @@ -16,6 +16,18 @@ describe("Patient Homepage present functionalities", () => { cy.awaitUrl("/patients"); }); + it("Export the live patient list based on a date range", () => { + patientHome.clickPatientExport(); + cy.verifyNotification("Please select a seven day period"); + cy.closeNotification(); + patientHome.typePatientModifiedBeforeDate("01122023"); + patientHome.typePatientModifiedAfterDate("07122023"); + patientHome.clickPatientFilterApply(); + patientHome.interceptPatientExportRequest(); + patientHome.clickPatientExport(); + patientHome.verifyPatientExportRequest(); + }); + it("Verify the functionality of the patient tab pagination", () => { let firstPatientPageOne: string; cy.get('[data-cy="patient"]') diff --git a/cypress/pageobject/Patient/PatientHome.ts b/cypress/pageobject/Patient/PatientHome.ts index 94801cd4bb8..d2f4efdc877 100644 --- a/cypress/pageobject/Patient/PatientHome.ts +++ b/cypress/pageobject/Patient/PatientHome.ts @@ -10,5 +10,36 @@ class PatientHome { clickPreviousPage() { cy.get("#prev-pages").click(); } + + clickPatientExport() { + cy.get("#patient-export").click(); + } + + clickPatientFilterApply() { + cy.get("#apply-filter").click(); + } + + interceptPatientExportRequest() { + cy.intercept({ + method: "GET", + url: "/api/v1/patient/*", + }).as("getPatients"); + } + + verifyPatientExportRequest() { + cy.wait("@getPatients").then((interception) => { + expect(interception.request.url).to.include("/api/v1/patient/"); + expect(interception.request.url).to.include("&csv"); + expect(interception.response.statusCode).to.eq(200); + }); + } + + typePatientModifiedBeforeDate(startDate: string) { + cy.clickAndTypeDate("input[name='modified_date_start']", startDate); + } + + typePatientModifiedAfterDate(endDate: string) { + cy.clickAndTypeDate("input[name='modified_date_end']", endDate); + } } export default PatientHome; diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index 3f15544a50a..e5ee70163ea 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -891,7 +891,7 @@ export const PatientManager = () => { selected={qParams.ordering} onSelect={updateQuery} /> -
+
{!isExportAllowed ? ( { From 207365a990a04884eef77771ffe1ce51749c8e38 Mon Sep 17 00:00:00 2001 From: Jacob John Jeevan <40040905+Jacobjeevan@users.noreply.github.com> Date: Wed, 9 Oct 2024 06:18:34 +0530 Subject: [PATCH 2/5] hide spoke heading on facility create page (#8730) --- src/Components/Facility/FacilityCreate.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index c68aa9ec0db..81bc6f48125 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -850,14 +850,14 @@ export const FacilityCreate = (props: FacilityProps) => { required types={["mobile", "landline"]} /> -
-

{t("spokes")}

- {facilityId && ( + {facilityId && ( +
+

{t("spokes")}

- )} -
+
+ )}
Date: Wed, 9 Oct 2024 15:46:43 +0530 Subject: [PATCH 3/5] Fix: Error Messages Persist in UserAdd Component (#8721) --- src/Components/Users/UserAdd.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index 855e2cb8f9a..6a87e64425c 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -294,6 +294,7 @@ export const UserAdd = (props: UserProps) => { const handleDateChange = (e: FieldChangeEvent) => { if (dayjs(e.value).isValid()) { + const errors = { ...state.errors, [e.name]: "" }; dispatch({ type: "set_form", form: { @@ -301,10 +302,12 @@ export const UserAdd = (props: UserProps) => { [e.name]: dayjs(e.value).format("YYYY-MM-DD"), }, }); + dispatch({ type: "set_errors", errors }); } }; const handleFieldChange = (event: FieldChangeEvent) => { + const errors = { ...state.errors, [event.name]: "" }; dispatch({ type: "set_form", form: { @@ -312,6 +315,7 @@ export const UserAdd = (props: UserProps) => { [event.name]: event.value, }, }); + dispatch({ type: "set_errors", errors }); }; useAbortableEffect(() => { From 4b2c827ed434b3eac22ac72582d3fdb863bcd670 Mon Sep 17 00:00:00 2001 From: Shaurya Gupta Date: Wed, 9 Oct 2024 16:04:13 +0530 Subject: [PATCH 4/5] fix: Add user media ready and camera permission denied notifications (#8688) --- .../Facility/CoverImageEditModal.tsx | 64 +++++++++++++------ src/Locale/en.json | 3 +- src/Locale/hi.json | 3 +- src/Locale/kn.json | 1 + src/Locale/ml.json | 1 + src/Locale/ta.json | 1 + 6 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/Components/Facility/CoverImageEditModal.tsx b/src/Components/Facility/CoverImageEditModal.tsx index d65a1d0ebfd..f3b2b3ab761 100644 --- a/src/Components/Facility/CoverImageEditModal.tsx +++ b/src/Components/Facility/CoverImageEditModal.tsx @@ -1,11 +1,11 @@ -import { +import React, { + useState, ChangeEventHandler, useCallback, useEffect, useRef, - useState, } from "react"; -import { Success } from "../../Utils/Notifications"; +import { Success, Warn } from "../../Utils/Notifications"; import useDragAndDrop from "../../Utils/useDragAndDrop"; import { sleep } from "../../Utils/utils"; import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2"; @@ -67,9 +67,11 @@ const CoverImageEditModal = ({ const LaptopScreenBreakpoint = 640; const isLaptopScreen = width >= LaptopScreenBreakpoint; const { t } = useTranslation(); + const [isDragging, setIsDragging] = useState(false); + const handleSwitchCamera = useCallback(() => { - setConstraint((prev) => - prev.facingMode === "user" + setConstraint( + constraint.facingMode === "user" ? VideoConstraints.environment : VideoConstraints.user, ); @@ -85,6 +87,7 @@ const CoverImageEditModal = ({ setSelectedFile(myFile); }); }; + const closeModal = () => { setPreview(undefined); setSelectedFile(undefined); @@ -162,11 +165,25 @@ const CoverImageEditModal = ({ const onDrop = (e: React.DragEvent) => { e.preventDefault(); dragProps.setDragOver(false); - const dropedFile = e?.dataTransfer?.files[0]; - if (dropedFile.type.split("/")[0] !== "image") + setIsDragging(false); + const droppedFile = e?.dataTransfer?.files[0]; + if (droppedFile.type.split("/")[0] !== "image") return dragProps.setFileDropError("Please drop an image file to upload!"); - setSelectedFile(dropedFile); + setSelectedFile(droppedFile); + }; + + const onDragOver = (e: React.DragEvent) => { + e.preventDefault(); + dragProps.onDragOver(e); + setIsDragging(true); + }; + + const onDragLeave = (e: React.DragEvent) => { + e.preventDefault(); + dragProps.onDragLeave(); + setIsDragging(false); }; + const commonHint = ( <> {t("max_size_for_image_uploaded_should_be")} 1mb. @@ -202,16 +219,16 @@ const CoverImageEditModal = ({ ) : (

{ + setConstraint(() => VideoConstraints.user); setIsCameraOpen(true); }} > @@ -322,6 +346,10 @@ const CoverImageEditModal = ({ width={1280} ref={webRef} videoConstraints={constraint} + onUserMediaError={(_e) => { + setIsCameraOpen(false); + Warn({ msg: t("camera_permission_denied") }); + }} /> ) : ( diff --git a/src/Locale/en.json b/src/Locale/en.json index 94b9168e564..3359a89904a 100644 --- a/src/Locale/en.json +++ b/src/Locale/en.json @@ -198,6 +198,7 @@ "retake": "Retake", "submit": "Submit", "camera": "Camera", + "camera_permission_denied": "Camera Permission denied", "submitting": "Submitting", "view_details": "View Details", "type_to_search": "Type to search", @@ -1020,4 +1021,4 @@ "date_declared_positive": "Date of declaring positive", "date_of_result": "Covid confirmation date", "is_vaccinated": "Whether vaccinated" -} +} \ No newline at end of file diff --git a/src/Locale/hi.json b/src/Locale/hi.json index 3e967c35cb4..4844a2d787d 100644 --- a/src/Locale/hi.json +++ b/src/Locale/hi.json @@ -197,6 +197,7 @@ "retake": "फिर से लेना", "submit": "जमा करना", "camera": "कैमरा", + "camera_permission_denied": "कैमरा अनुमति नहीं दी गई", "submitting": "भेजने से", "view_details": "विवरण देखें", "type_to_search": "खोजने के लिए टाइप करें", @@ -809,4 +810,4 @@ "search_by_username": "उपयोगकर्ता नाम से खोजें", "last_online": "अंतिम ऑनलाइन", "total_users": "कुल उपयोगकर्ता" -} +} \ No newline at end of file diff --git a/src/Locale/kn.json b/src/Locale/kn.json index ee808b5ebc3..a2738edd9e9 100644 --- a/src/Locale/kn.json +++ b/src/Locale/kn.json @@ -197,6 +197,7 @@ "retake": "ಮರುಪಡೆಯಿರಿ", "submit": "ಸಲ್ಲಿಸಿ", "camera": "ಕ್ಯಾಮೆರಾ", + "camera_permission_denied": "ಕ್ಯಾಮೆರಾ ಅನುಮತಿ ನಿರಾಕರಿಸಲಾಗಿದೆ", "submitting": "ಸಲ್ಲಿಸಲಾಗುತ್ತಿದೆ", "view_details": "ವಿವರಗಳನ್ನು ವೀಕ್ಷಿಸಿ", "type_to_search": "ಹುಡುಕಲು ಟೈಪ್ ಮಾಡಿ", diff --git a/src/Locale/ml.json b/src/Locale/ml.json index 00f649c6952..614a4005ef9 100644 --- a/src/Locale/ml.json +++ b/src/Locale/ml.json @@ -197,6 +197,7 @@ "retake": "വീണ്ടും എടുക്കുക", "submit": "സമർപ്പിക്കുക", "camera": "ക്യാമറ", + "camera_permission_denied": "ക്യാമറ അനുമതി നിഷേധിച്ചു", "submitting": "സമർപ്പിക്കുന്നു", "view_details": "വിശദാംശങ്ങൾ കാണുക", "type_to_search": "തിരയാൻ ടൈപ്പ് ചെയ്യുക", diff --git a/src/Locale/ta.json b/src/Locale/ta.json index ddaebbe2183..cb2eb506bc2 100644 --- a/src/Locale/ta.json +++ b/src/Locale/ta.json @@ -197,6 +197,7 @@ "retake": "மீண்டும் எடுக்கவும்", "submit": "சமர்ப்பிக்கவும்", "camera": "கேமரா", + "camera_permission_denied": "கேமரா அனுமதி நிராகரித்தது", "submitting": "சமர்ப்பிக்கிறது", "view_details": "விவரங்களைக் காண்க", "type_to_search": "தேட தட்டச்சு செய்யவும்", From aa90ad5b4c8fc0670533a4cbe3e24c7c9b57a286 Mon Sep 17 00:00:00 2001 From: Noufal Rahim <120470585+noufalrahim@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:28:15 +0530 Subject: [PATCH 5/5] fix: Removed useQuery from wrapper (#8716) Co-authored-by: Khavin Shankar --- .../Facility/LocationManagement.tsx | 196 ++++++++++-------- 1 file changed, 110 insertions(+), 86 deletions(-) diff --git a/src/Components/Facility/LocationManagement.tsx b/src/Components/Facility/LocationManagement.tsx index 8df40d9c5f2..1aaf57b7233 100644 --- a/src/Components/Facility/LocationManagement.tsx +++ b/src/Components/Facility/LocationManagement.tsx @@ -13,6 +13,7 @@ import ConfirmDialog from "../Common/ConfirmDialog"; import DialogModal from "../Common/Dialog"; import Uptime from "../Common/Uptime"; import useAuthUser from "../../Common/hooks/useAuthUser"; +import useQuery from "../../Utils/request/useQuery"; import Loading from "@/Components/Common/Loading"; interface Props { @@ -223,97 +224,120 @@ const Location = ({ disabled, setShowDeletePopup, facilityId, -}: LocationProps) => ( -

-
-
-
-

- {name} -

-
-

- {location_type} +}: LocationProps) => { + const { loading, data } = useQuery(routes.listFacilityBeds, { + query: { + facility: facilityId, + location: id, + }, + }); + + const totalBeds = data?.count ?? 0; + + if (loading) { + return ; + } + + return ( +

+
+
+
+

+ {name}

+
+

+ {location_type} +

+
-
-

- {description || "-"} -

-

- Middleware Address: -

-

- {middleware_address || "-"} -

- - Middleware Uptime -

- } - centerInfoPanel - /> -
- - - - Manage Beds - -
-
- - - Edit - -
-
- - setShowDeletePopup({ open: true, name: name ?? "", id: id ?? "" }) - } + {description || "-"} +

+

+ Middleware Address: +

+

- - Delete - + {middleware_address || "-"} +

+ + Middleware Uptime +

+ } + centerInfoPanel + />
-
-
- - + + Manage Beds + + + {totalBeds} + + +
+
+ + + Edit + +
+
+ + setShowDeletePopup({ open: true, name: name ?? "", id: id ?? "" }) + } + > + + Delete + +
+
+ +
+ + +
-
-); + ); +};