index.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import ImageList from '@mui/material/ImageList';
  2. import MediaListItem from './MediaListItem';
  3. import { makeStyles } from '@material-ui/core'
  4. import AlertInfo from '../../../../../reusableComponents/AlertInfo';
  5. import { TMessages } from '../../../../../../typescript/redux/messages/types'
  6. const useStyles = makeStyles({
  7. container: {
  8. position: 'absolute',
  9. animationDuration: '0.2s',
  10. animationDirection: 'normal',
  11. animation: `$moveElement`,
  12. },
  13. '@keyframes moveElement': {
  14. '0%': { left: '100%'},
  15. '100%': { left: '0%'},
  16. },
  17. })
  18. interface IMediaList {
  19. openPinned: boolean,
  20. filteredAndSorted: TMessages,
  21. handleScrollToTheMessage: (_id:string) => void,
  22. }
  23. const MediaList = ({ filteredAndSorted,handleScrollToTheMessage,openPinned }: IMediaList) => {
  24. const classes = useStyles()
  25. return filteredAndSorted.length > 0 ?(
  26. <ImageList className={classes.container}
  27. sx={{ width: '100%', height: 'auto', overflow: 'hidden' }} cols={3} rowHeight={164}>
  28. {filteredAndSorted.map(({message,createdAt,fullType,updatedAt,_id,name,lastName,avatarUrl,color}) =>
  29. <MediaListItem key={createdAt} message={message} fullType={fullType}
  30. updatedAt={updatedAt} handleScrollToTheMessage={handleScrollToTheMessage} id={_id}
  31. name={name} lastName={lastName} avatarUrl={avatarUrl} color={color}/>)}
  32. </ImageList>
  33. ): <AlertInfo name={`You do not have ${openPinned&&'Pinned'} Media yet!`}/>
  34. }
  35. export default MediaList