Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Events(Beta) improvement #7345

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/CAREUI/display/Timeline.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -49,6 +50,7 @@ interface TimelineNodeProps {

export const TimelineNode = (props: TimelineNodeProps) => {
const name = useContext(TimelineContext);
const { t } = useTranslation();

return (
<li className="relative flex gap-x-4">
Expand Down Expand Up @@ -80,9 +82,12 @@ export const TimelineNode = (props: TimelineNodeProps) => {
<p className="flex-auto py-0.5 text-xs leading-5 text-gray-600 md:w-2/3">
{props.event.by && (
<span className="font-medium text-gray-900">
{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})`
}`}{" "}
</span>
)}
{props.titleSuffix
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -47,14 +47,28 @@ 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 (
<div className="flex w-full flex-col items-center gap-2 md:flex-row">
<span className="text-xs uppercase text-gray-700">
{t("no_changes")}
</span>
</div>
);
}

switch (item.event_type.name) {
case "INTERNAL_TRANSFER":
case "CLINICAL":
case "DIAGNOSIS":
case "ENCOUNTER_SUMMARY":
case "HEALTH":
default:
return <GenericEvent event={item} />;
return <GenericEvent values={values} />;
}
})()}
</TimelineNode>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { ReactNode } from "react";
import { EventGeneric } from "./types";

interface IProps {
event: EventGeneric;
values: Record<string, any>;
}

/**
Expand Down Expand Up @@ -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 (
<div className="flex w-full flex-col gap-4 rounded-lg border border-gray-400 p-4 @container">
{Object.entries(event.value).map(([key, value]) => (
{values.map(([key, value]: [string, any]) => (
<div className="flex w-full flex-col items-center gap-2 md:flex-row">
<span className="text-xs uppercase text-gray-700">
{key.replace(/_/g, " ")}
Expand Down
3 changes: 2 additions & 1 deletion src/Locale/en/Consultation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Loading