import { Box, Typography, useMediaQuery, useTheme } from "@mui/material"; import { isDateToday } from "@root/utils/date"; interface Props { unAuthenticated?: boolean; isSelf: boolean; text: string; createdAt: string; } export default function ChatMessage({ unAuthenticated = false, isSelf, text, createdAt }: Props) { const theme = useTheme(); const upMd = useMediaQuery(theme.breakpoints.up("md")); const messageBackgroundColor = isSelf ? "white" : unAuthenticated ? "#EFF0F5" : theme.palette.grey2.main; const date = new Date(createdAt); const time = date.toLocaleString([], { hour: "2-digit", minute: "2-digit", ...(!isDateToday(date) && { year: "2-digit", month: "2-digit", day: "2-digit" }) }); return ( {time} {text} ); }