index.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 VideoLibraryIcon from '@mui/icons-material/VideoLibrary';
  7. import Divider from '@mui/material/Divider';
  8. import { makeStyles } from '@material-ui/core'
  9. import AlertInfo from '../../../../reusableComponents/AlertInfo';
  10. import { timeStampEU,prodAwsS3,firstLetter } 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: '#54b0fc',
  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 IVideoList {
  55. filteredAndSortedMessages: TAllMessages,
  56. value: string,
  57. date: any,
  58. handleScrollToTheMessage:(_id:string,companionId:string) => void
  59. }
  60. const VideoList = ({ filteredAndSortedMessages,value,date,handleScrollToTheMessage }: IVideoList) => {
  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. key={createdAt} 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. <VideoLibraryIcon 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 Video by request: ${value}`} />}
  86. {!value && !date && filteredAndSortedMessages.length === 0 && <AlertInfo name='You do not have Video yet!'/>}
  87. </>
  88. )
  89. }
  90. export default VideoList