ChatInfoDrawerMediaList.jsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { connect } from "react-redux"
  2. import { ChatInfoDrawerMediaItem, ChatInfoDrawerMediaListWrapper } from "./ChatInfoDrawerMediaList.style"
  3. import InsertPhotoOutlinedIcon from '@mui/icons-material/InsertPhotoOutlined';
  4. import VideocamRoundedIcon from '@mui/icons-material/VideocamRounded';
  5. import HeadsetRoundedIcon from '@mui/icons-material/HeadsetRounded';
  6. import InsertDriveFileRoundedIcon from '@mui/icons-material/InsertDriveFileRounded';
  7. import { Divider } from "../ChatInfoModal/ChatInfoModal.style";
  8. export const ChatInfoDrawerMediaList = ({chatMedia}) => {
  9. const media = Object.values(chatMedia || {})
  10. const audioFiles = media?.filter((item) => item?.type?.includes('audio') && !item?.originalFileName?.includes('record'));
  11. const photos = media?.filter(({type}) => type?.includes('image'));
  12. const videos = media?.filter(({type}) => type?.includes('video'));
  13. const files = media?.filter(({type}) => type?.includes('application'));
  14. return media.length !== 0 && (
  15. <ChatInfoDrawerMediaListWrapper>
  16. <Divider/>
  17. {photos.length > 0 && <ChatInfoDrawerMediaItem>
  18. <InsertPhotoOutlinedIcon sx={{mr: '25px'}}/>{photos.length} {photos.length === 1 ? 'photo' : 'photos'}
  19. </ChatInfoDrawerMediaItem>}
  20. {videos.length > 0 && <ChatInfoDrawerMediaItem>
  21. <VideocamRoundedIcon sx={{mr: '25px'}}/>{videos.length} {videos.length === 1 ? 'video' : 'videos'}
  22. </ChatInfoDrawerMediaItem>}
  23. {files.length > 0 && <ChatInfoDrawerMediaItem>
  24. <InsertDriveFileRoundedIcon sx={{mr: '25px'}}/>{files.length} {files.length === 1 ? 'file' : 'files'}
  25. </ChatInfoDrawerMediaItem>}
  26. {audioFiles.length > 0 && <ChatInfoDrawerMediaItem>
  27. <HeadsetRoundedIcon sx={{mr: '25px'}}/>{audioFiles.length} {audioFiles.length === 1 ? 'audio file' : 'audio files'}
  28. </ChatInfoDrawerMediaItem>}
  29. </ChatInfoDrawerMediaListWrapper>
  30. )
  31. }