Add datetime for chat
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
// UserMessage.jsx
|
||||
// src/UserMessage.jsx
|
||||
import React from "react";
|
||||
|
||||
export default function UserMessage({ content, theme }) {
|
||||
export default function UserMessage({ content, theme, timestamp }) {
|
||||
return (
|
||||
// This outer div aligns the *bubble* to the right
|
||||
<div className="mb-2 d-flex justify-content-end">
|
||||
<div className="mb-2 d-flex flex-column align-items-end">
|
||||
<div
|
||||
className={`p-2 rounded ${theme.userBg}`}
|
||||
style={{
|
||||
@@ -24,8 +23,37 @@ export default function UserMessage({ content, theme }) {
|
||||
{content}
|
||||
</pre>
|
||||
</div>
|
||||
{timestamp && (
|
||||
<div
|
||||
style={{
|
||||
fontSize: "0.75rem",
|
||||
color: "#666",
|
||||
marginTop: "0.2rem",
|
||||
marginRight: "0.25rem"
|
||||
}}
|
||||
>
|
||||
{formatDateTime(timestamp)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Same helper used in AssistantMessage
|
||||
function formatDateTime(dateTime) {
|
||||
try {
|
||||
const date = new Date(dateTime);
|
||||
return date.toLocaleString(undefined, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit"
|
||||
});
|
||||
} catch {
|
||||
return dateTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user