From f470636a70943a8ecad8bddc791a1c2dddd28e1e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 4 May 2019 21:13:12 +0300 Subject: Components -> UI --- vnext/src/ui/Post.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 vnext/src/ui/Post.js (limited to 'vnext/src/ui/Post.js') diff --git a/vnext/src/ui/Post.js b/vnext/src/ui/Post.js new file mode 100644 index 00000000..3dc23613 --- /dev/null +++ b/vnext/src/ui/Post.js @@ -0,0 +1,38 @@ +import React, { memo } from 'react'; + +import ReactRouterPropTypes from 'react-router-prop-types'; +import { UserType } from './Types'; + +import qs from 'qs'; + +import MessageInput from './MessageInput'; + +import { post } from '../api'; + +function PostComponent(props) { + let params = qs.parse(window.location.search.substring(1)); + let postMessage = (template) => { + const { attach, body } = template; + post(body, attach) + .then(response => { + if (response.status === 200) { + const msg = response.data.newMessage; + this.props.history.push(`/${this.props.visitor.uname}/${msg.mid}`); + } + }).catch(console.log); + }; + return ( +
+ + *weather It is very cold today! + +
+ ); +} + +export default memo(PostComponent); + +PostComponent.propTypes = { + history: ReactRouterPropTypes.history.isRequired, + visitor: UserType +}; -- cgit v1.2.3