From ba247f44e31270f5a3947d33d114e420b97d51f1 Mon Sep 17 00:00:00 2001 From: ahmedobaid23 Date: Thu, 25 Jul 2024 23:43:27 +0500 Subject: [PATCH 1/4] Changes 'CONSULTATION NOTES' to 'GENERAL INSTRUCTIONS (ADVICE)' --- .../Facility/ConsultationDetails/Events/GenericEvent.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index 414b86fecbe..962dd925402 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -85,7 +85,9 @@ export default function GenericEvent(props: IProps) { {Object.entries(props.values).map(([key, value]) => (
- {key.replaceAll(/_/g, " ")} + {key === "consultation_notes" + ? "General Instructions (Advice)" + : key.replaceAll(/_/g, " ")} {formatValue(value, key)} From a6047f88ab0dae03858953f4b5a7741e35740f22 Mon Sep 17 00:00:00 2001 From: ahmedobaid23 Date: Fri, 26 Jul 2024 17:46:15 +0500 Subject: [PATCH 2/4] Minor Changes --- .../ConsultationDetails/Events/GenericEvent.tsx | 16 +++++++++++----- src/Locale/en/Consultation.json | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index 962dd925402..860888bfe0a 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -1,8 +1,10 @@ import type { ReactNode } from "react"; +import consultationMessage from "../../../../../src/Locale/en/Consultation.json"; interface IProps { values: Record; } +type ConsultationMessageKeys = keyof typeof consultationMessage; /** * object - array, date */ @@ -84,11 +86,15 @@ export default function GenericEvent(props: IProps) {
{Object.entries(props.values).map(([key, value]) => (
- - {key === "consultation_notes" - ? "General Instructions (Advice)" - : key.replaceAll(/_/g, " ")} - + {(key as ConsultationMessageKeys) in consultationMessage ? ( + + {consultationMessage[key as ConsultationMessageKeys]} + + ) : ( + + {key.replaceAll(/_/g, " ")} + + )} {formatValue(value, key)} diff --git a/src/Locale/en/Consultation.json b/src/Locale/en/Consultation.json index d811680d0fd..2fdb2406d28 100644 --- a/src/Locale/en/Consultation.json +++ b/src/Locale/en/Consultation.json @@ -44,5 +44,6 @@ "encounter_date_field_label__HI": "Date & Time of Consultation", "encounter_date_field_label__R": "Date & Time of Consultation", "back_dated_encounter_date_caution": "You are creating an encounter for", - "encounter_duration_confirmation": "The duration of this encounter would be" + "encounter_duration_confirmation": "The duration of this encounter would be", + "consultation_notes": "General Instructions (Advice)" } \ No newline at end of file From 3fc8e35a15184d7707d24481027b780a45e4c6b0 Mon Sep 17 00:00:00 2001 From: ahmedobaid23 Date: Mon, 29 Jul 2024 16:34:04 +0500 Subject: [PATCH 3/4] Minor changes --- src/CAREUI/display/Timeline.tsx | 14 +++++++++++--- .../ConsultationDetails/Events/EventsList.tsx | 17 ++++++++++------- .../ConsultationDetails/Events/GenericEvent.tsx | 17 ++++++----------- src/Locale/en/Consultation.json | 3 ++- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/CAREUI/display/Timeline.tsx b/src/CAREUI/display/Timeline.tsx index bbbf5e24859..557e1694182 100644 --- a/src/CAREUI/display/Timeline.tsx +++ b/src/CAREUI/display/Timeline.tsx @@ -92,9 +92,17 @@ export const TimelineNode = (props: TimelineNodeProps) => { }`}{" "} )} - {props.titleSuffix - ? props.titleSuffix - : `${props.event.type} the ${props.name || name}.`} + {props.titleSuffix ? ( + props.titleSuffix + ) : ( + <> + {props.event.type} {t(" the")} + + {" "} + {props.name || name} + + + )}

{props.actions && ( diff --git a/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx b/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx index cf997dca4b3..dc94e2e32b5 100644 --- a/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx @@ -30,13 +30,16 @@ export default function EventsList() { {(item, items) => ( - text[0].toUpperCase() + text.toLowerCase().slice(1), - ) - .join(" ") + " Event" + t(item.event_type.name.toLowerCase()).replaceAll( + /_/g, + " ", + ) + " Event" + // .split("_") + // .map( + // (text) => + // text[0].toUpperCase() + text.toLowerCase().slice(1), + // ) + // .join(" ") + " Event" } event={{ type: item.change_type.replace(/_/g, " ").toLowerCase(), diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index 860888bfe0a..ca9c13c599b 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -1,10 +1,10 @@ import type { ReactNode } from "react"; -import consultationMessage from "../../../../../src/Locale/en/Consultation.json"; +import { useTranslation } from "react-i18next"; + interface IProps { values: Record; } -type ConsultationMessageKeys = keyof typeof consultationMessage; /** * object - array, date */ @@ -82,19 +82,14 @@ const formatValue = (value: unknown, key?: string): ReactNode => { }; export default function GenericEvent(props: IProps) { + const { t } = useTranslation(); return (
{Object.entries(props.values).map(([key, value]) => (
- {(key as ConsultationMessageKeys) in consultationMessage ? ( - - {consultationMessage[key as ConsultationMessageKeys]} - - ) : ( - - {key.replaceAll(/_/g, " ")} - - )} + + {t(key).replaceAll(/_/g, " ")} + {formatValue(value, key)} diff --git a/src/Locale/en/Consultation.json b/src/Locale/en/Consultation.json index d811680d0fd..2fdb2406d28 100644 --- a/src/Locale/en/Consultation.json +++ b/src/Locale/en/Consultation.json @@ -44,5 +44,6 @@ "encounter_date_field_label__HI": "Date & Time of Consultation", "encounter_date_field_label__R": "Date & Time of Consultation", "back_dated_encounter_date_caution": "You are creating an encounter for", - "encounter_duration_confirmation": "The duration of this encounter would be" + "encounter_duration_confirmation": "The duration of this encounter would be", + "consultation_notes": "General Instructions (Advice)" } \ No newline at end of file From 85109ac1047c9156a4c19b9106310ce017f72af7 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 29 Jul 2024 17:11:58 +0530 Subject: [PATCH 4/4] Apply suggestions from Code Review --- src/CAREUI/display/Timeline.tsx | 11 +++-------- .../ConsultationDetails/Events/EventsList.tsx | 6 ------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/CAREUI/display/Timeline.tsx b/src/CAREUI/display/Timeline.tsx index 557e1694182..7fcb57f56ea 100644 --- a/src/CAREUI/display/Timeline.tsx +++ b/src/CAREUI/display/Timeline.tsx @@ -92,15 +92,10 @@ export const TimelineNode = (props: TimelineNodeProps) => { }`}{" "} )} - {props.titleSuffix ? ( - props.titleSuffix - ) : ( + {props.titleSuffix || ( <> - {props.event.type} {t(" the")} - - {" "} - {props.name || name} - + {`${props.event.type} the `} + {props.name || name} )}

diff --git a/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx b/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx index dc94e2e32b5..f759559c1a1 100644 --- a/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx @@ -34,12 +34,6 @@ export default function EventsList() { /_/g, " ", ) + " Event" - // .split("_") - // .map( - // (text) => - // text[0].toUpperCase() + text.toLowerCase().slice(1), - // ) - // .join(" ") + " Event" } event={{ type: item.change_type.replace(/_/g, " ").toLowerCase(),