From ece081ae5539582af64f6e86fd76d6cbabd39969 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 4 Feb 2025 12:32:40 +0530 Subject: [PATCH] Enhance EncounterNotesTab message display with improved formatting and timestamps --- .../Encounters/tabs/EncounterNotesTab.tsx | 28 +++++++++++-------- src/types/notes/messages.ts | 4 ++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/pages/Encounters/tabs/EncounterNotesTab.tsx b/src/pages/Encounters/tabs/EncounterNotesTab.tsx index ce9454925fb..89b535134df 100644 --- a/src/pages/Encounters/tabs/EncounterNotesTab.tsx +++ b/src/pages/Encounters/tabs/EncounterNotesTab.tsx @@ -4,6 +4,7 @@ import { useQuery, useQueryClient, } from "@tanstack/react-query"; +import { formatRelative } from "date-fns"; import { Info, Loader2, @@ -52,6 +53,7 @@ import routes from "@/Utils/request/api"; import mutate from "@/Utils/request/mutate"; import query from "@/Utils/request/query"; import { PaginatedResponse } from "@/Utils/request/types"; +import { formatDateTime } from "@/Utils/utils"; import { EncounterTabProps } from "@/pages/Encounters/EncounterShow"; import { Message } from "@/types/notes/messages"; import { Thread } from "@/types/notes/threads"; @@ -154,21 +156,28 @@ const MessageItem = ({ message }: { message: Message }) => { isCurrentUser ? "items-end" : "items-start", )} > - - {message.created_by.username} - +

+ + {message.created_by.username} + + +

{message.message && ( -
- -
+ )}
@@ -377,9 +386,6 @@ export const EncounterNotesTab = ({ encounter }: EncounterTabProps) => { messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }); }, 100); }, - onError: () => { - toast.error(t("Failed to send message")); - }, }); // Handle infinite scroll diff --git a/src/types/notes/messages.ts b/src/types/notes/messages.ts index bca88676392..1178a6c0c4f 100644 --- a/src/types/notes/messages.ts +++ b/src/types/notes/messages.ts @@ -2,8 +2,10 @@ import { UserBase } from "@/types/user/user"; export interface Message { id: string; - message: string; + message: string; // Markdown message_history: Record; created_by: UserBase; updated_by: UserBase; + created_date: string; + modified_date: string; }