import React, { Component } from 'react'; import ReactAudioPlayer from 'react-audio-player'; import ReactPlayer from 'react-player'; import CloudDownloadIcon from '@material-ui/icons/CloudDownload'; import Avatar from '@material-ui/core/Avatar'; import moment from 'jalali-moment'; import DoneIcon from '@material-ui/icons/Done'; import DoneAllIcon from '@material-ui/icons/DoneAll'; import EditIcon from '@material-ui/icons/Edit'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import './index.scss'; import Menu from '@material-ui/core/Menu'; import MenuItem from '@material-ui/core/MenuItem'; import ReplyIcon from '@material-ui/icons/Reply'; import ForwardIcon from '@material-ui/icons/Forward'; import DeleteIcon from '@material-ui/icons/Delete'; import FavoriteIcon from '@material-ui/icons/Favorite'; import TextsmsIcon from '@material-ui/icons/Textsms'; import ScheduleIcon from '@material-ui/icons/Schedule'; const file = (fileId) => `${window.baseURL}/file/download/${fileId}`; const menu = [ { text: 'پسند', icon: FavoriteIcon, onClick: () => {} }, { text: 'تبادل نظر', icon: TextsmsIcon, onClick: () => {} }, { text: 'پاسخ', icon: ReplyIcon, onClick: () => {} }, { text: 'باز ارسال', icon: ForwardIcon, onClick: () => {} }, ]; const selfMenu = [ { text: 'باز ارسال', icon: ForwardIcon, onClick: () => {} }, { text: 'ویرایش', icon: EditIcon, onClick: () => {} }, { text: 'حذف', icon: DeleteIcon, onClick: () => {} }, ]; export default class NormalMessage extends Component { state = { messageMenu: null }; handleClose = () => { this.setState({ messageMenu: null, }); }; handleClick = (event) => { this.setState({ messageMenu: event.currentTarget, }); }; render() { const { message, user, document, isSelf, prevUserId, children } = this.props; const { messageMenu } = this.state; const hasavatar = prevUserId != message.userId; return (
{hasavatar && ( {user.name .split(' ') .map((e) => e.slice(0, 1)) .join(' ')} )}
this.handleClose()} className="rtl fontLight" > {(isSelf ? selfMenu : menu).map((e) => ( { this.handleClose(); e.onClick(); }} > {e.text} ))} {hasavatar &&
{user.name}
}
{message.type == 'text' ? (

{message.text}

) : null} {message.type == 'voice' ? ( ) : null} {message.type == 'image' ? (

{message.text}

) : null} {message.type == 'video' ? (

{message.text}

) : null} {message.type == 'audio' ? (

{message.text}

) : null} {message.type == 'document' ? (
{message.text}
) : null}
{message.updatedAt != message.createdAt ? ( <> ویرایش در {moment(message.updatedAt).format(' hh:mm jMM/jDD')} ) : ( moment(message.createdAt).format('hh:mm') )} {isSelf && message.status == 0 && } {isSelf && message.status == 1 && } {isSelf && message.status == 2 && }
{!isSelf ? ( <> {' '}
{10}
{10}
) : ( <>
+5
خلاقیت
)}
{children}
); } }