import { Box, Link, Typography, useMediaQuery, useTheme } from "@mui/material"; import { isDateToday } from "../../utils/date"; import Download from "@root/assets/Icons/download"; interface Props { unAuthenticated?: boolean; isSelf: boolean; file: string; createdAt: string; } export default function ChatDocument({ unAuthenticated = false, isSelf, file, createdAt, }: Props) { const theme = useTheme(); const upMd = useMediaQuery(theme.breakpoints.up("md")); 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} ); }