diff --git a/frontend/src/components/MessageInput/index.js b/frontend/src/components/MessageInput/index.js index d6e1bb6..e375d50 100644 --- a/frontend/src/components/MessageInput/index.js +++ b/frontend/src/components/MessageInput/index.js @@ -1,9 +1,10 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useContext } from "react"; import "emoji-mart/css/emoji-mart.css"; import { useParams } from "react-router-dom"; import { Picker } from "emoji-mart"; import { toast } from "react-toastify"; import MicRecorder from "mic-recorder-to-mp3"; +import clsx from "clsx"; import { makeStyles } from "@material-ui/core/styles"; import Paper from "@material-ui/core/Paper"; @@ -15,6 +16,7 @@ import IconButton from "@material-ui/core/IconButton"; import MoodIcon from "@material-ui/icons/Mood"; import SendIcon from "@material-ui/icons/Send"; import CancelIcon from "@material-ui/icons/Cancel"; +import ClearIcon from "@material-ui/icons/Clear"; import MicIcon from "@material-ui/icons/Mic"; import CheckCircleOutlineIcon from "@material-ui/icons/CheckCircleOutline"; import HighlightOffIcon from "@material-ui/icons/HighlightOff"; @@ -22,20 +24,30 @@ import HighlightOffIcon from "@material-ui/icons/HighlightOff"; import { i18n } from "../../translate/i18n"; import api from "../../services/api"; import RecordingTimer from "./RecordingTimer"; +import { ReplyMessageContext } from "../../context/ReplyingMessage/ReplyingMessageContext"; const Mp3Recorder = new MicRecorder({ bitRate: 128 }); const useStyles = makeStyles(theme => ({ - newMessageBox: { + mainWrapper: { background: "#eee", display: "flex", - padding: "7px", + flexDirection: "column", alignItems: "center", borderTop: "1px solid rgba(0, 0, 0, 0.12)", }, + newMessageBox: { + background: "#eee", + width: "100%", + display: "flex", + padding: "7px", + alignItems: "center", + }, + messageInputWrapper: { padding: 6, + marginRight: 7, background: "#fff", display: "flex", borderRadius: 20, @@ -79,8 +91,6 @@ const useStyles = makeStyles(theme => ({ position: "absolute", top: "20%", left: "50%", - // marginTop: 8, - // marginBottom: 6, marginLeft: -12, }, @@ -102,6 +112,62 @@ const useStyles = makeStyles(theme => ({ sendAudioIcon: { color: "green", }, + + quotedMsgWrapper: { + display: "flex", + width: "100%", + alignItems: "center", + justifyContent: "center", + paddingTop: 8, + paddingLeft: 73, + paddingRight: 7, + }, + + quotedContainerRight: { + flex: 1, + marginRight: 5, + overflowY: "hidden", + backgroundColor: "rgba(0, 0, 0, 0.05)", + borderRadius: "7.5px", + display: "flex", + position: "relative", + }, + + quotedMsgRight: { + padding: 10, + maxWidth: 300, + height: "auto", + whiteSpace: "pre-wrap", + }, + + quotedSideRight: { + flex: "none", + width: "4px", + backgroundColor: "#35cd96", + }, + + quotedContainerLeft: { + overflow: "hidden", + backgroundColor: "rgba(0, 0, 0, 0.05)", + borderRadius: "7.5px", + display: "flex", + position: "relative", + }, + + quotedMsg: { + padding: 10, + maxWidth: 300, + height: "auto", + display: "block", + whiteSpace: "pre-wrap", + overflow: "hidden", + }, + + quotedSideLeft: { + flex: "none", + width: "4px", + backgroundColor: "#6bcbef", + }, })); const MessageInput = ({ ticketStatus }) => { @@ -114,6 +180,9 @@ const MessageInput = ({ ticketStatus }) => { const [showEmoji, setShowEmoji] = useState(false); const [loading, setLoading] = useState(false); const [recording, setRecording] = useState(false); + const { setReplyingMessage, replyingMessage } = useContext( + ReplyMessageContext + ); useEffect(() => { return () => { @@ -263,6 +332,40 @@ const MessageInput = ({ ticketStatus }) => { } }; + const renderQuotedMessage = message => { + return ( +
+
+ +
+ {!message.fromMe && ( + + {message.contact?.name} + + )} + {message.body} +
+
+ setReplyingMessage({})} + > + + +
+ ); + }; + if (medias.length > 0) return ( @@ -296,115 +399,118 @@ const MessageInput = ({ ticketStatus }) => { ); else { return ( - - setShowEmoji(prevState => !prevState)} - > - - - {showEmoji ? ( -
- -
- ) : null} - - -