aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Chat.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/components/Chat.js')
-rw-r--r--vnext/src/components/Chat.js50
1 files changed, 33 insertions, 17 deletions
diff --git a/vnext/src/components/Chat.js b/vnext/src/components/Chat.js
index c4d9422f..8f3a26c0 100644
--- a/vnext/src/components/Chat.js
+++ b/vnext/src/components/Chat.js
@@ -32,6 +32,22 @@ export default class Chat extends React.Component {
}
}
+ onSend = (template) => {
+ const url = `https://api.juick.com/pm?hash=${this.props.visitor.hash}`;
+ let form = new FormData();
+ form.append('body', template.body);
+ form.append('uname', template.to.uname);
+ fetch(url, {
+ method: 'POST',
+ body: form
+ }).then(response => {
+ return response.json()
+ }).then(res => {
+ this.loadChat(this.props.match.params.user);
+ })
+ .catch(console.log)
+ }
+
render() {
const { chats } = this.state;
const uname = this.props.match.params.user;
@@ -39,23 +55,23 @@ export default class Chat extends React.Component {
<div id="content">
<article>
- { uname ? (
- <div className="chatroom">
- <ul style={chatStyle} ref="chats">
- {
- chats.map((chat) =>
- <PM key={moment.utc(chat.timestamp).valueOf()} chat={chat} />
- )
- }
- </ul>
- <MessageInput data={{}} onSend={()=>{}}/>
+ {uname ? (
+ <div className="chatroom">
+ <ul style={chatStyle} ref="chats">
+ {
+ chats.map((chat) =>
+ <PM key={moment.utc(chat.timestamp).valueOf()} chat={chat} />
+ )
+ }
+ </ul>
+ <MessageInput data={{ mid: 0, timestamp: "0", to: { uname: uname } }} onSend={this.onSend} />
+ </div>
+ ) : (
+ <div className="chatroom no-selection"><p>No chat selected</p></div>
+ )
+ }
+ </article>
</div>
- ) : (
- <div className="chatroom no-selection"><p>No chat selected</p></div>
- )
- }
- </article>
- </div>
)
}
}
@@ -67,5 +83,5 @@ const chatStyle = {
height: '450px',
display: 'flex',
flexDirection: 'column-reverse',
- width: '100%'
+ width: '100%'
}