|
@@ -4,19 +4,22 @@ import { MyDropzone } from "./dropzone"
|
|
|
import ScrollableFeed from 'react-scrollable-feed'
|
|
|
import { Link } from "react-router-dom"
|
|
|
|
|
|
-const Chat = ({ chat_id, chat_title, chat_avatar, user_id, messages, onUpload, onSend }) => {
|
|
|
+const Chat = ({ chat_id, chat_title, user_id, messages, onUpload, onSend }) => {
|
|
|
let [msg, setMSG] = useState("")
|
|
|
let [isUpload, setIsUpload] = useState(false)
|
|
|
let [files, setFiles] = useState([])
|
|
|
console.log(files)
|
|
|
+
|
|
|
let filesHandler = (file) => {
|
|
|
- files.length ? setFiles([...files, file]) : setFiles([file])
|
|
|
+ setFiles(file)
|
|
|
}
|
|
|
|
|
|
let handler = (e) => {
|
|
|
if ((e.key === "Enter" && !e.shiftKey) || e.type === "click") {
|
|
|
onSend(chat_id, msg, files)
|
|
|
setMSG("")
|
|
|
+ setFiles([])
|
|
|
+ setIsUpload(false)
|
|
|
e.preventDefault()
|
|
|
}
|
|
|
}
|
|
@@ -37,7 +40,7 @@ const Chat = ({ chat_id, chat_title, chat_avatar, user_id, messages, onUpload, o
|
|
|
{isUpload && <MyDropzone onUpload={onUpload} onSet={filesHandler} />}
|
|
|
<button onClick={(e) => handler(e)}>Отправить</button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </div >
|
|
|
)
|
|
|
}
|
|
|
|