import { Button, Card, Input, Icon } from "antd"; import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import twilio from "twilio"; import { closeConversation, toggleConversationVisible } from "../../redux/messaging/messaging.actions"; import PhoneFormatter from "../../utils/PhoneFormatter"; import "./chat-conversation.styles.scss"; //https://bootsnipp.com/snippets/exR5v import { MdSend } from "react-icons/md"; import { useTranslation } from "react-i18next"; const client = twilio( "ACf1b1aaf0e04740828b49b6e58467d787", "0bea5e29a6d77593183ab1caa01d23de" ); const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser }); const mapDispatchToProps = dispatch => ({ toggleConversationVisible: conversationId => dispatch(toggleConversationVisible(conversationId)), closeConversation: phone => dispatch(closeConversation(phone)) }); export default connect( mapStateToProps, mapDispatchToProps )(function ChatConversationComponent({ conversation, toggleConversationVisible, closeConversation }) { const { t } = useTranslation(); const [messages, setMessages] = useState([]); useEffect(() => { client.messages.list({ limit: 20 }, (error, items) => { setMessages( items.reduce((acc, value) => { acc.push({ sid: value.sid, direction: value.direction, body: value.body }); return acc; }, []) ); }); return () => {}; }, [setMessages]); return (
toggleConversationVisible(conversation.phone)} > {conversation.phone}
) : null } style={{ width: conversation.open ? "400px" : "175px", margin: "0px 10px" }} size="small" > {conversation.open ? (
} />
) : (
toggleConversationVisible(conversation.phone)}> {conversation.phone}
)} ); });