From 57c2520d2898d5c9c33edcc819648979339a70c4 Mon Sep 17 00:00:00 2001 From: Abhiuday Date: Tue, 5 Mar 2024 21:17:14 +0530 Subject: [PATCH] fix(events): added nursing assistant name and no change text --- src/CAREUI/display/Timeline.tsx | 11 +++++++--- .../ConsultationDetails/Events/EventsList.tsx | 22 +++++++++++++++---- .../Events/GenericEvent.tsx | 9 ++++---- src/Locale/en/Consultation.json | 3 ++- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/CAREUI/display/Timeline.tsx b/src/CAREUI/display/Timeline.tsx index f8e7991d3bf..9889894ac47 100644 --- a/src/CAREUI/display/Timeline.tsx +++ b/src/CAREUI/display/Timeline.tsx @@ -1,4 +1,5 @@ import { createContext, useContext } from "react"; +import { useTranslation } from "react-i18next"; import { PerformedByModel } from "../../Components/HCX/misc"; import { classNames, formatName } from "../../Utils/utils"; import CareIcon, { IconName } from "../icons/CareIcon"; @@ -49,6 +50,7 @@ interface TimelineNodeProps { export const TimelineNode = (props: TimelineNodeProps) => { const name = useContext(TimelineContext); + const { t } = useTranslation(); return (
  • @@ -80,9 +82,12 @@ export const TimelineNode = (props: TimelineNodeProps) => {

    {props.event.by && ( - {formatName(props.event.by)}{" "} - {props.event.by.user_type && - `(${props.event.by.user_type}) `} + {props.event.by.username.startsWith("asset") + ? t("virtual_nursing_assistant") + : `${formatName(props.event.by)} ${ + props.event.by.user_type && + `(${props.event.by.user_type})` + }`}{" "} )} {props.titleSuffix diff --git a/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx b/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx index 36991333888..7122c7d1dd3 100644 --- a/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/EventsList.tsx @@ -1,12 +1,12 @@ import { useTranslation } from "react-i18next"; -import { useSlugs } from "../../../../Common/hooks/useSlug"; +import { TimelineNode } from "../../../../CAREUI/display/Timeline"; import PaginatedList from "../../../../CAREUI/misc/PaginatedList"; +import { useSlugs } from "../../../../Common/hooks/useSlug"; import routes from "../../../../Redux/api"; -import { TimelineNode } from "../../../../CAREUI/display/Timeline"; import LoadingLogUpdateCard from "../../Consultations/DailyRounds/LoadingCard"; import GenericEvent from "./GenericEvent"; -import { EventGeneric } from "./types"; import { getEventIcon } from "./iconMap"; +import { EventGeneric } from "./types"; export default function EventsList() { const [consultationId] = useSlugs("consultation"); @@ -47,6 +47,20 @@ export default function EventsList() { isLast={items.indexOf(item) == items.length - 1} > {(() => { + const values = Object.entries(item.value).filter( + ([_, value]) => value !== null && value !== undefined + ); + + if (values.length === 0) { + return ( +

    + + {t("no_changes")} + +
    + ); + } + switch (item.event_type.name) { case "INTERNAL_TRANSFER": case "CLINICAL": @@ -54,7 +68,7 @@ export default function EventsList() { case "ENCOUNTER_SUMMARY": case "HEALTH": default: - return ; + return ; } })()} diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index 4296bd4c34b..c454136c592 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -1,8 +1,6 @@ import type { ReactNode } from "react"; -import { EventGeneric } from "./types"; - interface IProps { - event: EventGeneric; + values: Record; } /** @@ -72,10 +70,11 @@ const formatValue = (value: unknown, key?: string): ReactNode => { return JSON.stringify(value); }; -export default function GenericEvent({ event }: IProps) { +export default function GenericEvent({ values }: IProps) { + console.log("value", values); return (
    - {Object.entries(event.value).map(([key, value]) => ( + {values.map(([key, value]: [string, any]) => (
    {key.replace(/_/g, " ")} diff --git a/src/Locale/en/Consultation.json b/src/Locale/en/Consultation.json index 99ff7b73314..42f31433495 100644 --- a/src/Locale/en/Consultation.json +++ b/src/Locale/en/Consultation.json @@ -33,5 +33,6 @@ "select_groups": "Select Groups", "generate_report": "Generate Report", "prev_sessions": "Prev Sessions", - "next_sessions": "Next Sessions" + "next_sessions": "Next Sessions", + "no_changes": "No changes" } \ No newline at end of file