index.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import List from '@mui/material/List';
  2. import ListItem from '@mui/material/ListItem';
  3. import ListItemText from '@mui/material/ListItemText';
  4. import ListItemAvatar from '@mui/material/ListItemAvatar';
  5. import LibraryMusicIcon from '@mui/icons-material/LibraryMusic';
  6. import Divider from '@mui/material/Divider';
  7. import { makeStyles } from '@material-ui/core'
  8. import AlertInfo from '../../../../reusableComponents/AlertInfo';
  9. import { timeStampEU,handleDownload,prodBaseURL } from '../../../../../helpers'
  10. import { TAllMessages } from '../../../../../typescript/redux/allMessages/types'
  11. const useStyles = makeStyles({
  12. container: {
  13. width: '100%',
  14. maxHeight: '86vh',
  15. overflowY: 'scroll',
  16. '&::-webkit-scrollbar': {
  17. width: '0.4em'
  18. },
  19. '&::-webkit-scrollbar-track': {
  20. boxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
  21. webkitBoxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
  22. backgroundColor: '#eceeec',
  23. },
  24. '&::-webkit-scrollbar-thumb': {
  25. backgroundColor: '#ccc8c8',
  26. },
  27. "&::-webkit-scrollbar-thumb:focus": {
  28. backgroundColor: "#959595",
  29. },
  30. "&::-webkit-scrollbar-thumb:active": {
  31. backgroundColor: "#959595",
  32. },
  33. },
  34. folderIcon: {
  35. color: '#54b0fc',
  36. cursor: 'pointer',
  37. '&:hover': {
  38. color: '#016cc3'
  39. },
  40. },
  41. listItem: {
  42. '&:hover': {
  43. backgroundColor: '#f0f0f0',
  44. }
  45. },
  46. })
  47. const AudioList = ({ allMessagesMemo,value,date }: { allMessagesMemo: TAllMessages,value:string,date:any }) => {
  48. const classes = useStyles()
  49. const filteredMessagesMemo = allMessagesMemo.filter(({type}) => type === 'audio')
  50. return(
  51. <>
  52. {filteredMessagesMemo.length > 0 &&
  53. <List className={classes.container}>
  54. {filteredMessagesMemo.map(({ message, createdAt, fullType }) =>
  55. <div key={createdAt}>
  56. <ListItem alignItems="flex-start" className={classes.listItem}>
  57. <ListItemAvatar>
  58. <LibraryMusicIcon onClick={() =>
  59. handleDownload(`${prodBaseURL}/${message}`, fullType)}
  60. className={classes.folderIcon} fontSize='large' />
  61. </ListItemAvatar>
  62. <ListItemText
  63. primary={fullType}
  64. secondary={timeStampEU(createdAt)}
  65. />
  66. </ListItem>
  67. <Divider variant="inset"/>
  68. </div>)}
  69. </List>}
  70. {(value || date) && filteredMessagesMemo.length === 0 && <AlertInfo name={`Can not find Audio by request: ${value}`} />}
  71. {!value && !date && filteredMessagesMemo.length === 0 && <AlertInfo name='You do not have Audio yet!'/>}
  72. </>)
  73. }
  74. export default AudioList