import { useAttachment } from "@/app/providers/AttachmentProvider/useAttachment"; import { AttachmentProps } from "./MessageAttachments"; import { Avatar, Box, Flex, Text } from "@mantine/core"; import { useRosettaColors } from "@/app/hooks/useRosettaColors"; import { IconPhoneOutgoing, IconX } from "@tabler/icons-react"; import { translateDurationToTime } from "@/app/providers/CallProvider/translateDurationTime"; export function MessageCall(props: AttachmentProps) { const { getPreview, } = useAttachment( props.attachment, props.parent, ); const preview = getPreview(); const callerRole = preview.split("::")[0]; const duration = parseInt(preview.split("::")[1]); const colors = useRosettaColors(); const error = duration == 0; return ( {!error && <> {callerRole == "0" && ( )} {callerRole == "1" && ( )} } {error && <> } { error ? (callerRole == "0" ? "Missed call" : "Rejected call") : (callerRole == "0" ? "Incoming call" : "Outgoing call") } {!error && {translateDurationToTime(duration)} } {error && Call was not answered or was rejected } ); }