diff options
author | Vitaly Takmazov | 2019-05-04 21:13:12 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:54 +0300 |
commit | f470636a70943a8ecad8bddc791a1c2dddd28e1e (patch) | |
tree | c43d109d88adbde9a696084070cdd92c6b9a004b /vnext/src/ui/Post.js | |
parent | 3d7d213e3ddc5bf4f71d536f31677b768aa3b7c0 (diff) |
Components -> UI
Diffstat (limited to 'vnext/src/ui/Post.js')
-rw-r--r-- | vnext/src/ui/Post.js | 38 |
1 files changed, 38 insertions, 0 deletions
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 ( + <div className="msg-cont"> + <MessageInput rows="7" text={params.body || ''} data={{ mid: 0, timestamp: '0' }} onSend={postMessage}> + *weather It is very cold today! + </MessageInput> + </div> + ); +} + +export default memo(PostComponent); + +PostComponent.propTypes = { + history: ReactRouterPropTypes.history.isRequired, + visitor: UserType +}; |