|
@@ -2,13 +2,15 @@ import { makeStyles } from "@material-ui/core/styles";
|
|
import { IconButton } from "@material-ui/core";
|
|
import { IconButton } from "@material-ui/core";
|
|
import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
|
|
import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
|
|
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
|
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
|
-
|
|
|
|
|
|
+import { useState } from "react";
|
|
import { timeStampMessage } from '../../../../../../helpers'
|
|
import { timeStampMessage } from '../../../../../../helpers'
|
|
|
|
|
|
|
|
+const FileViewer = require('react-file-viewer')
|
|
|
|
+
|
|
const useStyles = makeStyles({
|
|
const useStyles = makeStyles({
|
|
container: {
|
|
container: {
|
|
display: "flex",
|
|
display: "flex",
|
|
- justifyContent: "flex-end",
|
|
|
|
|
|
+ justifyContent: "flex-start",
|
|
width:'auto',
|
|
width:'auto',
|
|
maxWidth: '80%',
|
|
maxWidth: '80%',
|
|
marginBottom:15
|
|
marginBottom:15
|
|
@@ -19,35 +21,35 @@ const useStyles = makeStyles({
|
|
justifyContent: 'space-between',
|
|
justifyContent: 'space-between',
|
|
alignContent: 'center',
|
|
alignContent: 'center',
|
|
alignItems: 'center',
|
|
alignItems: 'center',
|
|
- width: 250,
|
|
|
|
|
|
+ width: 200,
|
|
padding: '5px 5px 12px 5px',
|
|
padding: '5px 5px 12px 5px',
|
|
- backgroundColor: '#deffa9',
|
|
|
|
|
|
+ backgroundColor: '#ffffff',
|
|
borderRadius: 7,
|
|
borderRadius: 7,
|
|
"&:after": {
|
|
"&:after": {
|
|
content: "''",
|
|
content: "''",
|
|
position: "absolute",
|
|
position: "absolute",
|
|
width: "0",
|
|
width: "0",
|
|
height: "0",
|
|
height: "0",
|
|
- borderBottom: "15px solid #deffa9",
|
|
|
|
|
|
+ borderBottom: "15px solid #ffffff",
|
|
borderLeft: "15px solid transparent",
|
|
borderLeft: "15px solid transparent",
|
|
borderRight: "15px solid transparent",
|
|
borderRight: "15px solid transparent",
|
|
- bottom: "0",
|
|
|
|
- right: "-15px"
|
|
|
|
|
|
+ bottom: '0px',
|
|
|
|
+ left: "-15px"
|
|
},
|
|
},
|
|
"&:before": {
|
|
"&:before": {
|
|
content: "''",
|
|
content: "''",
|
|
position: "absolute",
|
|
position: "absolute",
|
|
width: "0",
|
|
width: "0",
|
|
height: "0",
|
|
height: "0",
|
|
- borderBottom: "17px solid #deffa9",
|
|
|
|
|
|
+ borderBottom: "17px solid #ffffff",
|
|
borderLeft: "16px solid transparent",
|
|
borderLeft: "16px solid transparent",
|
|
borderRight: "16px solid transparent",
|
|
borderRight: "16px solid transparent",
|
|
bottom: "0px",
|
|
bottom: "0px",
|
|
- right: "-17px"
|
|
|
|
- }
|
|
|
|
|
|
+ left: "-17px"
|
|
|
|
+ }
|
|
},
|
|
},
|
|
bntDownload: {
|
|
bntDownload: {
|
|
- backgroundColor: '#deffa9',
|
|
|
|
|
|
+ backgroundColor: '#ffffff',
|
|
color: '#54b0fc',
|
|
color: '#54b0fc',
|
|
width: 30,
|
|
width: 30,
|
|
height:30,
|
|
height:30,
|
|
@@ -58,7 +60,11 @@ const useStyles = makeStyles({
|
|
},
|
|
},
|
|
title: {
|
|
title: {
|
|
margin: '0 30px 0 5px',
|
|
margin: '0 30px 0 5px',
|
|
- color: '#0e0d0d'
|
|
|
|
|
|
+ color: '#0e0d0d',
|
|
|
|
+ cursor: 'pointer',
|
|
|
|
+ '&:hover': {
|
|
|
|
+ color: '#54b0fc',
|
|
|
|
+ }
|
|
},
|
|
},
|
|
time: {
|
|
time: {
|
|
position: "absolute",
|
|
position: "absolute",
|
|
@@ -70,30 +76,52 @@ const useStyles = makeStyles({
|
|
padding: 3,
|
|
padding: 3,
|
|
borderRadius: 5,
|
|
borderRadius: 5,
|
|
zIndex:10
|
|
zIndex:10
|
|
- },
|
|
|
|
|
|
+ },
|
|
|
|
+ overlay: {
|
|
|
|
+ position: 'absolute',
|
|
|
|
+ top: 0,
|
|
|
|
+ left: 0,
|
|
|
|
+ width: '100%',
|
|
|
|
+ height:'100%',
|
|
|
|
+ zIndex: 100,
|
|
|
|
+ backgroundColor: 'rgba(104, 105, 104, 0.6)',
|
|
|
|
+ border: 'solid 1px rgba(179, 179, 179, 0.6)',
|
|
|
|
+ overflowY: 'hidden'
|
|
|
|
+ },
|
|
});
|
|
});
|
|
|
|
|
|
interface IMessageLeftFile {
|
|
interface IMessageLeftFile {
|
|
- audioUrl:string,
|
|
|
|
|
|
+ url:string,
|
|
updatedAt: string,
|
|
updatedAt: string,
|
|
}
|
|
}
|
|
|
|
|
|
-const MessageLeftFile = ({ audioUrl,updatedAt }:IMessageLeftFile) => {
|
|
|
|
|
|
+const MessageLeftFile = ({ url,updatedAt }:IMessageLeftFile) => {
|
|
const classes = useStyles();
|
|
const classes = useStyles();
|
|
|
|
+ const [read,setRead] = useState<boolean>(false)
|
|
|
|
+ const handleOpenRead = () => !read&&setRead(true)
|
|
|
|
+ const handleCloseRead = () => read && setRead(false)
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className={classes.container}>
|
|
<div className={classes.container}>
|
|
|
|
+ {read&&<div className={classes.overlay} id='overlay' onClick={handleCloseRead}>
|
|
|
|
+ <FileViewer
|
|
|
|
+ allowFullScreen={true}
|
|
|
|
+ fileType='pdf'
|
|
|
|
+ filePath={url}
|
|
|
|
+ onError={handleCloseRead}
|
|
|
|
+ />
|
|
|
|
+ </div>}
|
|
<div className={classes.wrapper}>
|
|
<div className={classes.wrapper}>
|
|
- <InsertDriveFileIcon fontSize='large' style={{ color:'#5f5f5f'}}/>
|
|
|
|
- <span className={classes.title}>Application File</span>
|
|
|
|
- <a href={`http://localhost:3000/${audioUrl}`} target="_blank" rel="noreferrer" download>
|
|
|
|
|
|
+ <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} >
|
|
<IconButton className={classes.bntDownload} >
|
|
- <FileDownloadIcon fontSize='small'/>
|
|
|
|
|
|
+ <FileDownloadIcon fontSize='medium'/>
|
|
</IconButton>
|
|
</IconButton>
|
|
</a>
|
|
</a>
|
|
<div className={classes.time}>{timeStampMessage(updatedAt)}</div>
|
|
<div className={classes.time}>{timeStampMessage(updatedAt)}</div>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
|
|
+ </div>
|
|
)};
|
|
)};
|
|
|
|
|
|
export default MessageLeftFile
|
|
export default MessageLeftFile
|