import { Box, ButtonBase, Link, Typography, useMediaQuery, useTheme, } from "@mui/material"; import { isDateToday } from "../../utils/date"; import { useNavigate } from "react-router-dom"; interface Props { unAuthenticated?: boolean; isSelf: boolean; file: string; createdAt: string; } export default function ChatImage({ unAuthenticated = false, isSelf, file, createdAt, }: Props) { const theme = useTheme(); const upMd = useMediaQuery(theme.breakpoints.up("md")); const navigate = useNavigate(); const messageBackgroundColor = isSelf ? "white" : unAuthenticated ? "#EFF0F5" : "#434657"; const date = new Date(createdAt); const today = isDateToday(date); const time = date.toLocaleString([], { hour: "2-digit", minute: "2-digit", ...(!today && { year: "2-digit", month: "2-digit", day: "2-digit", }), }); return ( {time} ); }