index.tsx 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 Avatar from '@mui/material/Avatar';
  6. import LibraryMusicIcon from '@mui/icons-material/LibraryMusic';
  7. import Divider from '@mui/material/Divider';
  8. import { makeStyles } from '@material-ui/core'
  9. import AlertInfo from '../../../../reusableComponents/AlertInfo';
  10. import { timeStampEU,firstLetter,prodAwsS3 } from '../../../../../helpers'
  11. import { TAllMessages } from '../../../../../typescript/redux/allMessages/types'
  12. const useStyles = makeStyles({
  13. container: {
  14. width: '100%',
  15. maxHeight: '88vh',
  16. overflowY: 'scroll',
  17. position: 'absolute',
  18. animationDuration: '0.2s',
  19. animationDirection: 'normal',
  20. animation: `$moveElement`,
  21. '&::-webkit-scrollbar': {
  22. width: '0.4em'
  23. },
  24. '&::-webkit-scrollbar-track': {
  25. boxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
  26. webkitBoxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
  27. backgroundColor: '#eceeec',
  28. },
  29. '&::-webkit-scrollbar-thumb': {
  30. backgroundColor: '#ccc8c8',
  31. },
  32. "&::-webkit-scrollbar-thumb:focus": {
  33. backgroundColor: "#959595",
  34. },
  35. "&::-webkit-scrollbar-thumb:active": {
  36. backgroundColor: "#959595",
  37. },
  38. },
  39. folderIcon: {
  40. margin: 'auto 0px',
  41. color: 'rgba(0, 0, 0, 0.5)',
  42. },
  43. listItem: {
  44. cursor:'pointer',
  45. '&:hover': {
  46. backgroundColor: '#f0f0f0',
  47. }
  48. },
  49. '@keyframes moveElement': {
  50. '0%': { left: '-100%'},
  51. '100%': { left: '0%'},
  52. },
  53. })
  54. interface IAudioList {
  55. filteredAndSortedMessages: TAllMessages,
  56. value: string,
  57. date: any,
  58. handleScrollToTheMessage:(_id:string,companionId:string) => void
  59. }
  60. const AudioList = ({ filteredAndSortedMessages,value,date,handleScrollToTheMessage }: IAudioList) => {
  61. const classes = useStyles()
  62. return(
  63. <>
  64. {filteredAndSortedMessages.length > 0 &&
  65. <List className={classes.container}>
  66. {filteredAndSortedMessages.map(({ createdAt, fullType,_id,companionId,name,avatarUrl,lastName,color }) =>
  67. <div key={createdAt}>
  68. <ListItem onClick={() => handleScrollToTheMessage(_id,companionId)}
  69. alignItems="flex-start" className={classes.listItem}>
  70. <ListItemAvatar>
  71. <Avatar alt={name} src={avatarUrl?`${prodAwsS3}/${avatarUrl}`:undefined}
  72. sx={{ background: color, width: 40, height: 40}}>
  73. {`${firstLetter(name)}${firstLetter(lastName)}`}
  74. </Avatar>
  75. </ListItemAvatar>
  76. <ListItemText
  77. primary={fullType}
  78. secondary={timeStampEU(createdAt)}
  79. />
  80. <LibraryMusicIcon className={classes.folderIcon} fontSize='large'/>
  81. </ListItem>
  82. <Divider variant="inset"/>
  83. </div>)}
  84. </List>}
  85. {(value || date) && filteredAndSortedMessages.length === 0 && <AlertInfo name={`Can not find Audio by request: ${value}`} />}
  86. {!value && !date && filteredAndSortedMessages.length === 0 && <AlertInfo name='You do not have Audio yet!'/>}
  87. </>)
  88. }
  89. export default AudioList