index.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import Button from '@mui/material/Button';
  2. import Avatar from '@mui/material/Avatar';
  3. import { makeStyles } from '@material-ui/core'
  4. import { useSelector } from 'react-redux';
  5. import { getChat } from '../../../../../../redux/chat/selector';
  6. import { removeChatForBoth } from '../../../../../../api-data';
  7. import { firstLetter,slicedWord,prodBaseURL } from '../../../../../../helpers';
  8. const useStyles = makeStyles({
  9. modalDelete: {
  10. background: '#ffffff',
  11. position: 'absolute',
  12. content:'',
  13. width: '20%',
  14. height:'auto',
  15. left: '40%',
  16. bottom: '48.5%',
  17. borderRadius: 10,
  18. padding: 10,
  19. display: 'flex',
  20. flexDirection:'column'
  21. },
  22. overlay: {
  23. position: 'fixed',
  24. top: 0,
  25. left: 0,
  26. width: '100vw',
  27. height: '100vh',
  28. zIndex: 100,
  29. backgroundColor: 'rgba(104, 105, 104, 0.6)',
  30. overflowY: 'hidden',
  31. },
  32. titleWrapper: {
  33. display: 'flex',
  34. justifyContent: 'flex-start',
  35. alignContent: 'center',
  36. alignItems:'center'
  37. },
  38. })
  39. const DeleteModal = ({setModal}:{setModal:any}) => {
  40. const classes = useStyles()
  41. const {name,lastName,avatarUrl,color,companionId} = useSelector(getChat)
  42. const handleDeleteModal = (e: any) => {
  43. const id = e.target.id
  44. if (id === 'overlay' || id === 'cancel') return setModal(false)
  45. if (id === 'delete') {
  46. removeChatForBoth(companionId)
  47. setModal(false)
  48. }
  49. }
  50. return (
  51. <div onClick={handleDeleteModal} className={classes.overlay} id='overlay'>
  52. <div className={classes.modalDelete}>
  53. <div className={classes.titleWrapper}>
  54. <Avatar alt={name} src={avatarUrl?`${prodBaseURL}/${avatarUrl}`:undefined}
  55. sx={{ background: color, width: 38, height: 38,marginRight:2}}>
  56. {`${firstLetter(name)}${firstLetter(lastName)}`}
  57. </Avatar>
  58. <h3 style={{color: '#2c2c2c'}}>Delete chat</h3>
  59. </div>
  60. <p style={{color: '#050505'}}>{`Are you sure you want to delete the
  61. chat with ${`${firstLetter(name)}${slicedWord(name, 15, 1)}
  62. ${firstLetter(lastName)}${slicedWord(lastName, 15, 1)}`}?`}</p>
  63. <Button id='delete' variant="text" color="error" style={{fontWeight:500,fontSize:22}}>
  64. DELETE CHAT
  65. </Button>
  66. <Button id='cancel' variant="text" style={{fontWeight:500,fontSize:22}}>
  67. CANCEL
  68. </Button>
  69. </div>
  70. </div>
  71. )
  72. }
  73. export default DeleteModal