|
@@ -135,6 +135,14 @@ const useStyles = makeStyles({
|
|
|
color: '#ffffff',
|
|
|
}
|
|
|
},
|
|
|
+ overlay: {
|
|
|
+ position: 'fixed',
|
|
|
+ top: 0,
|
|
|
+ left: 0,
|
|
|
+ width: '100vw',
|
|
|
+ height: '100vh',
|
|
|
+ zIndex:100
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
interface ISendMessage{
|
|
@@ -176,61 +184,56 @@ const SendMessage = ({isArrow,handleScrollTo}:ISendMessage) => {
|
|
|
const formData: any = new FormData()
|
|
|
formData.append("file", file);
|
|
|
sentFileMessageById(companionId, formData)
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
setTimeout(handleScrollTo, 3000);
|
|
|
playNotification('http://localhost:3000/send.mp3')
|
|
|
}
|
|
|
- const handleTextarea = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
|
- isOpenMenu&&setIsOpenMenu(false)
|
|
|
- isOpenEmoji && setIsOpenEmoji(false)
|
|
|
- setValue(e.target.value)
|
|
|
- }
|
|
|
- const handleFocusTextarea = () => {
|
|
|
- typingChat(companionId,true)
|
|
|
- isOpenMenu&&setIsOpenMenu(false)
|
|
|
- isOpenEmoji&&setIsOpenEmoji(false)
|
|
|
- }
|
|
|
- const handleBlurTextarea = () => typingChat(companionId,false)
|
|
|
+ const handleTextarea = (e: React.ChangeEvent<HTMLTextAreaElement>) => setValue(e.target.value)
|
|
|
+ const handleFocusTextarea = async () => await typingChat(companionId,true)
|
|
|
+ const handleBlurTextarea = async () => await typingChat(companionId,false)
|
|
|
|
|
|
- const handleLeaveInput = (e: any) => {
|
|
|
- if (e.clientX > 1450 || e.clientX < 850) {
|
|
|
- isOpenMenu&&setIsOpenMenu(false)
|
|
|
- isOpenEmoji&&setIsOpenEmoji(false)
|
|
|
- }
|
|
|
- }
|
|
|
- const handleMoveInput = (e: any) => {
|
|
|
- if (e.clientX < 1250 && e.clientX > 1200) {
|
|
|
- isOpenMenu&&setIsOpenMenu(false)
|
|
|
- isOpenEmoji&&setIsOpenEmoji(false)
|
|
|
- }
|
|
|
- }
|
|
|
const handleKeyPres = (e: any) => {
|
|
|
if(e.code === 'Enter'&& value) sentMessage()
|
|
|
}
|
|
|
- const handleEnterFileMenu = () => !isOpenMenu&&setIsOpenMenu(true)
|
|
|
- const handleLeaveFileMenu = () => isOpenMenu&&setIsOpenMenu(false)
|
|
|
- const handleEnterEmoji = () => !isOpenEmoji&&setIsOpenEmoji(true)
|
|
|
- const handleLeaveEmoji = () => isOpenEmoji && setIsOpenEmoji(false)
|
|
|
+ const handleOpenFileMenu = () => !isOpenMenu&&setIsOpenMenu(true)
|
|
|
+ const handleCloseFileMenu = (e:any) => {
|
|
|
+ if (e.target.id === 'overlay'&&isOpenMenu) setIsOpenMenu(false)
|
|
|
+ }
|
|
|
+ const handleOpenEmoji = () => !isOpenEmoji&&setIsOpenEmoji(true)
|
|
|
+ const handleCloseEmoji = (e: any) => {
|
|
|
+ if (e.target.id === 'overlay'&&isOpenEmoji) setIsOpenEmoji(false)
|
|
|
+ }
|
|
|
const handleClearMessage = () => setFile(null)
|
|
|
-
|
|
|
+ console.log(file)
|
|
|
return (
|
|
|
<div className={classes.container} style={{borderTop:isArrow?'solid 1px #ffffff':'none'}} >
|
|
|
- <div onMouseLeave={handleLeaveInput} onMouseMove={handleMoveInput}
|
|
|
- onKeyPress={handleKeyPres} className={classes.inputContainer}>
|
|
|
+ <div onKeyPress={handleKeyPres} className={classes.inputContainer}>
|
|
|
<CloseIcon onClick={handleClearMessage} fontSize="small" className={classes.iconCancel}
|
|
|
sx={{backgroundColor:'#ffffff',width:36,height:36,color:'#949393',display:file?'inline-block':'none'}}/>
|
|
|
- <SentimentSatisfiedAltIcon onMouseEnter={handleEnterEmoji}
|
|
|
- fontSize='medium' sx={{ color: isOpenEmoji ? 'rgb(41, 139, 231)' : '#6b6b6b' }}/>
|
|
|
- <div onMouseLeave={handleLeaveEmoji} style={{display:isOpenEmoji?'block':'none'}} className={classes.emoji}>
|
|
|
- <NotDone name='Emoji Bar'/>
|
|
|
- </div>
|
|
|
+ <SentimentSatisfiedAltIcon onClick={handleOpenEmoji}
|
|
|
+ fontSize='medium' sx={{
|
|
|
+ color: isOpenEmoji ? 'rgb(41, 139, 231)' : '#6b6b6b', cursor: 'pointer',
|
|
|
+ '&:hover': { color: 'rgb(41, 139, 231)' }
|
|
|
+ }} />
|
|
|
+ <div onClick={handleCloseEmoji} className={classes.overlay} id='overlay'
|
|
|
+ style={{ display: isOpenEmoji ? 'block':'none'}}>
|
|
|
+ <div className={classes.emoji}>
|
|
|
+ <NotDone name='Emoji Bar'/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<textarea disabled={file?true:false} value={value} onBlur={handleBlurTextarea} onFocus={handleFocusTextarea} onChange={handleTextarea}
|
|
|
className={classes.textarea} placeholder={file?'Press onto Plane to send or Cross to remove':'Message'} rows={1}></textarea>
|
|
|
- <AttachFileIcon onMouseEnter={handleEnterFileMenu} className={classes.attachIcon}
|
|
|
- fontSize='medium' sx={{color: isOpenMenu?'rgb(41, 139, 231)':'#6b6b6b'}}/>
|
|
|
- <div onMouseLeave={handleLeaveFileMenu} style={{display:isOpenMenu?'block':'none'}} className={classes.filesMenu}>
|
|
|
- <FilesMenu setFile={setFile} setValue={setValue} setIsOpenMenu={setIsOpenMenu} setType={setType}/>
|
|
|
+ <AttachFileIcon onClick={handleOpenFileMenu} className={classes.attachIcon}
|
|
|
+ fontSize='medium' sx={{
|
|
|
+ color: isOpenMenu ? 'rgb(41, 139, 231)' : '#6b6b6b', cursor: 'pointer',
|
|
|
+ '&:hover': { color: 'rgb(41, 139, 231)' }
|
|
|
+ }} />
|
|
|
+ <div onClick={handleCloseFileMenu} className={classes.overlay} id='overlay'
|
|
|
+ style={{ display: isOpenMenu ? 'block':'none'}}>
|
|
|
+ <div className={classes.filesMenu}>
|
|
|
+ <FilesMenu setFile={setFile} setValue={setValue} setIsOpenMenu={setIsOpenMenu} setType={setType}/>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<Avatar onClick={handleScrollTo} className={classes.avatarArrow} sx={{
|
|
|
backgroundColor: '#ffffff',
|