diff --git a/client/package.json b/client/package.json index 53b892548..0ee8609c1 100644 --- a/client/package.json +++ b/client/package.json @@ -40,7 +40,8 @@ "redux-saga": "^1.1.3", "reselect": "^4.0.0", "styled-components": "^5.0.1", - "subscriptions-transport-ws": "^0.9.16" + "subscriptions-transport-ws": "^0.9.16", + "twilio": "^3.39.5" }, "scripts": { "start": "react-scripts start", diff --git a/client/src/components/chat-window/chat-window.component.jsx b/client/src/components/chat-window/chat-window.component.jsx index fa5f3539d..53b5f790e 100644 --- a/client/src/components/chat-window/chat-window.component.jsx +++ b/client/src/components/chat-window/chat-window.component.jsx @@ -1,10 +1,53 @@ -import React from "react"; - +import { Card } from "antd"; +import React, { useState, useEffect } from "react"; +import "./chat-window.styles.scss"; //https://bootsnipp.com/snippets/exR5v +import twilio from "twilio"; +// const client = require("twilio")( +// "ACf1b1aaf0e04740828b49b6e58467d787", +// "0bea5e29a6d77593183ab1caa01d23de" +// ); +const client = twilio( + "ACf1b1aaf0e04740828b49b6e58467d787", + "0bea5e29a6d77593183ab1caa01d23de" +); export default function ChatWindowComponent({ toggleChatVisible }) { + const [conversations, setConversations] = useState([]); + + useEffect(() => { + client.messages.list({ limit: 20 }, (error, items) => { + setConversations( + items.reduce((acc, value) => { + acc.push({ + sid: value.sid, + direction: value.direction, + body: value.body + }); + return acc; + }, []) + ); + }); + return () => {}; + }, [setConversations]); + + console.log(conversations); return ( -
- This is a chat - window! -
+ +
+ +
+
    + {conversations.map(item => ( +
  • +

    {item.body}

    +
  • + ))} +
+
+
+
); } diff --git a/client/src/components/chat-window/chat-window.container.jsx b/client/src/components/chat-window/chat-window.container.jsx index 09b3f7152..effb4c00b 100644 --- a/client/src/components/chat-window/chat-window.container.jsx +++ b/client/src/components/chat-window/chat-window.container.jsx @@ -1,3 +1,4 @@ +import { Affix, Button, Badge } from "antd"; import React from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -17,8 +18,20 @@ export default connect( mapStateToProps, mapDispatchToProps )(function ChatWindowContainer({ chatVisible, toggleChatVisible }) { - if (chatVisible) - return ; - - return
toggleChatVisible()}>Chat
; + return ( + + {chatVisible ? ( + + ) : ( + +