|
@@ -1,9 +1,9 @@
|
|
|
import { makeStyles } from "@material-ui/core/styles";
|
|
|
import { styled } from '@mui/material/styles';
|
|
|
import { useState,useRef } from "react";
|
|
|
-import { IconButton } from "@material-ui/core";
|
|
|
+import Typography from '@mui/material/Typography';
|
|
|
+import ListItemText from '@mui/material/ListItemText';
|
|
|
import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
|
|
|
-import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
|
|
import Button from '@mui/material/Button';
|
|
|
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
|
|
import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';
|
|
@@ -19,7 +19,7 @@ import ZoomInIcon from '@mui/icons-material/ZoomIn';
|
|
|
import ReplyIcon from '@mui/icons-material/Reply';
|
|
|
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
|
|
import { removeMessageById,updateMessageById,pinMessageById } from "../../../../../../api-data";
|
|
|
-import { timeStampMessage,copied,emojisArr,slicedWord } from '../../../../../../helpers'
|
|
|
+import { timeStampMessage,copied,emojisArr,slicedWord,firstLetter } from '../../../../../../helpers'
|
|
|
|
|
|
const FileViewer = require('react-file-viewer')
|
|
|
|
|
@@ -72,87 +72,80 @@ const useStyles = makeStyles({
|
|
|
wrapper: {
|
|
|
position: 'relative',
|
|
|
display: 'flex',
|
|
|
- justifyContent: 'space-between',
|
|
|
- alignContent: 'center',
|
|
|
alignItems: 'center',
|
|
|
- width: 200,
|
|
|
+ alignContent: 'center',
|
|
|
+ flexWrap: 'wrap',
|
|
|
+ maxWidth: 450,
|
|
|
+ minWidth:200,
|
|
|
padding: '5px 5px 22px 5px',
|
|
|
backgroundColor: '#deffa9',
|
|
|
borderRadius: 7,
|
|
|
- "&:after": {
|
|
|
- content: "''",
|
|
|
- position: "absolute",
|
|
|
- width: "0",
|
|
|
- height: "0",
|
|
|
- borderBottom: "15px solid #deffa9",
|
|
|
- borderLeft: "15px solid transparent",
|
|
|
- borderRight: "15px solid transparent",
|
|
|
- bottom: "0",
|
|
|
- right: "-15px"
|
|
|
- },
|
|
|
- "&:before": {
|
|
|
- content: "''",
|
|
|
- position: "absolute",
|
|
|
- width: "0",
|
|
|
- height: "0",
|
|
|
- borderBottom: "17px solid #deffa9",
|
|
|
- borderLeft: "16px solid transparent",
|
|
|
- borderRight: "16px solid transparent",
|
|
|
- bottom: "0px",
|
|
|
- right: "-17px"
|
|
|
- }
|
|
|
},
|
|
|
- wrapperActive: {
|
|
|
- position: 'relative',
|
|
|
+ wrapperInner: {
|
|
|
+ position:'relative',
|
|
|
display: 'flex',
|
|
|
- justifyContent: 'space-between',
|
|
|
- alignContent: 'center',
|
|
|
alignItems: 'center',
|
|
|
- width: 200,
|
|
|
- padding: '5px 5px 22px 5px',
|
|
|
- backgroundColor: '#ced8d7',
|
|
|
- borderRadius: 7,
|
|
|
- "&:after": {
|
|
|
- content: "''",
|
|
|
- position: "absolute",
|
|
|
- width: "0",
|
|
|
- height: "0",
|
|
|
- borderBottom: "15px solid #ced8d7",
|
|
|
- borderLeft: "15px solid transparent",
|
|
|
- borderRight: "15px solid transparent",
|
|
|
- bottom: "0",
|
|
|
- right: "-15px"
|
|
|
- },
|
|
|
- "&:before": {
|
|
|
- content: "''",
|
|
|
- position: "absolute",
|
|
|
- width: "0",
|
|
|
- height: "0",
|
|
|
- borderBottom: "17px solid #ced8d7",
|
|
|
- borderLeft: "16px solid transparent",
|
|
|
- borderRight: "16px solid transparent",
|
|
|
- bottom: "0px",
|
|
|
- right: "-17px"
|
|
|
- }
|
|
|
- },
|
|
|
- bntDownload: {
|
|
|
- backgroundColor: 'inherit',
|
|
|
- color: '#54b0fc',
|
|
|
- width: 30,
|
|
|
- height:30,
|
|
|
- '&:hover': {
|
|
|
- backgroundColor: '#54b0fc',
|
|
|
- color:'#ffffff'
|
|
|
- }
|
|
|
- },
|
|
|
- title: {
|
|
|
- margin: '0 30px 0 5px',
|
|
|
- color: '#0e0d0d',
|
|
|
+ alignContent: 'center',
|
|
|
+ width: '100%',
|
|
|
cursor: 'pointer',
|
|
|
'&:hover': {
|
|
|
- color: '#54b0fc',
|
|
|
+ backgroundColor: 'rgba(104, 105, 104, 0.2)'
|
|
|
}
|
|
|
+ },
|
|
|
+ message: {
|
|
|
+ wordBreak:'break-word',
|
|
|
+ textAlign: "left",
|
|
|
+ font: "400 .9em 'Open Sans', sans-serif",
|
|
|
+ "&:after": {
|
|
|
+ content: "''",
|
|
|
+ position: "absolute",
|
|
|
+ width: "0",
|
|
|
+ height: "0",
|
|
|
+ borderBottom: "15px solid #deffa9",
|
|
|
+ borderLeft: "15px solid transparent",
|
|
|
+ borderRight: "15px solid transparent",
|
|
|
+ bottom: "0px",
|
|
|
+ right: "-15px"
|
|
|
+ },
|
|
|
+ "&:before": {
|
|
|
+ content: "''",
|
|
|
+ position: "absolute",
|
|
|
+ width: "0",
|
|
|
+ height: "0",
|
|
|
+ borderBottom: "17px solid #deffa9",
|
|
|
+ borderLeft: "16px solid transparent",
|
|
|
+ borderRight: "16px solid transparent",
|
|
|
+ bottom: "0px",
|
|
|
+ right: "-17px"
|
|
|
+ },
|
|
|
},
|
|
|
+ messageActive: {
|
|
|
+ wordBreak:'break-word',
|
|
|
+ textAlign: "left",
|
|
|
+ font: "400 .9em 'Open Sans', sans-serif",
|
|
|
+ "&:after": {
|
|
|
+ content: "''",
|
|
|
+ position: "absolute",
|
|
|
+ width: "0",
|
|
|
+ height: "0",
|
|
|
+ borderBottom: "15px solid #ced8d7",
|
|
|
+ borderLeft: "15px solid transparent",
|
|
|
+ borderRight: "15px solid transparent",
|
|
|
+ bottom: "0",
|
|
|
+ right: "-15px"
|
|
|
+ },
|
|
|
+ "&:before": {
|
|
|
+ content: "''",
|
|
|
+ position: "absolute",
|
|
|
+ width: "0",
|
|
|
+ height: "0",
|
|
|
+ borderBottom: "17px solid #ced8d7",
|
|
|
+ borderLeft: "16px solid transparent",
|
|
|
+ borderRight: "16px solid transparent",
|
|
|
+ bottom: "0px",
|
|
|
+ right: "-17px"
|
|
|
+ }
|
|
|
+ },
|
|
|
time: {
|
|
|
position: "absolute",
|
|
|
fontSize: ".65em",
|
|
@@ -163,42 +156,6 @@ const useStyles = makeStyles({
|
|
|
padding: 3,
|
|
|
borderRadius: 5,
|
|
|
},
|
|
|
- captionWrapper: {
|
|
|
- position: 'relative',
|
|
|
- fontSize: ".85em",
|
|
|
- color: '#626262',
|
|
|
- maxWidth: 230,
|
|
|
- fontWeight:600,
|
|
|
- borderRadius: 5,
|
|
|
- marginRight:10,
|
|
|
- wordBreak:'break-word',
|
|
|
- textAlign: "left",
|
|
|
- font: "400 .9em 'Open Sans', sans-serif",
|
|
|
- backgroundColor: '#ffffff',
|
|
|
- padding:10,
|
|
|
- "&:after": {
|
|
|
- content: "''",
|
|
|
- position: "absolute",
|
|
|
- width: "0",
|
|
|
- height: "0",
|
|
|
- borderBottom: "15px solid #ffffff",
|
|
|
- borderLeft: "15px solid transparent",
|
|
|
- borderRight: "15px solid transparent",
|
|
|
- bottom: "0px",
|
|
|
- right: "-15px"
|
|
|
- },
|
|
|
- "&:before": {
|
|
|
- content: "''",
|
|
|
- position: "absolute",
|
|
|
- width: "0",
|
|
|
- height: "0",
|
|
|
- borderBottom: "17px solid #ffffff",
|
|
|
- borderLeft: "16px solid transparent",
|
|
|
- borderRight: "16px solid transparent",
|
|
|
- bottom: "0px",
|
|
|
- right: "-17px"
|
|
|
- }
|
|
|
- },
|
|
|
overlay: {
|
|
|
position: 'absolute',
|
|
|
top: 0,
|
|
@@ -314,13 +271,23 @@ const useStyles = makeStyles({
|
|
|
right: -64,
|
|
|
bottom: -10,
|
|
|
pointerEvents: 'auto'
|
|
|
- }
|
|
|
+ },
|
|
|
+ folderIcon: {
|
|
|
+ marginRight: 7,
|
|
|
+ color: '#54b0fc',
|
|
|
+ cursor: 'pointer',
|
|
|
+ '&:hover': {
|
|
|
+ color: '#016cc3'
|
|
|
+ },
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
const label = { inputProps: { 'aria-label': 'Checkbox demo' } };
|
|
|
|
|
|
interface IMessageRightFile {
|
|
|
- url:string,
|
|
|
+ url: string,
|
|
|
+ name: string,
|
|
|
+ lastName: string,
|
|
|
createdAt: string,
|
|
|
type: string,
|
|
|
caption: string,
|
|
@@ -336,7 +303,7 @@ interface IMessageRightFile {
|
|
|
handleForward: (_id: string) => void,
|
|
|
}
|
|
|
|
|
|
-const MessageRightFile = ({ url,createdAt,type,caption,emoji,emojiCompanion,pinned,isSomeSelected,isSelected,handleSelected,_id,nightMode,handleReply,handleForward }:IMessageRightFile) => {
|
|
|
+const MessageRightFile = ({ url,name,lastName,createdAt,type,caption,emoji,emojiCompanion,pinned,isSomeSelected,isSelected,handleSelected,_id,nightMode,handleReply,handleForward }:IMessageRightFile) => {
|
|
|
const classes = useStyles();
|
|
|
const [read, setRead] = useState<boolean>(false)
|
|
|
const [anchorEl, setAnchorEl] = useState<any>(null);
|
|
@@ -360,7 +327,10 @@ const MessageRightFile = ({ url,createdAt,type,caption,emoji,emojiCompanion,pinn
|
|
|
setScale(scale-0.25)
|
|
|
}
|
|
|
}
|
|
|
- const handleOpenRead = () => !read&&setRead(true)
|
|
|
+ const handleOpenRead = (e: any) => {
|
|
|
+ const id = e.target.id
|
|
|
+ if(id === 'read') !read&&setRead(true)
|
|
|
+ }
|
|
|
const handleCloseRead = (e:any) => {
|
|
|
const id = e.target.id
|
|
|
if (id === 'overlay' || id === 'close') {
|
|
@@ -413,16 +383,21 @@ const MessageRightFile = ({ url,createdAt,type,caption,emoji,emojiCompanion,pinn
|
|
|
/>
|
|
|
</div>
|
|
|
</div>}
|
|
|
- <div onContextMenu={(e) => handleContextMenu(e)}
|
|
|
- className={selected ? classes.wrapperActive : classes.wrapper}
|
|
|
- style={{pointerEvents:isSomeSelected?'none':'auto'}}>
|
|
|
- <InsertDriveFileIcon fontSize='large' style={{ color: '#99b401' }} />
|
|
|
- {!read && <span className={classes.title} onClick={handleOpenRead}>Read File</span>}
|
|
|
- <a href={url} target="_blank" rel="noreferrer" download>
|
|
|
- <IconButton className={classes.bntDownload}>
|
|
|
- <FileDownloadIcon fontSize='medium'/>
|
|
|
- </IconButton>
|
|
|
- </a>
|
|
|
+ <div onContextMenu={(e) => handleContextMenu(e)} className={classes.wrapper}
|
|
|
+ style={{backgroundColor:selected?'#ced8d7':undefined,pointerEvents:isSomeSelected?'none':'auto'}}>
|
|
|
+ <Typography style={{color: "#42aee0"}} variant="h6" align="right">
|
|
|
+ {`${firstLetter(name)}${slicedWord(name, 15, 1)}
|
|
|
+ ${firstLetter(lastName)}${slicedWord(lastName, 15, 1)}`}
|
|
|
+ </Typography>
|
|
|
+ <div className={classes.wrapperInner} id='read' onClick={handleOpenRead}>
|
|
|
+ <a href={url} target="_blank" rel="noreferrer" download>
|
|
|
+ <InsertDriveFileIcon className={classes.folderIcon} fontSize='large' />
|
|
|
+ </a>
|
|
|
+ {!read && <span id='read'>Read File</span>}
|
|
|
+ </div>
|
|
|
+ {caption && <ListItemText className={selected ? classes.messageActive : classes.message}
|
|
|
+ primary='Caption' primaryTypographyProps={{ color: "#42aee0" }}
|
|
|
+ secondary={caption} secondaryTypographyProps={{ color: "#2f2f2f" }}/>}
|
|
|
<div className={classes.time}>{timeStampMessage(createdAt)}</div>
|
|
|
{emojiCompanion && <div className={classes.emojiCompanionTitle}>{emojisArr[Number(emojiCompanion)]}</div>}
|
|
|
{emoji && <div className={classes.emojiTitle}>{emojisArr[Number(emoji)]}</div>}
|
|
@@ -490,7 +465,6 @@ const MessageRightFile = ({ url,createdAt,type,caption,emoji,emojiCompanion,pinn
|
|
|
</div>
|
|
|
</div>}
|
|
|
</div>
|
|
|
- {caption&&<div className={classes.captionWrapper}>{caption}</div>}
|
|
|
</div>
|
|
|
)};
|
|
|
|