index.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import { makeStyles } from "@material-ui/core/styles";
  2. import { IconButton } from "@material-ui/core";
  3. import AudioFileIcon from '@mui/icons-material/AudioFile';
  4. import FileDownloadIcon from '@mui/icons-material/FileDownload';
  5. import ReactAudioPlayer from 'react-audio-player';
  6. import { timeStampMessage,handleDownload } from '../../../../../../helpers'
  7. const useStyles = makeStyles({
  8. container: {
  9. display: "flex",
  10. justifyContent: "flex-start",
  11. width:'auto',
  12. maxWidth: '80%',
  13. marginBottom:15
  14. },
  15. wrapper: {
  16. position: 'relative',
  17. display: 'flex',
  18. justifyContent: 'space-between',
  19. alignContent: 'center',
  20. alignItems: 'center',
  21. padding: '12px 5px 12px 5px',
  22. backgroundColor: '#ffffff',
  23. borderRadius: 7,
  24. "&:after": {
  25. content: "''",
  26. position: "absolute",
  27. width: "0",
  28. height: "0",
  29. borderBottom: "15px solid #ffffff",
  30. borderLeft: "15px solid transparent",
  31. borderRight: "15px solid transparent",
  32. bottom: '0px',
  33. left: "-15px"
  34. },
  35. "&:before": {
  36. content: "''",
  37. position: "absolute",
  38. width: "0",
  39. height: "0",
  40. borderBottom: "17px solid #ffffff",
  41. borderLeft: "16px solid transparent",
  42. borderRight: "16px solid transparent",
  43. bottom: "0px",
  44. left: "-17px"
  45. }
  46. },
  47. bntDownload: {
  48. backgroundColor: '#ffffff',
  49. color: '#54b0fc',
  50. width: 30,
  51. height:30,
  52. '&:hover': {
  53. backgroundColor: '#54b0fc',
  54. color:'#ffffff'
  55. }
  56. },
  57. player: {
  58. margin: '0 5px 0 5px',
  59. borderRadius:7
  60. },
  61. time: {
  62. position: "absolute",
  63. fontSize: ".65em",
  64. fontWeight:600,
  65. bottom: 0,
  66. right: 6,
  67. color: '#414141',
  68. padding: 3,
  69. borderRadius: 5,
  70. },
  71. });
  72. interface IMessageLeftAudio {
  73. url:string,
  74. updatedAt: string,
  75. fullType:string
  76. }
  77. const MessageLeftAudio = ({ url,updatedAt,fullType }:IMessageLeftAudio) => {
  78. const classes = useStyles();
  79. return (
  80. <div className={classes.container}>
  81. <div className={classes.wrapper}>
  82. <AudioFileIcon fontSize='large' style={{ color:'#0294c0'}}/>
  83. <ReactAudioPlayer className={classes.player}
  84. src={url}
  85. controls
  86. />
  87. <IconButton onClick={() => handleDownload(url, fullType)} className={classes.bntDownload} >
  88. <FileDownloadIcon fontSize='medium'/>
  89. </IconButton>
  90. <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
  91. </div>
  92. </div>
  93. )};
  94. export default MessageLeftAudio