index.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { makeStyles, Typography } from '@material-ui/core'
  2. import Avatar from '@mui/material/Avatar';
  3. import { slicedWord, firstLetter,prodBaseURL } from '../../../../../../helpers';
  4. import { TChat } from '../../../../../../typescript/redux/chats/types';
  5. const useStyles = makeStyles({
  6. stackItem: {
  7. display: 'flex',
  8. flexDirection: 'column',
  9. justifyContent: 'center',
  10. alignContent: 'center',
  11. alignItems: 'center',
  12. padding:5,
  13. borderRadius: 5,
  14. cursor:'pointer',
  15. '&:hover': {
  16. background: '#eeeded'
  17. }
  18. },
  19. titleName: {
  20. color: '#575757',
  21. fontSize: 16,
  22. paddingTop:5
  23. }
  24. })
  25. interface IRecentItem {
  26. handleListItemClick: (companionId: string) => void,
  27. chat:TChat,
  28. }
  29. const RecentItem = ({handleListItemClick,chat}:IRecentItem) => {
  30. const classes = useStyles()
  31. const { name, lastName,color,avatarUrl,companionId } = chat
  32. return (
  33. <div onClick={() => handleListItemClick(companionId)} className={classes.stackItem}>
  34. <Avatar alt={name} src={avatarUrl?`${prodBaseURL}/${avatarUrl}`:undefined}
  35. sx={{ background: color, width: 54, height: 54}}>
  36. {`${firstLetter(name)}${firstLetter(lastName)}`}
  37. </Avatar>
  38. <Typography variant="h6" className={classes.titleName} >{`${firstLetter(name)}${slicedWord(name, 8, 1)}`}</Typography>
  39. </div>
  40. )
  41. }
  42. export default RecentItem