From 16aa34681c3f4c5d85b078f6ac7c3442b9428a15 Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Thu, 10 Oct 2024 13:56:02 +0530 Subject: [PATCH] updated UI to not have the user add slashes --- .../patient_spec/PatientRegistration.cy.ts | 2 +- src/Components/Common/DateInputV2.tsx | 72 ++------- src/Components/Common/DateTextInput.tsx | 147 ++++++++++-------- src/Components/Symptoms/SymptomsBuilder.tsx | 2 +- 4 files changed, 104 insertions(+), 119 deletions(-) diff --git a/cypress/e2e/patient_spec/PatientRegistration.cy.ts b/cypress/e2e/patient_spec/PatientRegistration.cy.ts index 900e0d370c0..7a459603b2e 100644 --- a/cypress/e2e/patient_spec/PatientRegistration.cy.ts +++ b/cypress/e2e/patient_spec/PatientRegistration.cy.ts @@ -36,7 +36,7 @@ describe("Patient Creation with consultation", () => { const phone_number = generatePhoneNumber(); const age = calculateAge(); const patientFacility = "Dummy Facility 40"; - const patientDateOfBirth = "01/01/2001"; + const patientDateOfBirth = "01012001"; const patientMenstruationStartDate = getRelativeDateString(-10); const patientDateOfDelivery = getRelativeDateString(-20); const patientOneName = "Patient With No Consultation"; diff --git a/src/Components/Common/DateInputV2.tsx b/src/Components/Common/DateInputV2.tsx index 95857b89709..cc678768ebe 100644 --- a/src/Components/Common/DateInputV2.tsx +++ b/src/Components/Common/DateInputV2.tsx @@ -50,7 +50,6 @@ const DateInputV2: React.FC = ({ max, outOfLimitsErrorMessage, onChange, - position = "CENTER", disabled, placeholder, setIsOpen, @@ -206,22 +205,6 @@ const DateInputV2: React.FC = ({ return true; }; - const isDateWithinLimits = (parsedDate: dayjs.Dayjs): boolean => { - if (parsedDate?.isValid()) { - if ( - (max && parsedDate.toDate() > max) || - (min && parsedDate.toDate() < min) - ) { - Notification.Error({ - msg: outOfLimitsErrorMessage ?? "Cannot select date out of range", - }); - return false; - } - return true; - } - return false; - }; - const isSelectedMonth = (month: number) => month === datePickerHeaderDate.getMonth(); @@ -294,33 +277,9 @@ const DateInputV2: React.FC = ({ }, [isOpen]); const dateFormat = `DD/MM/YYYY${time ? " hh:mm a" : ""}`; - const placeHolder = dateFormat.replace("a", "am/pm"); - - const getDisplayValue = (date: Date) => { - return dayjs(date).format(dateFormat); - }; const getPosition = () => { - switch (position) { - case "LEFT": - return "left-0"; - case "LEFT-CENTER": - return "right-0 transform md:translate-x-1/2"; - case "RIGHT": - return "right-0"; - case "RIGHT-CENTER": - return "right-0 transform md:translate-x-1/2"; - case "CENTER": - return "transform -translate-x-1/2"; - case "TOP-LEFT": - return "bottom-full left-full"; - case "TOP-RIGHT": - return "bottom-full right-0"; - case "TOP-CENTER": - return "bottom-full left-1/2 transform -translate-x-1/2"; - default: - return "left-0"; - } + return ""; }; return ( @@ -358,7 +317,6 @@ const DateInputV2: React.FC = ({ {open && ( = ({ >
- {value && ( - - )} + max) || + (!!min && value < min)) + ? "Cannot select date out of range" + : undefined + } + /> +
@@ -647,7 +609,7 @@ const DateInputV2: React.FC = ({