diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index 8ec3b3981b7..70276e9641d 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -19,13 +19,11 @@ const getRelativeDateString = (deltaDays = 0) => { if (deltaDays) { date.setDate(date.getDate() + deltaDays); } - return date - .toLocaleDateString("en-IN", { - day: "2-digit", - month: "2-digit", - year: "numeric", - }) - .replace("/", ""); + return date.toLocaleDateString("en-IN", { + day: "2-digit", + month: "2-digit", + year: "numeric", + }); }; describe("Patient Creation with consultation", () => { diff --git a/cypress/e2e/users_spec/user_creation.cy.ts b/cypress/e2e/users_spec/user_creation.cy.ts index e2708c7a5a2..2fccf4fae87 100644 --- a/cypress/e2e/users_spec/user_creation.cy.ts +++ b/cypress/e2e/users_spec/user_creation.cy.ts @@ -146,7 +146,7 @@ describe("User Creation", () => { userCreationPage.typeIntoElementById("password", "Test@123"); userCreationPage.selectHomeFacility("Dummy Shifting Center"); userCreationPage.typeIntoElementById("phone_number", phone_number); - userCreationPage.setInputDate("date_of_birth", "date-input", "25081999"); + userCreationPage.setInputDate("date_of_birth", "date-input", "25/08/1999"); userCreationPage.selectDropdownOption("user_type", "Doctor"); userCreationPage.typeIntoElementById("c_password", "Test@123"); userCreationPage.typeIntoElementById("doctor_qualification", "MBBS"); diff --git a/src/Components/Common/DateInputV2.tsx b/src/Components/Common/DateInputV2.tsx index 1a2d9333038..f2cd8f8d9f3 100644 --- a/src/Components/Common/DateInputV2.tsx +++ b/src/Components/Common/DateInputV2.tsx @@ -335,22 +335,22 @@ const DateInputV2: React.FC = ({ /> - -
- {open && ( +
= ({ }} onBlur={() => setEditingText(null)} /> - )} -
-
-
- - -
- {type === "date" && ( +
+
+
+ + +
+ {type === "date" && ( +
+ {dayjs(datePickerHeaderDate).format("MMMM")} +
+ )}
- {dayjs(datePickerHeaderDate).format("MMMM")} +

+ {type == "year" + ? year.getFullYear() + : dayjs(datePickerHeaderDate).format( + "YYYY", + )} +

- )} -
-

- {type == "year" - ? year.getFullYear() - : dayjs(datePickerHeaderDate).format("YYYY")} -

+
- -
- {type === "date" && ( - <> -
- {DAYS.map((day, i) => ( -
-
- {day} + {type === "date" && ( + <> +
+ {DAYS.map((day, i) => ( +
+
+ {day} +
-
- ))} -
-
- {blankDays.map((_, i) => ( -
- ))} - {dayCount.map((d, i) => { - const withinConstraints = - isDateWithinConstraints(d); - let selected; - if (value) { - const newDate = new Date( - datePickerHeaderDate, - ); - newDate.setDate(d); - selected = - value.toDateString() === - newDate.toDateString(); - } - - const baseClasses = - "flex h-full items-center justify-center rounded text-center text-sm leading-loose transition duration-100 ease-in-out"; - let conditionalClasses = ""; - - if (withinConstraints) { - if (selected) { - conditionalClasses = - "bg-primary-500 font-bold text-white"; + ))} +
+
+ {blankDays.map((_, i) => ( +
+ ))} + {dayCount.map((d, i) => { + const withinConstraints = + isDateWithinConstraints(d); + let selected; + if (value) { + const newDate = new Date( + datePickerHeaderDate, + ); + newDate.setDate(d); + selected = + value.toDateString() === + newDate.toDateString(); + } + + const baseClasses = + "flex h-full items-center justify-center rounded text-center text-sm leading-loose transition duration-100 ease-in-out"; + let conditionalClasses = ""; + + if (withinConstraints) { + if (selected) { + conditionalClasses = + "bg-primary-500 font-bold text-white"; + } else { + conditionalClasses = + "hover:bg-secondary-300 cursor-pointer"; + } } else { conditionalClasses = - "hover:bg-secondary-300 cursor-pointer"; + "!cursor-not-allowed !text-secondary-400"; } - } else { - conditionalClasses = - "!cursor-not-allowed !text-secondary-400"; - } - return ( -
- -
- ); - })} -
- - )} - {type === "month" && ( -
- {Array(12) - .fill(null) - .map((_, i) => ( -
- {dayjs( - new Date( - datePickerHeaderDate.getFullYear(), - i, - 1, - ), - ).format("MMM")} -
- ))} -
- )} - {type === "year" && ( -
- {Array(12) - .fill(null) - .map((_, i) => { - const y = year.getFullYear() - 11 + i; - return ( + +
+ ); + })} +
+ + )} + {type === "month" && ( +
+ {Array(12) + .fill(null) + .map((_, i) => (
- {y} + {dayjs( + new Date( + datePickerHeaderDate.getFullYear(), + i, + 1, + ), + ).format("MMM")}
- ); - })} -
- )} -
- {time && ( -
- {( - [ - { - name: "Hours", - value: hours, - options: Array.from( - { length: 12 }, - (_, i) => i + 1, - ), - onChange: (val: any) => { - handleTimeChange({ - newHours: val, - }); + ))} +
+ )} + {type === "year" && ( +
+ {Array(12) + .fill(null) + .map((_, i) => { + const y = year.getFullYear() - 11 + i; + return ( +
+ {y} +
+ ); + })} +
+ )} +
+ {time && ( +
+ {( + [ + { + name: "Hours", + value: hours, + options: Array.from( + { length: 12 }, + (_, i) => i + 1, + ), + onChange: (val: any) => { + handleTimeChange({ + newHours: val, + }); + }, + ref: hourScrollerRef, }, - ref: hourScrollerRef, - }, - { - name: "Minutes", - value: minutes, - options: Array.from( - { length: 60 }, - (_, i) => i, - ), - onChange: (val: any) => { - handleTimeChange({ - newMinutes: val, - }); + { + name: "Minutes", + value: minutes, + options: Array.from( + { length: 60 }, + (_, i) => i, + ), + onChange: (val: any) => { + handleTimeChange({ + newMinutes: val, + }); + }, + ref: minuteScrollerRef, }, - ref: minuteScrollerRef, - }, - { - name: "am/pm", - value: ampm, - options: ["AM", "PM"], - onChange: (val: any) => { - handleTimeChange({ - newAmpm: val, - }); + { + name: "am/pm", + value: ampm, + options: ["AM", "PM"], + onChange: (val: any) => { + handleTimeChange({ + newAmpm: val, + }); + }, + ref: undefined, }, - ref: undefined, - }, - ] as const - ).map((input, i) => ( -
{ - const optionsHeight = - e.currentTarget.scrollHeight / 3; - const scrollTop = e.currentTarget.scrollTop; - const containerHeight = - e.currentTarget.clientHeight; - if (scrollTop >= optionsHeight * 2) { - e.currentTarget.scrollTo({ - top: optionsHeight, - }); - } - if ( - scrollTop + containerHeight <= - optionsHeight - ) { - e.currentTarget.scrollTo({ - top: optionsHeight + scrollTop, - }); - } - }} - > - {[ - ...input.options, - ...(input.name === "am/pm" - ? [] - : input.options), - ...(input.name === "am/pm" - ? [] - : input.options), - ].map((option, j) => ( - - ))} -
- ))} -
- )} + if ( + scrollTop + containerHeight <= + optionsHeight + ) { + e.currentTarget.scrollTo({ + top: optionsHeight + scrollTop, + }); + } + }} + > + {[ + ...input.options, + ...(input.name === "am/pm" + ? [] + : input.options), + ...(input.name === "am/pm" + ? [] + : input.options), + ].map((option, j) => ( + + ))} +
+ ))} +
+ )} +
-
- + + )}
); }}