index.tsx 2.4 KB

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