|
@@ -12,8 +12,6 @@ import Avatar from '@mui/material/Avatar';
|
|
|
import Webcam from "react-webcam";
|
|
|
import CameraIcon from '@mui/icons-material/Camera';
|
|
|
import TextField from '@mui/material/TextField';
|
|
|
-import MenuItem from '@mui/material/MenuItem';
|
|
|
-import ListItemText from '@mui/material/ListItemText';
|
|
|
import Picker from 'emoji-picker-react';
|
|
|
import InputAdornment from '@mui/material/InputAdornment';
|
|
|
|
|
@@ -21,67 +19,70 @@ import { useReactMediaRecorder } from "react-media-recorder";
|
|
|
import { useState,useEffect,useCallback } from "react";
|
|
|
import { useSelector } from "react-redux";
|
|
|
|
|
|
-import FilesMenu from "../FilesMenu";
|
|
|
+import FilesMenu from "./FilesMenu";
|
|
|
+import ReplyBar from './ReplyBar'
|
|
|
+import ForwardBar from "./ForwardBar";
|
|
|
+import ForwardSearchList from "./ForwardSearchList";
|
|
|
import {
|
|
|
sentMessageById, sentImgMessageById, sentAudioMessageById,
|
|
|
sentVideoMessageById,sentFileMessageById,sentMessageReplyById
|
|
|
} from '../../../../../api-data'
|
|
|
import { getChat } from '../../../../../redux/chat/selector'
|
|
|
import { getRightIsOpen } from '../../../../../redux/control/selector'
|
|
|
-import { playNotification,prodBaseURL,firstLetter,slicedWord } from "../../../../../helpers";
|
|
|
+import { playNotification,prodBaseURL } from "../../../../../helpers";
|
|
|
import { typingChat } from "../../../../../api-data";
|
|
|
import { TMessage } from "../../../../../typescript/redux/messages/types";
|
|
|
|
|
|
|
|
|
const useStyles = makeStyles({
|
|
|
- container: {
|
|
|
- width: '35vw',
|
|
|
- height:'6vh',
|
|
|
- position: 'fixed',
|
|
|
- bottom: '2vh',
|
|
|
- borderRadius: 8,
|
|
|
- padding: 10,
|
|
|
- display: 'flex',
|
|
|
- flexWrap: 'nowrap',
|
|
|
- alignContent: 'start',
|
|
|
- alignItems: 'start',
|
|
|
- color: '#6b6b6b',
|
|
|
- border:'solid 2px #ffffff',
|
|
|
- backgroundColor: '#ffffff',
|
|
|
- },
|
|
|
- containerActive: {
|
|
|
- width: '35vw',
|
|
|
- height:'6vh',
|
|
|
- position: 'fixed',
|
|
|
- bottom: '2vh',
|
|
|
- borderRadius: 8,
|
|
|
- padding: 10,
|
|
|
- display: 'flex',
|
|
|
- flexWrap: 'nowrap',
|
|
|
- alignContent: 'start',
|
|
|
- alignItems: 'start',
|
|
|
- border:'solid 2px rgb(41, 139, 231)',
|
|
|
- backgroundColor: '#ffffff',
|
|
|
- },
|
|
|
- textarea: {
|
|
|
- width: '100%',
|
|
|
- height: '100%',
|
|
|
- outline: 'none',
|
|
|
- border:'none',
|
|
|
- padding: '0px 10px',
|
|
|
- marginLeft: 8,
|
|
|
- marginRight: 8,
|
|
|
- overflowY:'auto',
|
|
|
- resize: 'none',
|
|
|
- '&::placeholder': {
|
|
|
- color: 'inherit',
|
|
|
- fontWeight: 600,
|
|
|
- fontSize:20
|
|
|
- }
|
|
|
- },
|
|
|
- attachIcon: {
|
|
|
- transform:'rotate(30deg)',
|
|
|
+ container: {
|
|
|
+ width: '35vw',
|
|
|
+ height:'6vh',
|
|
|
+ position: 'fixed',
|
|
|
+ bottom: '2vh',
|
|
|
+ borderRadius: 8,
|
|
|
+ padding: 10,
|
|
|
+ display: 'flex',
|
|
|
+ flexWrap: 'nowrap',
|
|
|
+ alignContent: 'start',
|
|
|
+ alignItems: 'start',
|
|
|
+ color: '#6b6b6b',
|
|
|
+ border:'solid 2px #ffffff',
|
|
|
+ backgroundColor: '#ffffff',
|
|
|
+ },
|
|
|
+ containerActive: {
|
|
|
+ width: '35vw',
|
|
|
+ height:'6vh',
|
|
|
+ position: 'fixed',
|
|
|
+ bottom: '2vh',
|
|
|
+ borderRadius: 8,
|
|
|
+ padding: 10,
|
|
|
+ display: 'flex',
|
|
|
+ flexWrap: 'nowrap',
|
|
|
+ alignContent: 'start',
|
|
|
+ alignItems: 'start',
|
|
|
+ border:'solid 2px rgb(41, 139, 231)',
|
|
|
+ backgroundColor: '#ffffff',
|
|
|
+ },
|
|
|
+ textarea: {
|
|
|
+ width: '100%',
|
|
|
+ height: '100%',
|
|
|
+ outline: 'none',
|
|
|
+ border:'none',
|
|
|
+ padding: '0px 10px',
|
|
|
+ marginLeft: 8,
|
|
|
+ marginRight: 8,
|
|
|
+ overflowY:'auto',
|
|
|
+ resize: 'none',
|
|
|
+ '&::placeholder': {
|
|
|
+ color: 'inherit',
|
|
|
+ fontWeight: 600,
|
|
|
+ fontSize:20
|
|
|
},
|
|
|
+ },
|
|
|
+ attachIcon: {
|
|
|
+ transform:'rotate(30deg)',
|
|
|
+ },
|
|
|
borderTop: {
|
|
|
position: 'absolute',
|
|
|
left: 0,
|
|
@@ -90,40 +91,6 @@ const useStyles = makeStyles({
|
|
|
height: 1,
|
|
|
background:'#ffffff',
|
|
|
},
|
|
|
- replyTop : {
|
|
|
- position: 'absolute',
|
|
|
- left: 0,
|
|
|
- top: '-7vh',
|
|
|
- height: '6vh',
|
|
|
- width: '100%',
|
|
|
- borderRadius: 8,
|
|
|
- display: 'flex',
|
|
|
- flexWrap: 'nowrap',
|
|
|
- alignContent: 'center',
|
|
|
- alignItems: 'center',
|
|
|
- color: '#6b6b6b',
|
|
|
- border:'solid 2px rgb(41, 139, 231)',
|
|
|
- backgroundColor: '#ffffff',
|
|
|
- padding: 0,
|
|
|
- zIndex:2,
|
|
|
- },
|
|
|
- replyIconClose: {
|
|
|
- cursor: 'pointer',
|
|
|
- margin:'0px 7px',
|
|
|
- '&:hover': {
|
|
|
- color:'#f02a2a',
|
|
|
- transform: 'rotate(180deg)',
|
|
|
- transition: 'all 250ms ease-out ',
|
|
|
- }
|
|
|
- },
|
|
|
- replyListWrapper: {
|
|
|
- width: '100%',
|
|
|
- },
|
|
|
- replyColumn: {
|
|
|
- height: '80%',
|
|
|
- width: 2,
|
|
|
- backgroundColor: '#00aeff',
|
|
|
- },
|
|
|
filesMenu: {
|
|
|
background: '#fdfdfd',
|
|
|
position: 'absolute',
|
|
@@ -141,14 +108,14 @@ const useStyles = makeStyles({
|
|
|
zIndex: 10,
|
|
|
visibility: 'visible',
|
|
|
},
|
|
|
- captionTextField: {
|
|
|
- zIndex: 10,
|
|
|
- visibility: 'visible',
|
|
|
- width: '35vw',
|
|
|
- backgroundColor: '#ffffff',
|
|
|
- borderRadius:4,
|
|
|
- },
|
|
|
- iconCancel: {
|
|
|
+ captionTextField: {
|
|
|
+ zIndex: 10,
|
|
|
+ visibility: 'visible',
|
|
|
+ width: '35vw',
|
|
|
+ backgroundColor: '#ffffff',
|
|
|
+ borderRadius:4,
|
|
|
+ },
|
|
|
+ iconCancel: {
|
|
|
position: 'absolute',
|
|
|
left: -72,
|
|
|
bottom:-1,
|
|
@@ -212,7 +179,7 @@ const useStyles = makeStyles({
|
|
|
color: '#ffffff',
|
|
|
}
|
|
|
},
|
|
|
- overlay: {
|
|
|
+ overlay: {
|
|
|
position: 'fixed',
|
|
|
top: 0,
|
|
|
left: 0,
|
|
@@ -307,10 +274,12 @@ interface ISendMessage{
|
|
|
silentMode: boolean,
|
|
|
isReply:TMessage | undefined,
|
|
|
setIsReply: React.Dispatch<React.SetStateAction<TMessage | undefined>>,
|
|
|
+ isForward: TMessage | undefined,
|
|
|
+ setIsForward: React.Dispatch<React.SetStateAction<TMessage | undefined>>,
|
|
|
handleScrollToTheMessage: (_id:string) => void
|
|
|
}
|
|
|
|
|
|
-const SendMessage = ({isArrow,silentMode,isReply,setIsReply,handleScrollToTheMessage }:ISendMessage) => {
|
|
|
+const SendMessage = ({isArrow,silentMode,isReply,setIsReply,isForward,setIsForward,handleScrollToTheMessage }:ISendMessage) => {
|
|
|
const classes = useStyles();
|
|
|
const { companionId } = useSelector(getChat)
|
|
|
const rightIsOpen = useSelector(getRightIsOpen)
|
|
@@ -363,11 +332,15 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,handleScrollToTheMes
|
|
|
}
|
|
|
|
|
|
const sentMessage = async () => {
|
|
|
- if (value && !isReply) sentMessageById(companionId, value, caption.trim())
|
|
|
+ if (value && !isReply && !isForward) sentMessageById(companionId, value, caption.trim())
|
|
|
if (value && isReply) {
|
|
|
sentMessageReplyById(isReply._id, value, caption.trim())
|
|
|
setIsReply(undefined)
|
|
|
}
|
|
|
+ if (value && isForward) {
|
|
|
+ console.log('Sent forwarded')
|
|
|
+ setIsForward(undefined)
|
|
|
+ }
|
|
|
if (mediaBlobUrl && type === 'recording') {
|
|
|
const audio = new XMLHttpRequest();
|
|
|
audio.open('GET', mediaBlobUrl, true);
|
|
@@ -493,6 +466,11 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,handleScrollToTheMes
|
|
|
clearMessage()
|
|
|
}
|
|
|
|
|
|
+ const handleCloseForward= () => {
|
|
|
+ setIsForward(undefined)
|
|
|
+ clearMessage()
|
|
|
+ }
|
|
|
+
|
|
|
const defaultState = useCallback(() => {
|
|
|
stopRecording()
|
|
|
_stopRecording()
|
|
@@ -515,6 +493,10 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,handleScrollToTheMes
|
|
|
useEffect(() => {
|
|
|
defaultState()
|
|
|
}, [isReply])
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ defaultState()
|
|
|
+ }, [isForward])
|
|
|
|
|
|
useEffect(() => {
|
|
|
defaultState()
|
|
@@ -522,21 +504,13 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,handleScrollToTheMes
|
|
|
|
|
|
return (
|
|
|
<div className={value || file || status === 'stopped' || _status === 'stopped' ?classes.containerActive:classes.container}>
|
|
|
- {isArrow && <div className={classes.borderTop}></div>}
|
|
|
- {isReply && <div className={classes.replyTop}>
|
|
|
- <CloseIcon onClick={handleCloseReply} className={classes.replyIconClose} />
|
|
|
- <div className={classes.replyColumn}></div>
|
|
|
- <ul className={classes.replyListWrapper}>
|
|
|
- <MenuItem onClick={() => handleScrollToTheMessage(isReply._id)}>
|
|
|
- <ListItemText
|
|
|
- primary={`${firstLetter(isReply.name)}${slicedWord(isReply.name, 15, 1)}
|
|
|
- ${firstLetter(isReply.lastName)}${slicedWord(isReply.lastName, 15, 1)}`}
|
|
|
- primaryTypographyProps={{ color: "#0379af",fontSize:16 }}
|
|
|
- secondary={`Type : ${isReply.type.toUpperCase()}`}
|
|
|
- secondaryTypographyProps={{ fontSize:16 }}/>
|
|
|
- </MenuItem>
|
|
|
- </ul>
|
|
|
- </div>}
|
|
|
+ {isArrow && <div className={classes.borderTop}></div>}
|
|
|
+ {isReply && <ReplyBar isReply={isReply} handleCloseReply={handleCloseReply} handleScrollToTheMessage={handleScrollToTheMessage} />}
|
|
|
+ {isForward &&
|
|
|
+ <div className={classes.overlay} id='overlay'>
|
|
|
+ <ForwardSearchList/>
|
|
|
+ </div>}
|
|
|
+ {/* {isForward && <ForwardBar isForward={isForward} handleCloseForward={handleCloseForward} handleScrollToTheMessage={handleScrollToTheMessage}/>} */}
|
|
|
{isFilming && _status !== 'stopped' &&
|
|
|
<>
|
|
|
<div className={classes.pauseLeft}>
|
|
@@ -636,9 +610,9 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,handleScrollToTheMes
|
|
|
className={classes.capturePhoto} fontSize='large' style={{marginBottom:30}} />
|
|
|
<img className={classes.capturedPicture} width='300' height='174'
|
|
|
style={{visibility:file?'visible':'hidden'}} src={file} alt='chosen pic'></img>
|
|
|
- </>}
|
|
|
- </Webcam>
|
|
|
- </div>}
|
|
|
+ </>}
|
|
|
+ </Webcam>
|
|
|
+ </div>}
|
|
|
</div>
|
|
|
)
|
|
|
}
|