index.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { makeStyles } from '@material-ui/core'
  2. import { styled } from '@mui/material/styles';
  3. import ListItemButton from '@mui/material/ListItemButton';
  4. import Avatar from '@mui/material/Avatar';
  5. import ListItemText from '@mui/material/ListItemText';
  6. import ListItemIcon from '@mui/material/ListItemIcon';
  7. import Badge from '@mui/material/Badge';
  8. import { firstLetter, slicedWord, timeStampEU,prodAwsS3 } from '../../../../../../../../helpers';
  9. const StyledBadge = styled(Badge)(({ theme }) => ({
  10. '& .MuiBadge-badge': {
  11. backgroundColor: '#44b700',
  12. color: '#44b700',
  13. boxShadow: `0 0 0 2px ${theme.palette.background.paper}`,
  14. '&::after': {
  15. position: 'absolute',
  16. top: 0,
  17. left: 0,
  18. width: '100%',
  19. height: '100%',
  20. borderRadius: '50%',
  21. animation: 'ripple 1.2s infinite ease-in-out',
  22. border: '1px solid currentColor',
  23. content: '""',
  24. },
  25. },
  26. '@keyframes ripple': {
  27. '0%': {
  28. transform: 'scale(.8)',
  29. opacity: 1,
  30. },
  31. '100%': {
  32. transform: 'scale(2.4)',
  33. opacity: 0,
  34. },
  35. },
  36. }));
  37. const useStyles = makeStyles({
  38. listItem_iconAvatar: {
  39. marginRight:10
  40. },
  41. })
  42. interface IForwardItem {
  43. name: string,
  44. lastName: string,
  45. avatarUrl: string,
  46. color: string,
  47. online: string,
  48. companionId: string,
  49. handleForwardTo: (companionId: string) => void,
  50. }
  51. const ForwardItem = ({name,lastName,avatarUrl,color,online,companionId,handleForwardTo}:IForwardItem) => {
  52. const classes = useStyles()
  53. return (
  54. <div>
  55. <ListItemButton onClick={() => handleForwardTo(companionId)}>
  56. <ListItemIcon className={classes.listItem_iconAvatar}>
  57. <StyledBadge overlap="circular" variant={online === 'true'?'dot':'standard'}
  58. anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}>
  59. <Avatar alt={name} src={avatarUrl?`${prodAwsS3}/${avatarUrl}`:undefined}
  60. sx={{ background: color, width: 54, height: 54 }}>
  61. {!avatarUrl&&`${firstLetter(name)}${firstLetter(lastName)}`}
  62. </Avatar>
  63. </StyledBadge>
  64. </ListItemIcon>
  65. <ListItemText primary={`${firstLetter(name)}${slicedWord(name, 15, 1)}
  66. ${firstLetter(lastName)}${slicedWord(lastName, 15, 1)}`}
  67. secondaryTypographyProps={{ color: '#0379af' }} secondary={online === 'true' ?
  68. 'online' : `last seen ${timeStampEU(online)}`} />
  69. </ListItemButton>
  70. </div>
  71. );
  72. }
  73. export default ForwardItem