import React, { useState, useEffect } from "react"; import { connect } from "react-redux"; import { Link, useParams } from "react-router-dom"; import { actionFullMsgsByChat } from "../actions"; import { store } from "../reducers"; import Button from "react-bootstrap/esm/Button"; import { backURL } from "../constants"; import { AvatarStubHeader, color } from "../components/AvatarStub"; import { actionSendMsg } from "../actions"; import { useDropzone } from "react-dropzone"; const ChatMsgs = ({ chatMsgs = [], getChat, msgsCount = 20, sendMsg, msg, nickOwner, }) => { const [files, setFiles] = useState( msg?.media.map((mediaFile) => ({ ...mediaFile, url: backURL + mediaFile.url, })) || [] ); const { getRootProps, getInputProps } = useDropzone({ noKeyboard: true, onDrop: async (acceptedFiles) => { await setFiles([ ...files, ...acceptedFiles.map((file) => Object.assign(file, { url: URL.createObjectURL(file), }) ), ]) }, }) {console.log(files, "FILES")} const [msgsBlock, setMsgsBlock] = useState(0); let { _id } = useParams(); useEffect(() => { chatMsgs(_id, msgsBlock, msgsCount); }, [_id]); const [text, setText] = useState(""); const [msgs] = useState(getChat); const oneChatMsgs = getChat[_id]?.messages; return ( <>
{getChat[_id]?.avatar?.url ? ( ) : ( )}
{getChat[_id]?.title}
Members: {getChat[_id]?.members.length}
{oneChatMsgs === getChat[_id] ? ( <> ) : (