|
|
|
@ -9,135 +9,218 @@ import DoneAllIcon from '@material-ui/icons/DoneAll'; |
|
|
|
|
import EditIcon from '@material-ui/icons/Edit'; |
|
|
|
|
import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; |
|
|
|
|
import './NormalMessage.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'; |
|
|
|
|
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 } = this.props; |
|
|
|
|
const { message, user, document, isSelf, prevUserId } = this.props; |
|
|
|
|
const { messageMenu } = this.state; |
|
|
|
|
const hasavatar = prevUserId != message.userId; |
|
|
|
|
return ( |
|
|
|
|
<div |
|
|
|
|
className="normal-message d-flex flex-column d-flex" |
|
|
|
|
style={{ |
|
|
|
|
marginRight: isSelf ? 0 : 70, |
|
|
|
|
marginLeft: isSelf ? 70 : 0, |
|
|
|
|
filter: document !== null ? 'blur(16px)' : 'blur(0px)', |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<Avatar |
|
|
|
|
alt={user.name} |
|
|
|
|
src={window.baseURL + '/file/download/' + user.fileId} |
|
|
|
|
className="" |
|
|
|
|
style={{ backgroundColor: user.color, alignSelf: isSelf ? 'flex-end' : 'flex-start' }} |
|
|
|
|
> |
|
|
|
|
{user.name |
|
|
|
|
.split(' ') |
|
|
|
|
.map((e) => e.slice(0, 1)) |
|
|
|
|
.join(' ')} |
|
|
|
|
</Avatar> |
|
|
|
|
{/* <img |
|
|
|
|
src={window.baseURL + '/file/download/' + user.fileId} |
|
|
|
|
style={{ alignSelf: isSelf ? 'flex-end' : 'flex-start' }} |
|
|
|
|
alt={message.id} |
|
|
|
|
/> */} |
|
|
|
|
<div |
|
|
|
|
className={ |
|
|
|
|
message.voice === null && |
|
|
|
|
{hasavatar && ( |
|
|
|
|
<Avatar |
|
|
|
|
alt={user.name} |
|
|
|
|
src={window.baseURL + '/file/download/' + user.fileId} |
|
|
|
|
className="" |
|
|
|
|
style={{ backgroundColor: user.color, alignSelf: isSelf ? 'flex-end' : 'flex-start' }} |
|
|
|
|
> |
|
|
|
|
{user.name |
|
|
|
|
.split(' ') |
|
|
|
|
.map((e) => e.slice(0, 1)) |
|
|
|
|
.join(' ')} |
|
|
|
|
</Avatar> |
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
<div className="d-flex" style={{ direction: isSelf ? 'rtl' : 'ltr' }}> |
|
|
|
|
<div |
|
|
|
|
className={ |
|
|
|
|
message.voice === null && |
|
|
|
|
message.video === null && |
|
|
|
|
message.image === null && |
|
|
|
|
message.music === null && |
|
|
|
|
message.document === null |
|
|
|
|
? `normal-message__box ` |
|
|
|
|
: `normal-message__box normal-message__box--file` |
|
|
|
|
} |
|
|
|
|
style={{ |
|
|
|
|
paddingTop: hasavatar ? 25 : 10, |
|
|
|
|
backgroundColor: isSelf ? 'rgb(15, 93, 190)' : 'white', |
|
|
|
|
width: 'calc(100%-70px)', |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{message.voice === null && |
|
|
|
|
message.video === null && |
|
|
|
|
message.image === null && |
|
|
|
|
message.music === null && |
|
|
|
|
message.document === null |
|
|
|
|
? `normal-message__box d-flex` |
|
|
|
|
: `normal-message__box d-flex normal-message__box--file` |
|
|
|
|
} |
|
|
|
|
style={{ backgroundColor: isSelf ? 'rgb(15, 93, 190)' : 'white' }} |
|
|
|
|
> |
|
|
|
|
{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, |
|
|
|
|
message.document === null ? ( |
|
|
|
|
<div |
|
|
|
|
className="normal-message__box--detail d-flex" |
|
|
|
|
style={{ |
|
|
|
|
top: 0, |
|
|
|
|
|
|
|
|
|
direction: isSelf ? 'ltr' : 'rtl', |
|
|
|
|
paddingRight: isSelf ? 60 : 0, |
|
|
|
|
paddingLeft: isSelf ? 15 : 70, |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<div style={{ color: isSelf ? '#aaa' : 'gray' }}> |
|
|
|
|
<ExpandMoreIcon fontSize="small" /> |
|
|
|
|
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 |
|
|
|
|
id="simple-menu" |
|
|
|
|
anchorEl={messageMenu} |
|
|
|
|
keepMounted |
|
|
|
|
open={Boolean(messageMenu)} |
|
|
|
|
onClose={() => this.handleClose()} |
|
|
|
|
style={{ direction: 'rtl', fontFamily: 'IRANSansNumeralLight' }} |
|
|
|
|
> |
|
|
|
|
<MenuItem |
|
|
|
|
style={{ fontFamily: 'IRANSansNumeralLight' }} |
|
|
|
|
onClick={() => this.handleClose()} |
|
|
|
|
> |
|
|
|
|
<ReplyIcon fontSize="samall" /> |
|
|
|
|
پاسخ |
|
|
|
|
</MenuItem> |
|
|
|
|
|
|
|
|
|
<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> |
|
|
|
|
<div style={{ color: isSelf ? '#aaa' : 'gray' }}>{user.name}</div> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
) : 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> |
|
|
|
|
) : null} |
|
|
|
|
{message.voice !== null ? <ReactAudioPlayer src={message.voice.url} controls /> : null} |
|
|
|
|
{message.image !== null ? ( |
|
|
|
|
<div className="normal-message__box--caption"> |
|
|
|
|
<a href={message.image} download> |
|
|
|
|
<img src={message.image} download alt="" /> |
|
|
|
|
</a> |
|
|
|
|
<p id="2" style={{ color: isSelf ? 'white' : 'black' }}> |
|
|
|
|
{message.text} |
|
|
|
|
</p> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{message.video !== null ? ( |
|
|
|
|
<div className="normal-message__box--caption"> |
|
|
|
|
<a href={message.video} download> |
|
|
|
|
<ReactPlayer url={message.video} controls width={'100%'} height={250} /> |
|
|
|
|
</a> |
|
|
|
|
<p id="1" style={{ color: isSelf ? 'white' : 'black' }}> |
|
|
|
|
{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> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{message.music !== null ? <ReactAudioPlayer src={message.music} controls /> : null} |
|
|
|
|
{message.document !== null ? ( |
|
|
|
|
<a |
|
|
|
|
href={message.document.data} |
|
|
|
|
download |
|
|
|
|
className="normal-message__box--document d-flex" |
|
|
|
|
style={{ |
|
|
|
|
backgroundColor: isSelf ? 'rgb(15, 93, 190)' : 'white', |
|
|
|
|
color: isSelf ? 'white' : 'black', |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<CloudDownloadIcon |
|
|
|
|
) : null} |
|
|
|
|
{message.voice !== null ? <ReactAudioPlayer src={message.voice.url} controls /> : null} |
|
|
|
|
{message.image !== null ? ( |
|
|
|
|
<div className="normal-message__box--caption"> |
|
|
|
|
<a href={message.image} download> |
|
|
|
|
<img src={message.image} download alt="" /> |
|
|
|
|
</a> |
|
|
|
|
<p |
|
|
|
|
id="2" |
|
|
|
|
style={{ |
|
|
|
|
color: isSelf ? 'white' : 'black', |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{message.text} |
|
|
|
|
</p> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{message.video !== null ? ( |
|
|
|
|
<div className="normal-message__box--caption"> |
|
|
|
|
<a href={message.video} download> |
|
|
|
|
<ReactPlayer url={message.video} controls width={'100%'} height={250} /> |
|
|
|
|
</a> |
|
|
|
|
<p |
|
|
|
|
id="1" |
|
|
|
|
style={{ |
|
|
|
|
color: isSelf ? 'white' : 'black', |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{message.text} |
|
|
|
|
</p> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{message.music !== null ? <ReactAudioPlayer src={message.music} controls /> : null} |
|
|
|
|
{message.document !== null ? ( |
|
|
|
|
<a |
|
|
|
|
href={message.document.data} |
|
|
|
|
download |
|
|
|
|
className="normal-message__box--document d-flex" |
|
|
|
|
style={{ |
|
|
|
|
backgroundColor: isSelf ? 'rgb(15, 93, 190)' : 'white', |
|
|
|
|
color: isSelf ? 'white' : 'black', |
|
|
|
|
width: 32, |
|
|
|
|
height: 32, |
|
|
|
|
marginRight: 10, |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
<div>{message.document.name}</div> |
|
|
|
|
</a> |
|
|
|
|
) : null} |
|
|
|
|
<div className="normal-message__box--dete d-flex"> |
|
|
|
|
<span style={{ color: isSelf ? '#aaa' : 'gray' }}> |
|
|
|
|
{message.status == 1 && <DoneIcon fontSize="small" />} |
|
|
|
|
{message.status == 2 && <DoneAllIcon fontSize="small" />} |
|
|
|
|
{message.updatedAt ? ( |
|
|
|
|
<> |
|
|
|
|
<span> ویرایش در</span> |
|
|
|
|
> |
|
|
|
|
<CloudDownloadIcon |
|
|
|
|
style={{ |
|
|
|
|
color: isSelf ? 'white' : 'black', |
|
|
|
|
width: 32, |
|
|
|
|
height: 32, |
|
|
|
|
marginRight: 10, |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
<div>{message.document.name}</div> |
|
|
|
|
</a> |
|
|
|
|
) : null} |
|
|
|
|
<div className="normal-message__box--date d-flex"> |
|
|
|
|
<span style={{ color: isSelf ? '#aaa' : 'gray' }}> |
|
|
|
|
{message.status == 1 && <DoneIcon fontSize="small" />} |
|
|
|
|
{message.status == 2 && <DoneAllIcon fontSize="small" />} |
|
|
|
|
{message.updatedAt ? ( |
|
|
|
|
<> |
|
|
|
|
<span> ویرایش در</span> |
|
|
|
|
|
|
|
|
|
{moment(message.updatedAt).format(' hh:mm jMM/jDD')} |
|
|
|
|
</> |
|
|
|
|
) : ( |
|
|
|
|
moment(message.createdAt).format('hh:mm') |
|
|
|
|
)} |
|
|
|
|
</span> |
|
|
|
|
{moment(message.updatedAt).format(' hh:mm jMM/jDD')} |
|
|
|
|
</> |
|
|
|
|
) : ( |
|
|
|
|
moment(message.createdAt).format('hh:mm') |
|
|
|
|
)} |
|
|
|
|
</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> */} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|