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, isDragActive } = useDropzone({ accept: "image/*", maxFiles: 2, onDrop: (acceptedFiles) => { setFiles(acceptedFiles[0]); }, }); 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] ? ( <> ) : (
{isDragActive ? (

Drop the files here ...

) : ( )}
{/* { setText(e.target.value); }} /> */}