index.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import ImageList from '@mui/material/ImageList';
  2. import { makeStyles } from '@material-ui/core'
  3. import MediaListItem from './MediaListItem';
  4. import AlertInfo from '../../../../reusableComponents/AlertInfo';
  5. import { TAllMessages } from '../../../../../typescript/redux/allMessages/types'
  6. const useStyles = makeStyles({
  7. container: {
  8. width: '100%',
  9. maxHeight: '88vh',
  10. overflowY: 'scroll',
  11. position: 'absolute',
  12. animationDuration: '0.2s',
  13. animationDirection: 'normal',
  14. animation: `$moveElement`,
  15. '&::-webkit-scrollbar': {
  16. width: '0.4em'
  17. },
  18. '&::-webkit-scrollbar-track': {
  19. boxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
  20. webkitBoxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
  21. backgroundColor: '#eceeec',
  22. },
  23. '&::-webkit-scrollbar-thumb': {
  24. backgroundColor: '#ccc8c8',
  25. },
  26. "&::-webkit-scrollbar-thumb:focus": {
  27. backgroundColor: "#959595",
  28. },
  29. "&::-webkit-scrollbar-thumb:active": {
  30. backgroundColor: "#959595",
  31. },
  32. },
  33. '@keyframes moveElement': {
  34. '0%': { left: '-100%'},
  35. '100%': { left: '0%'},
  36. },
  37. })
  38. interface IMediaList {
  39. filteredAndSortedMessages: TAllMessages,
  40. value: string,
  41. date: any,
  42. handleScrollToTheMessage:(_id:string,companionId:string) => void
  43. }
  44. const MediaList = ({ filteredAndSortedMessages,value,date,handleScrollToTheMessage }: IMediaList) => {
  45. const classes = useStyles()
  46. return (
  47. <>
  48. {filteredAndSortedMessages.length > 0 &&
  49. <ImageList className={classes.container} cols={3} rowHeight={164}>
  50. {filteredAndSortedMessages.map(({message,createdAt,fullType,updatedAt,_id,companionId,name,lastName,color}) =>
  51. <MediaListItem key={createdAt} message={message} fullType={fullType}
  52. updatedAt={updatedAt} handleScrollToTheMessage={handleScrollToTheMessage} id={_id}
  53. companionId={companionId} name={name} lastName={lastName} color={color}/>)}
  54. </ImageList>}
  55. {(value || date) && filteredAndSortedMessages.length === 0 && <AlertInfo name={`Can not find Media by request: ${value}`} />}
  56. {!value && !date && filteredAndSortedMessages.length === 0 && <AlertInfo name='You do not have Media yet!'/>}
  57. </>
  58. )
  59. }
  60. export default MediaList