Skip to content

Commit

Permalink
remove hardcoded date encounter notes (#10382)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Feb 4, 2025
1 parent 4ae9cae commit 525dac8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
30 changes: 17 additions & 13 deletions src/pages/Encounters/tabs/EncounterNotesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
useQuery,
useQueryClient,
} from "@tanstack/react-query";
import { formatRelative } from "date-fns";
import {
Info,
Loader2,
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -105,8 +107,6 @@ const ThreadItem = ({
<div className="flex items-start justify-between gap-3">
<div className="flex-1 min-w-0">
<h4 className="font-medium text-sm truncate">{thread.title}</h4>
{/* Todo: Replace with thread.created */}
<p className="text-xs text-gray-500 mt-1">12/12/2024</p>
</div>
{isSelected && (
<div className="w-1.5 h-1.5 rounded-full bg-primary animate-pulse mt-1.5" />
Expand Down Expand Up @@ -156,21 +156,28 @@ const MessageItem = ({ message }: { message: Message }) => {
isCurrentUser ? "items-end" : "items-start",
)}
>
<span className="text-xs text-gray-500 mb-1">
{message.created_by.username}
</span>
<p className="text-xs space-x-2 mb-1">
<span className="text-gray-700 font-medium">
{message.created_by.username}
</span>
<time
className="text-gray-500"
dateTime={message.created_date}
title={formatDateTime(message.created_date)}
>
{formatRelative(message.created_date, new Date())}
</time>
</p>
<div
className={cn(
"p-3 rounded-lg break-words",
isCurrentUser
? "bg-primary-100 text-white rounded-br-none"
: "bg-gray-100 rounded-bl-none",
? "bg-white text-black rounded-tr-none border border-gray-200"
: "bg-gray-100 rounded-tl-none border border-gray-200",
)}
>
{message.message && (
<div className="mt-4">
<Markdown content={message.message} className="text-sm" />
</div>
<Markdown content={message.message} className="text-sm" />
)}
</div>
</div>
Expand Down Expand Up @@ -379,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
Expand Down
4 changes: 3 additions & 1 deletion src/types/notes/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { UserBase } from "@/types/user/user";

export interface Message {
id: string;
message: string;
message: string; // Markdown
message_history: Record<string, unknown>;
created_by: UserBase;
updated_by: UserBase;
created_date: string;
modified_date: string;
}

0 comments on commit 525dac8

Please sign in to comment.