import React, { useState } from "react"; import { connect } from "react-redux"; import { useDropzone } from "react-dropzone"; import { Link } from "react-router-dom"; import Button from "react-bootstrap/esm/Button"; import { Input, InputDebounce } from "../helpers/UserSearch"; import { CSearchByLogin } from "../helpers/UserSearch"; import { actionSetChatInfo } from "../actions"; import { CChatAvatar } from "../components/Avatar"; const ChatPage = ({ onChat, chat, myProfile, create }) => { const [img, setImg] = useState(null); const [title, setTitle] = useState(chat?.title || ""); const [members, setMembers] = useState(chat?.members || [myProfile]); const { getRootProps, getInputProps, isDragActive } = useDropzone({ accept: "image/*", maxFiles: 1, onDrop: (acceptedFiles) => { setImg(acceptedFiles[0]); }, }); function prepareMembers(members) { const newMembers = []; for (const member of members) { if (create) { if (member._id !== myProfile?._id) { newMembers.push({ _id: member._id }); } } else { newMembers.push({ _id: member._id }); } } return newMembers; } return (
{isDragActive ? (

Drop the files here ...

) : ( )}
{ setTitle(e.target.value); }} />
Back to all chats
); }; export const CNewChatPage = connect( (state) => ({ myProfile: state.promise.myProfile?.payload || {}, }), { onChat: actionSetChatInfo } )(ChatPage);