index.tsx 1.3 KB

1234567891011121314151617181920212223242526272829
  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 { actionIsOpen } from '../../../../../redux/control/action'
  7. import { getChat } from '../../../../../redux/chat/selector'
  8. import { firstLetter,slicedWord,timeStamp } from '../../../../../helpers'
  9. const Credentials = () => {
  10. const dispatch = useDispatch()
  11. const { name, lastName, avatarUrl, color, online } = useSelector(getChat)
  12. return (
  13. <ListItemButton onClick={() => dispatch(actionIsOpen('credentials'))}>
  14. <ListItemIcon >
  15. <Avatar alt={name} src={avatarUrl?`http://localhost:3000/${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'?'online':`last seen ${timeStamp(online)}`} />
  23. </ListItemButton>
  24. )
  25. }
  26. export default Credentials