index.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. import ListItemButton from '@mui/material/ListItemButton';
  2. import Avatar from '@mui/material/Avatar';
  3. import ListItemText from '@mui/material/ListItemText';
  4. import ListItemIcon from '@mui/material/ListItemIcon';
  5. import { useDispatch, useSelector } from 'react-redux';
  6. import { actionRightIsOpen } from '../../../../../redux/control/action'
  7. import { getChat } from '../../../../../redux/chat/selector'
  8. import { firstLetter,slicedWord,timeStampEU,prodAwsS3 } from '../../../../../helpers'
  9. const Credentials = () => {
  10. const dispatch = useDispatch()
  11. const { name, lastName, avatarUrl, color, online } = useSelector(getChat)
  12. return (
  13. <ListItemButton onClick={() => dispatch(actionRightIsOpen('credentials'))}>
  14. <ListItemIcon >
  15. <Avatar alt={name} src={avatarUrl?`${prodAwsS3}/${avatarUrl}`:undefined}
  16. sx={{ background: color, width: 44, height: 44 }}>
  17. {!avatarUrl&&`${firstLetter(name)}${firstLetter(lastName)}`}
  18. </Avatar>
  19. </ListItemIcon>
  20. <ListItemText primary={`${firstLetter(name)}${slicedWord(name, 15, 1)}
  21. ${firstLetter(lastName)}${slicedWord(lastName, 15, 1)}`}
  22. secondaryTypographyProps={{ color: '#0379af' }} secondary={online === 'true' ?
  23. 'online' : `last seen ${timeStampEU(online)}`} />
  24. </ListItemButton>
  25. )
  26. }
  27. export default Credentials