import Avatar from '@components/Avatar'; import PopupMenu from '@components/PopupMenu'; import Like from '@components/Like'; import { getMeInfo } from '@controllers/UserController'; import { useQuery } from '@tanstack/react-query'; import { toastError } from '@controllers/Toasts'; import User from './User'; import Image from './Image'; import { useState } from 'react'; const Text = ({ text }: { text: string }) => { if (text === '') { return null; } return
{text}
; }; const Message = ({ message }: any) => { const me = useQuery(['me'], getMeInfo, { onSuccess: (data) => { return data; }, onError: (error) => { toastError(error as string); }, }); return ( <>
{message.author && }
{message.author && } {me.data?.id === message.author.id || me.data?.role === 'ADMIN' || me.data?.role === 'CREATOR' ? ( ) : null}
{message.image && image}
{new Date(message.createdAt).toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', })}
{message.edited &&
Modifié
}
{me.data?.id === message.author.id ? null : }
); }; export default Message;