|
|
|
@ -16,6 +16,19 @@ 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 = () => { |
|
|
|
@ -64,11 +77,7 @@ export default class NormalMessage extends Component { |
|
|
|
|
> |
|
|
|
|
<div |
|
|
|
|
className={ |
|
|
|
|
message.voice === null && |
|
|
|
|
message.video === null && |
|
|
|
|
message.image === null && |
|
|
|
|
message.music === null && |
|
|
|
|
message.document === null |
|
|
|
|
message.type == 'text' |
|
|
|
|
? `normal-message__box ` |
|
|
|
|
: `normal-message__box normal-message__box--file` |
|
|
|
|
} |
|
|
|
@ -78,115 +87,73 @@ export default class NormalMessage extends Component { |
|
|
|
|
width: 'calc(100%-70px)', |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{message.voice === null && |
|
|
|
|
message.video === null && |
|
|
|
|
message.image === null && |
|
|
|
|
message.music === null && |
|
|
|
|
message.document === null ? ( |
|
|
|
|
<div |
|
|
|
|
className="normal-message__box--detail d-flex" |
|
|
|
|
style={{ |
|
|
|
|
top: 0, |
|
|
|
|
<div |
|
|
|
|
className="normal-message__box--detail d-flex" |
|
|
|
|
style={{ |
|
|
|
|
top: 0, |
|
|
|
|
|
|
|
|
|
direction: isSelf ? 'ltr' : 'rtl', |
|
|
|
|
paddingRight: isSelf ? 70 : 0, |
|
|
|
|
paddingLeft: isSelf ? 0 : 70, |
|
|
|
|
}} |
|
|
|
|
direction: isSelf ? 'ltr' : 'rtl', |
|
|
|
|
paddingRight: isSelf ? 70 : 0, |
|
|
|
|
paddingLeft: isSelf ? 0 : 70, |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<div style={{ color: isSelf ? '#aaa' : 'gray' }}> |
|
|
|
|
<ExpandMoreIcon fontSize="small" onClick={this.handleClick} /> |
|
|
|
|
</div> |
|
|
|
|
<Menu |
|
|
|
|
anchorEl={messageMenu} |
|
|
|
|
keepMounted |
|
|
|
|
open={Boolean(messageMenu)} |
|
|
|
|
onClose={() => this.handleClose()} |
|
|
|
|
className="rtl fontLight" |
|
|
|
|
> |
|
|
|
|
<div style={{ color: isSelf ? '#aaa' : 'gray' }}> |
|
|
|
|
<ExpandMoreIcon fontSize="small" onClick={this.handleClick} /> |
|
|
|
|
</div> |
|
|
|
|
<Menu |
|
|
|
|
id="simple-menu" |
|
|
|
|
anchorEl={messageMenu} |
|
|
|
|
keepMounted |
|
|
|
|
open={Boolean(messageMenu)} |
|
|
|
|
onClose={() => this.handleClose()} |
|
|
|
|
style={{ direction: 'rtl', fontFamily: 'IRANSansNumeralLight' }} |
|
|
|
|
> |
|
|
|
|
{(isSelf ? selfMenu : menu).map((e) => ( |
|
|
|
|
<MenuItem |
|
|
|
|
style={{ fontFamily: 'IRANSansNumeralLight' }} |
|
|
|
|
onClick={() => this.handleClose()} |
|
|
|
|
className="fontLight" |
|
|
|
|
onClick={() => { |
|
|
|
|
this.handleClose(); |
|
|
|
|
e.onClick(); |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<ReplyIcon fontSize="samall" /> |
|
|
|
|
پاسخ |
|
|
|
|
<e.icon fontSize="samall" /> |
|
|
|
|
{e.text} |
|
|
|
|
</MenuItem> |
|
|
|
|
))} |
|
|
|
|
</Menu> |
|
|
|
|
{hasavatar && <div style={{ color: isSelf ? '#aaa' : 'gray' }}>{user.name}</div>} |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<MenuItem |
|
|
|
|
style={{ fontFamily: 'IRANSansNumeralLight' }} |
|
|
|
|
onClick={() => this.handleClose()} |
|
|
|
|
> |
|
|
|
|
<ForwardIcon fontSize="samall" /> |
|
|
|
|
باز ارسال به |
|
|
|
|
</MenuItem> |
|
|
|
|
<MenuItem |
|
|
|
|
style={{ fontFamily: 'IRANSansNumeralLight' }} |
|
|
|
|
onClick={() => this.handleClose()} |
|
|
|
|
> |
|
|
|
|
<EditIcon fontSize="samall" /> |
|
|
|
|
ویرایش |
|
|
|
|
</MenuItem> |
|
|
|
|
<MenuItem |
|
|
|
|
style={{ fontFamily: 'IRANSansNumeralLight' }} |
|
|
|
|
onClick={() => this.handleClose()} |
|
|
|
|
> |
|
|
|
|
<DeleteIcon fontSize="samall" /> |
|
|
|
|
حذف |
|
|
|
|
</MenuItem> |
|
|
|
|
</Menu> |
|
|
|
|
{hasavatar && <div style={{ color: isSelf ? '#aaa' : 'gray' }}>{user.name}</div>} |
|
|
|
|
</div> |
|
|
|
|
{message.type == 'text' ? ( |
|
|
|
|
<p style={{ color: isSelf ? 'white' : 'black' }}>{message.text}</p> |
|
|
|
|
) : null} |
|
|
|
|
|
|
|
|
|
{message.text !== null && |
|
|
|
|
message.video === null && |
|
|
|
|
message.image === null && |
|
|
|
|
message.music === null && |
|
|
|
|
message.document === null ? ( |
|
|
|
|
<p id="3" style={{ color: isSelf ? 'white' : 'black' }}> |
|
|
|
|
{message.text} |
|
|
|
|
</p> |
|
|
|
|
{message.type == 'voice' ? ( |
|
|
|
|
<ReactAudioPlayer src={file(message.fileId)} controls /> |
|
|
|
|
) : null} |
|
|
|
|
{message.voice !== null ? <ReactAudioPlayer src={message.voice.url} controls /> : null} |
|
|
|
|
{message.image !== null ? ( |
|
|
|
|
<div |
|
|
|
|
className="normal-message__box--caption" |
|
|
|
|
ref={(refElem) => { |
|
|
|
|
console.log(refElem); |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<a href={message.image} download> |
|
|
|
|
<img src={message.image} download alt="" /> |
|
|
|
|
{message.type == 'image' ? ( |
|
|
|
|
<div className="normal-message__box--caption"> |
|
|
|
|
<a href={file(message.fileId)} download> |
|
|
|
|
<img src={file(message.fileId)} download alt="" /> |
|
|
|
|
</a> |
|
|
|
|
<p |
|
|
|
|
id="2" |
|
|
|
|
style={{ |
|
|
|
|
color: isSelf ? 'white' : 'black', |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{message.text} |
|
|
|
|
</p> |
|
|
|
|
<p style={{ color: isSelf ? 'white' : 'black' }}>{message.text}</p> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{message.video !== null ? ( |
|
|
|
|
{message.type == 'video' ? ( |
|
|
|
|
<div className="normal-message__box--caption"> |
|
|
|
|
<a href={message.video} download> |
|
|
|
|
<ReactPlayer url={message.video} controls width={'100%'} height={250} /> |
|
|
|
|
<a href={file(message.fileId)} download> |
|
|
|
|
<ReactPlayer url={file(message.fileId)} controls width={'100%'} height={250} /> |
|
|
|
|
</a> |
|
|
|
|
<p |
|
|
|
|
id="1" |
|
|
|
|
style={{ |
|
|
|
|
color: isSelf ? 'white' : 'black', |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{message.text} |
|
|
|
|
</p> |
|
|
|
|
<p style={{ color: isSelf ? 'white' : 'black' }}>{message.text}</p> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{message.music !== null ? <ReactAudioPlayer src={message.music} controls /> : null} |
|
|
|
|
{message.document !== null ? ( |
|
|
|
|
{message.type == 'audio' ? ( |
|
|
|
|
<div className="normal-message__box--caption"> |
|
|
|
|
<ReactAudioPlayer src={file(message.fileId)} controls /> |
|
|
|
|
<p style={{ color: isSelf ? 'white' : 'black' }}>{message.text}</p> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{message.type == 'document' ? ( |
|
|
|
|
<a |
|
|
|
|
href={message.document.data} |
|
|
|
|
href={file(message.fileId)} |
|
|
|
|
download |
|
|
|
|
className="normal-message__box--document d-flex" |
|
|
|
|
style={{ |
|
|
|
@ -202,15 +169,13 @@ export default class NormalMessage extends Component { |
|
|
|
|
marginRight: 10, |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
<div>{message.document.name}</div> |
|
|
|
|
<div>{message.text}</div> |
|
|
|
|
</a> |
|
|
|
|
) : null} |
|
|
|
|
|
|
|
|
|
<div className="normal-message__box--date d-flex"> |
|
|
|
|
<div className={'normal-message__box--date d-flex ' + (isSelf ? 'self' : '')}> |
|
|
|
|
<span style={{ color: isSelf ? '#aaa' : 'gray' }}> |
|
|
|
|
{message.status == 1 && <DoneIcon fontSize="small" />} |
|
|
|
|
{message.status == 2 && <DoneAllIcon fontSize="small" />} |
|
|
|
|
{message.updatedAt ? ( |
|
|
|
|
{message.updatedAt != message.createdAt ? ( |
|
|
|
|
<> |
|
|
|
|
<span> ویرایش در</span> |
|
|
|
|
|
|
|
|
@ -220,22 +185,43 @@ export default class NormalMessage extends Component { |
|
|
|
|
moment(message.createdAt).format('hh:mm') |
|
|
|
|
)} |
|
|
|
|
</span> |
|
|
|
|
<span |
|
|
|
|
style={{ |
|
|
|
|
color: isSelf ? '#aaa' : 'gray', |
|
|
|
|
padding: '0 2px', |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{isSelf && message.status == 0 && <ScheduleIcon fontSize="small" />} |
|
|
|
|
{isSelf && message.status == 1 && <DoneIcon fontSize="small" />} |
|
|
|
|
{isSelf && message.status == 2 && <DoneAllIcon fontSize="small" />} |
|
|
|
|
</span> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div className={isSelf ? 'icons self' : 'icons'}> |
|
|
|
|
<div> |
|
|
|
|
<FavoriteIcon fontSize="samall" color="primary" /> |
|
|
|
|
<span> {10}</span> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
{/* <div> |
|
|
|
|
<TextsmsIcon fontSize="samall" color="secondary" /> |
|
|
|
|
<span> {10}</span> |
|
|
|
|
</div> |
|
|
|
|
<div> |
|
|
|
|
<span> {'+5 اعتماد به نفس'}</span> |
|
|
|
|
</div> */} |
|
|
|
|
{!isSelf ? ( |
|
|
|
|
<> |
|
|
|
|
{' '} |
|
|
|
|
<div> |
|
|
|
|
<FavoriteIcon fontSize="samall" color="primary" /> |
|
|
|
|
<span> {10}</span> |
|
|
|
|
</div> |
|
|
|
|
<div> |
|
|
|
|
<TextsmsIcon fontSize="samall" color="secondary" /> |
|
|
|
|
<span> {10}</span> |
|
|
|
|
</div> |
|
|
|
|
</> |
|
|
|
|
) : ( |
|
|
|
|
<> |
|
|
|
|
<div> |
|
|
|
|
<span> |
|
|
|
|
+5 |
|
|
|
|
<br /> |
|
|
|
|
خلاقیت |
|
|
|
|
</span> |
|
|
|
|
</div> |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div |
|
|
|
|