diff options
Diffstat (limited to 'vnext/src/components/Post.js')
-rw-r--r-- | vnext/src/components/Post.js | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/vnext/src/components/Post.js b/vnext/src/components/Post.js index e8ebab5c..ff99cc27 100644 --- a/vnext/src/components/Post.js +++ b/vnext/src/components/Post.js @@ -1,4 +1,8 @@ import React from 'react'; + +import ReactRouterPropTypes from 'react-router-prop-types'; +import { UserType } from './Types'; + import * as qs from 'query-string'; import MessageInput from './MessageInput'; @@ -7,23 +11,23 @@ import { post } from '../api'; export default class Post extends React.Component { constructor(props) { - super(props) + super(props); let params = qs.parse(window.location.search); this.state = { attach: '', body: params.body || '' } this.fileinput = React.createRef(); - console.log(props) + console.log(props); } postMessage = (template) => { const { attach, body } = template; post(body, attach) .then(response => { - console.log(response) + console.log(response); if (response.status === 200) { const msg = response.data.newMessage; - console.log(msg) + console.log(msg); this.props.history.push(`/${this.props.visitor.uname}/${msg.mid}`); } }).catch(console.log); @@ -31,22 +35,27 @@ export default class Post extends React.Component { attachChanged = (event) => { this.setState({ attach: event.target.value - }) + }); } bodyChanged = (event) => { this.setState({ body: event.target.value - }) + }); } render() { return ( <div className="msgs"> <article className="msg-cont"> - <MessageInput rows="7" text={this.state.body} data={{ mid: 0, timestamp: "0" }} onSend={this.postMessage}> - *weather It's very cold today! + <MessageInput rows="7" text={this.state.body} data={{ mid: 0, timestamp: '0' }} onSend={this.postMessage}> + *weather It is very cold today! </MessageInput> </article> </div> ); } } + +Post.propTypes = { + history: ReactRouterPropTypes.history.isRequired, + visitor: UserType +}; |