index.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { makeStyles } from "@material-ui/core/styles";
  2. import { useDispatch } from "react-redux";
  3. import CloseIcon from '@mui/icons-material/Close';
  4. import ReplyIcon from '@mui/icons-material/Reply';
  5. import MenuItem from '@mui/material/MenuItem';
  6. import ListItemText from '@mui/material/ListItemText';
  7. import LibraryMusicIcon from '@mui/icons-material/LibraryMusic';
  8. import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
  9. import ImageIcon from '@mui/icons-material/Image';
  10. import ContentCopyIcon from '@mui/icons-material/ContentCopy';
  11. import VideoLibraryIcon from '@mui/icons-material/VideoLibrary';
  12. import { firstLetter,slicedWord } from "../../../../../../helpers";
  13. import { TMessage } from "../../../../../../typescript/redux/messages/types";
  14. import { asyncGetChatById } from '../../../../../../redux/chat/operations'
  15. import { actionRightIsOpen, actionOpenPinned } from '../../../../../../redux/control/action'
  16. const useStyles = makeStyles({
  17. forwardTop : {
  18. position: 'absolute',
  19. left: 0,
  20. top: '-7vh',
  21. height: '6vh',
  22. width: '100%',
  23. borderRadius: 8,
  24. display: 'flex',
  25. flexWrap: 'nowrap',
  26. alignContent: 'center',
  27. alignItems: 'center',
  28. color: '#6b6b6b',
  29. border:'solid 2px rgb(41, 139, 231)',
  30. backgroundColor: '#ffffff',
  31. padding: '0px 5px',
  32. zIndex:2,
  33. },
  34. forwardIconClose: {
  35. cursor: 'pointer',
  36. marginLeft: 5,
  37. marginRight: 5,
  38. '&:hover': {
  39. color:'#f02a2a',
  40. transform: 'rotate(180deg)',
  41. transition: 'all 250ms ease-out ',
  42. }
  43. },
  44. forwardListWrapper: {
  45. width: '100%',
  46. },
  47. forwardColumn: {
  48. height: '80%',
  49. width: 2,
  50. backgroundColor: 'rgb(41, 139, 231)',
  51. marginRight:10
  52. },
  53. folderIcon: {
  54. color: '#54b0fc',
  55. },
  56. });
  57. interface IForwardBar {
  58. companionId: string,
  59. isForward:TMessage,
  60. handleCloseForward: () => void,
  61. handleScrollToTheMessage: (_id: string) => void,
  62. setIsForward: React.Dispatch<React.SetStateAction<TMessage | undefined>>,
  63. }
  64. const ForwardBar = ({ companionId,isForward, handleCloseForward,handleScrollToTheMessage,setIsForward }: IForwardBar) => {
  65. const classes = useStyles();
  66. const dispatch = useDispatch()
  67. const handleScrollHereOrBack = () => {
  68. if (companionId === isForward.companionId) return handleScrollToTheMessage(isForward._id)
  69. setIsForward(undefined)
  70. dispatch(actionRightIsOpen(''))
  71. dispatch(actionOpenPinned(false))
  72. dispatch(asyncGetChatById(isForward.companionId))
  73. setTimeout(() => handleScrollToTheMessage(isForward._id), 2000)
  74. }
  75. return (
  76. <div className={classes.forwardTop}>
  77. <ReplyIcon style={{margin:'0px 7px',color: "rgb(41, 139, 231)",transform :'rotateY(180deg)'}} />
  78. <div className={classes.forwardColumn}></div>
  79. <ul className={classes.forwardListWrapper}>
  80. <MenuItem onClick={handleScrollHereOrBack}>
  81. <ListItemText
  82. primary={`${firstLetter(isForward.name)}${slicedWord(isForward.name, 15, 1)}
  83. ${firstLetter(isForward.lastName)}${slicedWord(isForward.lastName, 15, 1)}`}
  84. primaryTypographyProps={{ color: "rgb(41, 139, 231)",fontSize:16 }}
  85. secondary={`Type : ${isForward.type.toUpperCase()}`}
  86. secondaryTypographyProps={{ fontSize:16 }}/>
  87. {isForward.type === 'text' &&<ContentCopyIcon className={classes.folderIcon} fontSize='large' />}
  88. {isForward.type === 'audio' &&<LibraryMusicIcon className={classes.folderIcon} fontSize='large' />}
  89. {isForward.type === 'video' &&<VideoLibraryIcon className={classes.folderIcon} fontSize='large' />}
  90. {isForward.type === 'image' &&<ImageIcon className={classes.folderIcon} fontSize='large' />}
  91. {isForward.type === 'pdf'&&<InsertDriveFileIcon className={classes.folderIcon} fontSize='large' />}
  92. {isForward.type === 'docx'&&<InsertDriveFileIcon className={classes.folderIcon} fontSize='large' />}
  93. </MenuItem>
  94. </ul>
  95. <CloseIcon onClick={handleCloseForward} className={classes.forwardIconClose} />
  96. </div>
  97. )
  98. }
  99. export default ForwardBar