From 504c080d8fa091682dd9f6a5bbc261375ca03861 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 20 Jun 2018 16:33:51 +0300 Subject: post comments --- vnext/src/components/Thread.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'vnext/src/components/Thread.js') diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js index 96b7e093..cfef2372 100644 --- a/vnext/src/components/Thread.js +++ b/vnext/src/components/Thread.js @@ -18,6 +18,7 @@ export default class Thread extends React.Component { replies: [] }; this.loaded = this.loaded.bind(this); + this.postComment = this.postComment.bind(this); } componentDidMount() { document.body.scrollTop = 0; @@ -52,6 +53,25 @@ export default class Thread extends React.Component { loaded() { return this.state.msg.mid; } + + postComment(template) { + const url = `https://api.juick.com/comment?hash=${this.props.visitor.hash}`; + let form = new FormData(); + form.append('mid', template.mid); + form.append('rid', template.rid); + form.append('body', template.body); + form.append('attach', template.attach); + fetch(url, { + method: 'POST', + body: form + }).then(response => { + return response.json() + }).then(res => { + this.loadReplies() + }) + .catch(console.log) + } + render() { const msg = this.state.msg; return ( @@ -61,7 +81,7 @@ export default class Thread extends React.Component { { this.loaded() ? ( - + ) : ( -- cgit v1.2.3