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