From ea4a69b0adbedea0c6d8f17dda6ce18639d51e03 Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Tue, 4 Feb 2025 00:21:05 +0530 Subject: [PATCH 01/19] improved tablet view responsiveness --- src/pages/Encounters/EncounterList.tsx | 280 +++++++++++++------------ 1 file changed, 142 insertions(+), 138 deletions(-) diff --git a/src/pages/Encounters/EncounterList.tsx b/src/pages/Encounters/EncounterList.tsx index effc46721a5..8db184105de 100644 --- a/src/pages/Encounters/EncounterList.tsx +++ b/src/pages/Encounters/EncounterList.tsx @@ -214,8 +214,8 @@ export function EncounterList({ return ( -
-
+
+
@@ -467,191 +467,195 @@ export function EncounterList({
+
+ + updateQuery({ + ...{ encounter_class: encounterClass, priority }, + status: undefined, + }) + } + > + All + + + updateQuery({ + ...{ encounter_class: encounterClass, priority }, + status: "planned", + }) + } + > + + Planned + + + updateQuery({ + ...{ encounter_class: encounterClass, priority }, + status: "in_progress", + }) + } + > + + In Progress + + + updateQuery({ + ...{ encounter_class: encounterClass, priority }, + status: "discharged", + }) + } + > + + Discharged + + + updateQuery({ + ...{ encounter_class: encounterClass, priority }, + status: "completed", + }) + } + > + + Completed + + + updateQuery({ + ...{ encounter_class: encounterClass, priority }, + status: "cancelled", + }) + } + > + + Cancelled + +
+
+
+
+
+ + + + {/* Class Filter - Desktop */} +
+ + +
updateQuery({ - ...{ encounter_class: encounterClass, priority }, - status: undefined, + status, + priority, + encounter_class: undefined, }) } > - All + All Types updateQuery({ - ...{ encounter_class: encounterClass, priority }, - status: "planned", + status, + priority, + encounter_class: "imp", }) } > - - Planned + + Inpatient updateQuery({ - ...{ encounter_class: encounterClass, priority }, - status: "in_progress", + status, + priority, + encounter_class: "amb", }) } > - - In Progress + + Ambulatory updateQuery({ - ...{ encounter_class: encounterClass, priority }, - status: "discharged", + status, + priority, + encounter_class: "obsenc", }) } > - - Discharged + + Observation updateQuery({ - ...{ encounter_class: encounterClass, priority }, - status: "completed", + status, + priority, + encounter_class: "emer", }) } > - - Completed + + Emergency updateQuery({ - ...{ encounter_class: encounterClass, priority }, - status: "cancelled", + status, + priority, + encounter_class: "vr", }) } > - - Cancelled + + Virtual - - -
-
- - - - {/* Class Filter - Desktop */} -
- - - - updateQuery({ - status, - priority, - encounter_class: undefined, - }) - } - > - All Types - - - updateQuery({ - status, - priority, - encounter_class: "imp", - }) - } - > - - Inpatient - - - updateQuery({ - status, - priority, - encounter_class: "amb", - }) - } - > - - Ambulatory - - - updateQuery({ - status, - priority, - encounter_class: "obsenc", - }) - } - > - - Observation - - - updateQuery({ - status, - priority, - encounter_class: "emer", - }) - } - > - - Emergency - - - updateQuery({ - status, - priority, - encounter_class: "vr", - }) - } - > - - Virtual - - - updateQuery({ - status, - priority, - encounter_class: "hh", - }) - } - > - - Home Health - + + updateQuery({ + status, + priority, + encounter_class: "hh", + }) + } + > + + Home Health + +
From 85bfad8282fbdeb7be1686c2a1af2d04c5dbe22a Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Tue, 4 Feb 2025 17:21:19 +0530 Subject: [PATCH 02/19] solved i18n issue --- src/pages/Encounters/EncounterList.tsx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pages/Encounters/EncounterList.tsx b/src/pages/Encounters/EncounterList.tsx index 8db184105de..f6eaf605c80 100644 --- a/src/pages/Encounters/EncounterList.tsx +++ b/src/pages/Encounters/EncounterList.tsx @@ -478,7 +478,7 @@ export function EncounterList({ }) } > - All + {t("all")} - Planned + {t("encounter_status__planned")} - In Progress + {t("encounter_class__in_progress")} - Discharged + {t("discharge")} - Completed + {t("completed")} - Cancelled + {t("cancelled")}
@@ -569,7 +569,7 @@ export function EncounterList({ }) } > - All Types + {t("all")} - Inpatient + {t("encounter_class__imp")} - Ambulatory + {t("encounter_class__amb")} - Observation + {t("encounter_class__obsenc")} - Emergency + {t("emergency")} - Virtual + {t("encounter_class__vr")} - Home Health + {t("encounter_class__hh")}
From 158d70996cb7354bac9e8e269fa4510363901630 Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Wed, 5 Feb 2025 00:05:41 +0530 Subject: [PATCH 03/19] update mobile view responsiveness --- .../Facility/settings/locations/LocationView.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/Facility/settings/locations/LocationView.tsx b/src/pages/Facility/settings/locations/LocationView.tsx index d5527d5fe4f..9b1e89c39f8 100644 --- a/src/pages/Facility/settings/locations/LocationView.tsx +++ b/src/pages/Facility/settings/locations/LocationView.tsx @@ -95,10 +95,10 @@ export default function LocationView({ id, facilityId }: Props) { return ( -
-
-
-
+
+
+
+

{t("locations")}

{getLocationFormLabel(location?.form)} @@ -117,7 +117,7 @@ export default function LocationView({ id, facilityId }: Props) { )}
-
+
@@ -136,7 +136,7 @@ export default function LocationView({ id, facilityId }: Props) { currentOrganizations={locationOrganizations.results} facilityId={facilityId} trigger={ - From c4586e61f1b688ae72c2f38307540c2d1be14955 Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Wed, 5 Feb 2025 16:32:10 +0530 Subject: [PATCH 04/19] added responsiveness in organization users page --- src/pages/Organization/OrganizationUsers.tsx | 4 ++-- src/pages/Organization/components/AddUserSheet.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/Organization/OrganizationUsers.tsx b/src/pages/Organization/OrganizationUsers.tsx index 479059fa9a3..02efa8b4f44 100644 --- a/src/pages/Organization/OrganizationUsers.tsx +++ b/src/pages/Organization/OrganizationUsers.tsx @@ -57,7 +57,7 @@ export default function OrganizationUsers({ id, navOrganizationId }: Props) { return (
-
+
-
+
{ diff --git a/src/pages/Organization/components/AddUserSheet.tsx b/src/pages/Organization/components/AddUserSheet.tsx index 1efba82ca81..b6054eb4a56 100644 --- a/src/pages/Organization/components/AddUserSheet.tsx +++ b/src/pages/Organization/components/AddUserSheet.tsx @@ -33,7 +33,7 @@ export default function AddUserSheet({ return ( - From 73c1773e8f61870bd0a3738087571d097c992047 Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Wed, 5 Feb 2025 17:04:52 +0530 Subject: [PATCH 05/19] minor change in button --- src/pages/Organization/components/LinkUserSheet.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Organization/components/LinkUserSheet.tsx b/src/pages/Organization/components/LinkUserSheet.tsx index 967783d61be..cee05d79724 100644 --- a/src/pages/Organization/components/LinkUserSheet.tsx +++ b/src/pages/Organization/components/LinkUserSheet.tsx @@ -111,7 +111,7 @@ export default function LinkUserSheet({ return ( - From ffdb6df7083de82372fcbf8d747d8cfbf12fc20d Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Wed, 5 Feb 2025 17:36:45 +0530 Subject: [PATCH 06/19] draft pr --- .../Patient/PatientRegistration.tsx | 1 + src/components/ui/date-field.tsx | 62 +++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/components/Patient/PatientRegistration.tsx b/src/components/Patient/PatientRegistration.tsx index 9acf238d3de..8f9236f946a 100644 --- a/src/components/Patient/PatientRegistration.tsx +++ b/src/components/Patient/PatientRegistration.tsx @@ -169,6 +169,7 @@ export default function PatientRegistration( partial_id: resp?.id?.slice(0, 5), }, }); + console.log(resp.date_of_birth); }, onError: () => { toast.error(t("patient_registration_error")); diff --git a/src/components/ui/date-field.tsx b/src/components/ui/date-field.tsx index daeff36be5f..b1ff2d84290 100644 --- a/src/components/ui/date-field.tsx +++ b/src/components/ui/date-field.tsx @@ -29,10 +29,11 @@ export default function DateField({ const [month, setMonth] = useState(""); const [year, setYear] = useState(""); + // Only set initial values from `date` prop without padding useEffect(() => { if (date) { - setDay(date.getDate().toString().padStart(2, "0")); - setMonth((date.getMonth() + 1).toString().padStart(2, "0")); + setDay(date.getDate().toString()); + setMonth((date.getMonth() + 1).toString()); setYear(date.getFullYear().toString()); } else { setDay(""); @@ -58,7 +59,6 @@ export default function DateField({ ); onChange(updatedDate); } - document.getElementById(`${id}-month-input`)?.focus(); } }; @@ -79,8 +79,6 @@ export default function DateField({ ); onChange(updatedDate); } - - document.getElementById(`${id}-year-input`)?.focus(); } }; @@ -100,6 +98,56 @@ export default function DateField({ } }; + // Handle day blur to pad single digit values + const handleDayBlur = () => { + if (day.length === 1 && parseInt(day) >= 1 && parseInt(day) <= 9) { + const paddedDay = day.padStart(2, "0"); + setDay(paddedDay); + if (isValidDate(year, month, paddedDay) && onChange) { + const updatedDate = new Date( + parseInt(year), + parseInt(month) - 1, + parseInt(paddedDay), + ); + onChange(updatedDate); + } + } + }; + + // Handle month blur to pad single digit values + const handleMonthBlur = () => { + if (month.length === 1 && parseInt(month) >= 1) { + setYear(year); + if (isValidDate(year, month, day) && onChange) { + const updatedDate = new Date( + parseInt(year), + parseInt(year) - 1, + parseInt(day), + ); + onChange(updatedDate); + } + } + }; + + const handleYearBlur = () => { + const currYear = new Date().getFullYear(); + if ( + year.length === 4 && + parseInt(year) >= 1900 && + parseInt(year) <= currYear + ) { + setDay(year); + if (isValidDate(year, month, day) && onChange) { + const updatedDate = new Date( + parseInt(year), + parseInt(month) - 1, + parseInt(day), + ); + onChange(updatedDate); + } + } + }; + return (
@@ -109,6 +157,7 @@ export default function DateField({ placeholder="DD" value={day} onChange={handleDayChange} + onBlur={handleDayBlur} min={1} max={31} id={`${id}-day-input`} @@ -124,6 +173,7 @@ export default function DateField({ placeholder="MM" value={month} onChange={handleMonthChange} + onBlur={handleMonthBlur} min={1} max={12} id={`${id}-month-input`} @@ -139,7 +189,9 @@ export default function DateField({ placeholder="YYYY" value={year} onChange={handleYearChange} + onBlur={handleYearBlur} min={1900} + max={new Date().getFullYear()} id={`${id}-year-input`} data-cy={`${id}-year-input`} disabled={disabled} From f46c2eb42ebf45ba10b6bf42c9395a8f5b628ee4 Mon Sep 17 00:00:00 2001 From: Jacob John Jeevan Date: Thu, 6 Feb 2025 00:48:39 +0530 Subject: [PATCH 07/19] modified date-field handlers --- .../Patient/PatientRegistration.tsx | 8 ++- src/components/ui/date-field.tsx | 57 +++++++++---------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/components/Patient/PatientRegistration.tsx b/src/components/Patient/PatientRegistration.tsx index 8f9236f946a..14dae246637 100644 --- a/src/components/Patient/PatientRegistration.tsx +++ b/src/components/Patient/PatientRegistration.tsx @@ -176,7 +176,11 @@ export default function PatientRegistration( }, }); - const { mutate: updatePatient, isPending: isUpdatingPatient } = useMutation({ + const { + mutate: updatePatient, + isPending: isUpdatingPatient, + isSuccess: isUpdateSuccess, + } = useMutation({ mutationFn: mutate(routes.updatePatient, { pathParams: { id: patientId || "" }, }), @@ -292,7 +296,7 @@ export default function PatientRegistration( useNavigationPrompt( form.formState.isDirty && !isCreatingPatient && - !isUpdatingPatient && + !(isUpdatingPatient || isUpdateSuccess) && !showDuplicate, t("unsaved_changes"), ); diff --git a/src/components/ui/date-field.tsx b/src/components/ui/date-field.tsx index b1ff2d84290..7893f9beb6e 100644 --- a/src/components/ui/date-field.tsx +++ b/src/components/ui/date-field.tsx @@ -32,8 +32,8 @@ export default function DateField({ // Only set initial values from `date` prop without padding useEffect(() => { if (date) { - setDay(date.getDate().toString()); - setMonth((date.getMonth() + 1).toString()); + setDay(date.getDate().toString().padStart(2, "0")); + setMonth((date.getMonth() + 1).toString().padStart(2, "0")); setYear(date.getFullYear().toString()); } else { setDay(""); @@ -46,16 +46,22 @@ export default function DateField({ const newDay = e.target.value; setDay(newDay); + // Check if change is from spinner (stepUp/stepDown) vs keyboard input + const isFromSpinner = + e.nativeEvent instanceof InputEvent && + (e.nativeEvent as InputEvent).inputType === "insertReplacementText"; + if ( - newDay.length === 2 && + (isFromSpinner || newDay.length === 2) && parseInt(newDay) >= 1 && parseInt(newDay) <= 31 ) { - if (isValidDate(year, month, newDay) && onChange) { + const modifiedDay = isFromSpinner ? newDay.padStart(2, "0") : newDay; + if (isValidDate(year, month, modifiedDay) && onChange) { const updatedDate = new Date( parseInt(year), parseInt(month) - 1, - parseInt(newDay), + parseInt(modifiedDay), ); onChange(updatedDate); } @@ -66,15 +72,23 @@ export default function DateField({ const newMonth = e.target.value; setMonth(newMonth); + // Check if change is from spinner (stepUp/stepDown) vs keyboard input + const isFromSpinner = + e.nativeEvent instanceof InputEvent && + (e.nativeEvent as InputEvent).inputType === "insertReplacementText"; + if ( - newMonth.length === 2 && + (isFromSpinner || newMonth.length === 2) && parseInt(newMonth) >= 1 && parseInt(newMonth) <= 12 ) { - if (isValidDate(year, newMonth, day) && onChange) { + const modifiedMonth = isFromSpinner + ? newMonth.padStart(2, "0") + : newMonth; + if (isValidDate(year, modifiedMonth, day) && onChange) { const updatedDate = new Date( parseInt(year), - parseInt(newMonth) - 1, + parseInt(modifiedMonth) - 1, parseInt(day), ); onChange(updatedDate); @@ -117,30 +131,12 @@ export default function DateField({ // Handle month blur to pad single digit values const handleMonthBlur = () => { if (month.length === 1 && parseInt(month) >= 1) { - setYear(year); - if (isValidDate(year, month, day) && onChange) { - const updatedDate = new Date( - parseInt(year), - parseInt(year) - 1, - parseInt(day), - ); - onChange(updatedDate); - } - } - }; - - const handleYearBlur = () => { - const currYear = new Date().getFullYear(); - if ( - year.length === 4 && - parseInt(year) >= 1900 && - parseInt(year) <= currYear - ) { - setDay(year); - if (isValidDate(year, month, day) && onChange) { + const paddedMonth = month.padStart(2, "0"); + setMonth(paddedMonth); + if (isValidDate(year, paddedMonth, day) && onChange) { const updatedDate = new Date( parseInt(year), - parseInt(month) - 1, + parseInt(paddedMonth) - 1, parseInt(day), ); onChange(updatedDate); @@ -189,7 +185,6 @@ export default function DateField({ placeholder="YYYY" value={year} onChange={handleYearChange} - onBlur={handleYearBlur} min={1900} max={new Date().getFullYear()} id={`${id}-year-input`} From 4dfd361d33e54c45972fb380f038bdd47eebcfe2 Mon Sep 17 00:00:00 2001 From: Jacob John Jeevan Date: Thu, 6 Feb 2025 01:08:19 +0530 Subject: [PATCH 08/19] minor cleanup --- src/components/Patient/PatientRegistration.tsx | 1 - src/components/ui/date-field.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/components/Patient/PatientRegistration.tsx b/src/components/Patient/PatientRegistration.tsx index 14dae246637..14b062f38f1 100644 --- a/src/components/Patient/PatientRegistration.tsx +++ b/src/components/Patient/PatientRegistration.tsx @@ -169,7 +169,6 @@ export default function PatientRegistration( partial_id: resp?.id?.slice(0, 5), }, }); - console.log(resp.date_of_birth); }, onError: () => { toast.error(t("patient_registration_error")); diff --git a/src/components/ui/date-field.tsx b/src/components/ui/date-field.tsx index 7893f9beb6e..b82ad00c9fc 100644 --- a/src/components/ui/date-field.tsx +++ b/src/components/ui/date-field.tsx @@ -29,7 +29,6 @@ export default function DateField({ const [month, setMonth] = useState(""); const [year, setYear] = useState(""); - // Only set initial values from `date` prop without padding useEffect(() => { if (date) { setDay(date.getDate().toString().padStart(2, "0")); From e1b3c374952dfd4d5770676fabbe5185d266d067 Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Thu, 6 Feb 2025 18:02:12 +0530 Subject: [PATCH 09/19] revert unwanted changes --- .../Facility/settings/locations/LocationView.tsx | 14 +++++++------- src/pages/Organization/OrganizationUsers.tsx | 4 ++-- src/pages/Organization/components/AddUserSheet.tsx | 2 +- .../Organization/components/LinkUserSheet.tsx | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pages/Facility/settings/locations/LocationView.tsx b/src/pages/Facility/settings/locations/LocationView.tsx index 9b1e89c39f8..d5527d5fe4f 100644 --- a/src/pages/Facility/settings/locations/LocationView.tsx +++ b/src/pages/Facility/settings/locations/LocationView.tsx @@ -95,10 +95,10 @@ export default function LocationView({ id, facilityId }: Props) { return ( -
-
-
-
+
+
+
+

{t("locations")}

{getLocationFormLabel(location?.form)} @@ -117,7 +117,7 @@ export default function LocationView({ id, facilityId }: Props) { )}
-
+
@@ -136,7 +136,7 @@ export default function LocationView({ id, facilityId }: Props) { currentOrganizations={locationOrganizations.results} facilityId={facilityId} trigger={ - diff --git a/src/pages/Organization/OrganizationUsers.tsx b/src/pages/Organization/OrganizationUsers.tsx index 02efa8b4f44..479059fa9a3 100644 --- a/src/pages/Organization/OrganizationUsers.tsx +++ b/src/pages/Organization/OrganizationUsers.tsx @@ -57,7 +57,7 @@ export default function OrganizationUsers({ id, navOrganizationId }: Props) { return (
-
+
-
+
{ diff --git a/src/pages/Organization/components/AddUserSheet.tsx b/src/pages/Organization/components/AddUserSheet.tsx index b6054eb4a56..1efba82ca81 100644 --- a/src/pages/Organization/components/AddUserSheet.tsx +++ b/src/pages/Organization/components/AddUserSheet.tsx @@ -33,7 +33,7 @@ export default function AddUserSheet({ return ( - diff --git a/src/pages/Organization/components/LinkUserSheet.tsx b/src/pages/Organization/components/LinkUserSheet.tsx index cee05d79724..967783d61be 100644 --- a/src/pages/Organization/components/LinkUserSheet.tsx +++ b/src/pages/Organization/components/LinkUserSheet.tsx @@ -111,7 +111,7 @@ export default function LinkUserSheet({ return ( - From a32aeef8e050834ff74c9c5c5e1235045c345ff5 Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Sun, 9 Feb 2025 13:46:54 +0530 Subject: [PATCH 10/19] fix responsiveness --- .../Medicine/MedicationRequestTable/index.tsx | 4 +- .../Patient/PatientRegistration.tsx | 8 +-- src/components/ui/date-field.tsx | 64 +++---------------- 3 files changed, 13 insertions(+), 63 deletions(-) diff --git a/src/components/Medicine/MedicationRequestTable/index.tsx b/src/components/Medicine/MedicationRequestTable/index.tsx index 389093ae429..fd5c5e1c66a 100644 --- a/src/components/Medicine/MedicationRequestTable/index.tsx +++ b/src/components/Medicine/MedicationRequestTable/index.tsx @@ -114,7 +114,7 @@ export default function MedicationRequestTable({
- +
-
+
= 1 && parseInt(newDay) <= 31 ) { - const modifiedDay = isFromSpinner ? newDay.padStart(2, "0") : newDay; - if (isValidDate(year, month, modifiedDay) && onChange) { + if (isValidDate(year, month, newDay) && onChange) { const updatedDate = new Date( parseInt(year), parseInt(month) - 1, - parseInt(modifiedDay), + parseInt(newDay), ); onChange(updatedDate); } + document.getElementById(`${id}-month-input`)?.focus(); } }; @@ -71,27 +66,21 @@ export default function DateField({ const newMonth = e.target.value; setMonth(newMonth); - // Check if change is from spinner (stepUp/stepDown) vs keyboard input - const isFromSpinner = - e.nativeEvent instanceof InputEvent && - (e.nativeEvent as InputEvent).inputType === "insertReplacementText"; - if ( - (isFromSpinner || newMonth.length === 2) && + newMonth.length === 2 && parseInt(newMonth) >= 1 && parseInt(newMonth) <= 12 ) { - const modifiedMonth = isFromSpinner - ? newMonth.padStart(2, "0") - : newMonth; - if (isValidDate(year, modifiedMonth, day) && onChange) { + if (isValidDate(year, newMonth, day) && onChange) { const updatedDate = new Date( parseInt(year), - parseInt(modifiedMonth) - 1, + parseInt(newMonth) - 1, parseInt(day), ); onChange(updatedDate); } + + document.getElementById(`${id}-year-input`)?.focus(); } }; @@ -111,38 +100,6 @@ export default function DateField({ } }; - // Handle day blur to pad single digit values - const handleDayBlur = () => { - if (day.length === 1 && parseInt(day) >= 1 && parseInt(day) <= 9) { - const paddedDay = day.padStart(2, "0"); - setDay(paddedDay); - if (isValidDate(year, month, paddedDay) && onChange) { - const updatedDate = new Date( - parseInt(year), - parseInt(month) - 1, - parseInt(paddedDay), - ); - onChange(updatedDate); - } - } - }; - - // Handle month blur to pad single digit values - const handleMonthBlur = () => { - if (month.length === 1 && parseInt(month) >= 1) { - const paddedMonth = month.padStart(2, "0"); - setMonth(paddedMonth); - if (isValidDate(year, paddedMonth, day) && onChange) { - const updatedDate = new Date( - parseInt(year), - parseInt(paddedMonth) - 1, - parseInt(day), - ); - onChange(updatedDate); - } - } - }; - return (
@@ -152,7 +109,6 @@ export default function DateField({ placeholder="DD" value={day} onChange={handleDayChange} - onBlur={handleDayBlur} min={1} max={31} id={`${id}-day-input`} @@ -168,7 +124,6 @@ export default function DateField({ placeholder="MM" value={month} onChange={handleMonthChange} - onBlur={handleMonthBlur} min={1} max={12} id={`${id}-month-input`} @@ -185,7 +140,6 @@ export default function DateField({ value={year} onChange={handleYearChange} min={1900} - max={new Date().getFullYear()} id={`${id}-year-input`} data-cy={`${id}-year-input`} disabled={disabled} From ebdc9627d2242cb723dd98eae5a15c2c0c13c3b8 Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Tue, 11 Feb 2025 00:35:31 +0530 Subject: [PATCH 11/19] minor change --- src/components/Medicine/MedicationRequestTable/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Medicine/MedicationRequestTable/index.tsx b/src/components/Medicine/MedicationRequestTable/index.tsx index fd5c5e1c66a..31196483599 100644 --- a/src/components/Medicine/MedicationRequestTable/index.tsx +++ b/src/components/Medicine/MedicationRequestTable/index.tsx @@ -114,7 +114,7 @@ export default function MedicationRequestTable({
- + Date: Sun, 16 Feb 2025 14:23:38 +0530 Subject: [PATCH 12/19] solved type error --- src/components/Common/AvatarEditModal.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Common/AvatarEditModal.tsx b/src/components/Common/AvatarEditModal.tsx index 3c278ea80b0..c1209b705fc 100644 --- a/src/components/Common/AvatarEditModal.tsx +++ b/src/components/Common/AvatarEditModal.tsx @@ -90,7 +90,13 @@ const AvatarEditModal = ({ setSelectedFile(myFile); }); }; - + const stopCamera = useCallback(() => { + const openCamera = webRef.current?.photo?.srcObject as MediaStream; + if (openCamera) { + openCamera.getTracks().forEach((track) => track.stop()); + } + setIsCameraOpen(false); + }, []); const closeModal = () => { setPreview(undefined); setIsProcessing(false); @@ -410,7 +416,7 @@ const AvatarEditModal = ({ onClick={() => { setPreviewImage(null); setIsCameraOpen(false); - webRef.current.stopCamera(); + stopCamera(); }} disabled={isProcessing} > From 4db802e80681b63e3a1f1a9b21ded2a8661dc65f Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Mon, 17 Feb 2025 14:21:11 +0530 Subject: [PATCH 13/19] updated with requested changes --- src/components/Common/AvatarEditModal.tsx | 39 +++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/components/Common/AvatarEditModal.tsx b/src/components/Common/AvatarEditModal.tsx index c1209b705fc..d6a473dd367 100644 --- a/src/components/Common/AvatarEditModal.tsx +++ b/src/components/Common/AvatarEditModal.tsx @@ -62,8 +62,8 @@ const AvatarEditModal = ({ const [selectedFile, setSelectedFile] = useState(); const [preview, setPreview] = useState(); const [isCameraOpen, setIsCameraOpen] = useState(false); - const webRef = useRef(null); - const [previewImage, setPreviewImage] = useState(null); + const webRef = useRef(null); + const [previewImage, setPreviewImage] = useState(null); const [isCaptureImgBeingUploaded, setIsCaptureImgBeingUploaded] = useState(false); const [constraint, setConstraint] = useState( @@ -81,21 +81,34 @@ const AvatarEditModal = ({ }, []); const captureImage = () => { - setPreviewImage(webRef.current.getScreenshot()); - const canvas = webRef.current.getCanvas(); - canvas?.toBlob((blob: Blob) => { - const myFile = new File([blob], "image.png", { - type: blob.type, - }); - setSelectedFile(myFile); + if (webRef.current) { + setPreviewImage(webRef.current.getScreenshot()); + } + const canvas = webRef.current?.getCanvas(); + canvas?.toBlob((blob) => { + if (blob) { + const myFile = new File([blob], "image.png", { + type: blob.type, + }); + setSelectedFile(myFile); + } else { + toast.error(t("failed_to_capture_image")); + } }); }; const stopCamera = useCallback(() => { - const openCamera = webRef.current?.photo?.srcObject as MediaStream; - if (openCamera) { - openCamera.getTracks().forEach((track) => track.stop()); + try { + if (webRef.current) { + const openCamera = webRef.current?.video?.srcObject as MediaStream; + if (openCamera) { + openCamera.getTracks().forEach((track) => track.stop()); + } + } + } catch (error: any) { + toast.error("Failed to stop camera: ", error); + } finally { + setIsCameraOpen(false); } - setIsCameraOpen(false); }, []); const closeModal = () => { setPreview(undefined); From b61eec450e59c91e66399cdf5d275f3cd96b3501 Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Thu, 20 Feb 2025 14:42:01 +0530 Subject: [PATCH 14/19] update ui --- src/components/Users/UserBanner.tsx | 20 ++++++++++++-------- src/components/Users/UserViewDetails.tsx | 10 +++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/components/Users/UserBanner.tsx b/src/components/Users/UserBanner.tsx index f48388f8540..1a39ed6acce 100644 --- a/src/components/Users/UserBanner.tsx +++ b/src/components/Users/UserBanner.tsx @@ -12,29 +12,33 @@ export default function UserBanner({ userData }: { userData: UserBase }) { return (
-
+
-
+
-

+

{formatName(userData)} -

+

- +
- {userData.username} - +

diff --git a/src/components/Users/UserViewDetails.tsx b/src/components/Users/UserViewDetails.tsx index cdb72dc5b48..8c1833b8878 100644 --- a/src/components/Users/UserViewDetails.tsx +++ b/src/components/Users/UserViewDetails.tsx @@ -16,10 +16,10 @@ const LabelValue = ({ id?: string; }) => (
- {label} - +

{label}

+

{value || "-"} - +

); @@ -38,14 +38,14 @@ export const Badge = ({ return (
- {text} - +
); }; From de6422acc7f9e8cd2dfda5205477b9ff5bd10d8a Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Thu, 20 Feb 2025 14:44:06 +0530 Subject: [PATCH 15/19] updated code --- src/components/Common/AvatarEditModal.tsx | 41 ++++++----------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/src/components/Common/AvatarEditModal.tsx b/src/components/Common/AvatarEditModal.tsx index d6a473dd367..3c278ea80b0 100644 --- a/src/components/Common/AvatarEditModal.tsx +++ b/src/components/Common/AvatarEditModal.tsx @@ -62,8 +62,8 @@ const AvatarEditModal = ({ const [selectedFile, setSelectedFile] = useState(); const [preview, setPreview] = useState(); const [isCameraOpen, setIsCameraOpen] = useState(false); - const webRef = useRef(null); - const [previewImage, setPreviewImage] = useState(null); + const webRef = useRef(null); + const [previewImage, setPreviewImage] = useState(null); const [isCaptureImgBeingUploaded, setIsCaptureImgBeingUploaded] = useState(false); const [constraint, setConstraint] = useState( @@ -81,35 +81,16 @@ const AvatarEditModal = ({ }, []); const captureImage = () => { - if (webRef.current) { - setPreviewImage(webRef.current.getScreenshot()); - } - const canvas = webRef.current?.getCanvas(); - canvas?.toBlob((blob) => { - if (blob) { - const myFile = new File([blob], "image.png", { - type: blob.type, - }); - setSelectedFile(myFile); - } else { - toast.error(t("failed_to_capture_image")); - } + setPreviewImage(webRef.current.getScreenshot()); + const canvas = webRef.current.getCanvas(); + canvas?.toBlob((blob: Blob) => { + const myFile = new File([blob], "image.png", { + type: blob.type, + }); + setSelectedFile(myFile); }); }; - const stopCamera = useCallback(() => { - try { - if (webRef.current) { - const openCamera = webRef.current?.video?.srcObject as MediaStream; - if (openCamera) { - openCamera.getTracks().forEach((track) => track.stop()); - } - } - } catch (error: any) { - toast.error("Failed to stop camera: ", error); - } finally { - setIsCameraOpen(false); - } - }, []); + const closeModal = () => { setPreview(undefined); setIsProcessing(false); @@ -429,7 +410,7 @@ const AvatarEditModal = ({ onClick={() => { setPreviewImage(null); setIsCameraOpen(false); - stopCamera(); + webRef.current.stopCamera(); }} disabled={isProcessing} > From ad537e22765640ea1988eb26ee70f714f8b34a24 Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Thu, 20 Feb 2025 14:54:54 +0530 Subject: [PATCH 16/19] minor updation --- src/components/Users/UserBanner.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Users/UserBanner.tsx b/src/components/Users/UserBanner.tsx index 1a39ed6acce..6a90539747e 100644 --- a/src/components/Users/UserBanner.tsx +++ b/src/components/Users/UserBanner.tsx @@ -21,9 +21,9 @@ export default function UserBanner({ userData }: { userData: UserBase }) { />
-

+

{formatName(userData)} -

+

Date: Fri, 21 Feb 2025 12:36:21 +0530 Subject: [PATCH 17/19] minor changes --- src/components/Users/UserBanner.tsx | 26 ++++++++++++++---------- src/components/Users/UserViewDetails.tsx | 11 ++++++---- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/components/Users/UserBanner.tsx b/src/components/Users/UserBanner.tsx index 6a90539747e..054fca80c03 100644 --- a/src/components/Users/UserBanner.tsx +++ b/src/components/Users/UserBanner.tsx @@ -1,6 +1,7 @@ import { Avatar } from "@/components/Common/Avatar"; import { formatDisplayName, formatName } from "@/Utils/utils"; +import { TooltipComponent } from "@/src/components/ui/tooltip"; import { UserBase } from "@/types/user/user"; import { UserStatusIndicator } from "./UserListAndCard"; @@ -17,13 +18,15 @@ export default function UserBanner({ userData }: { userData: UserBase }) {
-

- {formatName(userData)} -

+ +

+ {formatName(userData)} +

+
- -

- {userData.username} -

+ +

+ {userData.username} +

+
diff --git a/src/components/Users/UserViewDetails.tsx b/src/components/Users/UserViewDetails.tsx index 8c1833b8878..31832500998 100644 --- a/src/components/Users/UserViewDetails.tsx +++ b/src/components/Users/UserViewDetails.tsx @@ -1,5 +1,6 @@ import { useTranslation } from "react-i18next"; +import { TooltipComponent } from "@/src/components/ui/tooltip"; import { UserBase } from "@/types/user/user"; interface UserViewDetailsProps { @@ -16,10 +17,12 @@ const LabelValue = ({ id?: string; }) => (
-

{label}

-

- {value || "-"} -

+

{label}

+ + + {value || "-"} + +
); From 49ef1b6319f77168d17294e9f9e29770e22e02ee Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Fri, 21 Feb 2025 13:03:14 +0530 Subject: [PATCH 18/19] minor changes --- src/components/Users/UserBanner.tsx | 3 ++- src/components/Users/UserViewDetails.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/Users/UserBanner.tsx b/src/components/Users/UserBanner.tsx index 054fca80c03..1e63ce839f3 100644 --- a/src/components/Users/UserBanner.tsx +++ b/src/components/Users/UserBanner.tsx @@ -1,7 +1,8 @@ +import { TooltipComponent } from "@/components/ui/tooltip"; + import { Avatar } from "@/components/Common/Avatar"; import { formatDisplayName, formatName } from "@/Utils/utils"; -import { TooltipComponent } from "@/src/components/ui/tooltip"; import { UserBase } from "@/types/user/user"; import { UserStatusIndicator } from "./UserListAndCard"; diff --git a/src/components/Users/UserViewDetails.tsx b/src/components/Users/UserViewDetails.tsx index 31832500998..d9e1c4cb7a8 100644 --- a/src/components/Users/UserViewDetails.tsx +++ b/src/components/Users/UserViewDetails.tsx @@ -1,6 +1,7 @@ import { useTranslation } from "react-i18next"; -import { TooltipComponent } from "@/src/components/ui/tooltip"; +import { TooltipComponent } from "@/components/ui/tooltip"; + import { UserBase } from "@/types/user/user"; interface UserViewDetailsProps { From a254028a0c0f253ccd748f490a4a59e8a9a0c334 Mon Sep 17 00:00:00 2001 From: Tanuj Nainwal Date: Fri, 28 Feb 2025 20:21:30 +0530 Subject: [PATCH 19/19] minor cleanup --- src/components/Users/UserBanner.tsx | 2 +- src/components/Users/UserViewDetails.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Users/UserBanner.tsx b/src/components/Users/UserBanner.tsx index 1e63ce839f3..1f5b9e187a9 100644 --- a/src/components/Users/UserBanner.tsx +++ b/src/components/Users/UserBanner.tsx @@ -19,7 +19,7 @@ export default function UserBanner({ userData }: { userData: UserBase }) {
diff --git a/src/components/Users/UserViewDetails.tsx b/src/components/Users/UserViewDetails.tsx index d9e1c4cb7a8..67525798bbd 100644 --- a/src/components/Users/UserViewDetails.tsx +++ b/src/components/Users/UserViewDetails.tsx @@ -42,14 +42,14 @@ export const Badge = ({ return (
-
{text} -
+
); };