diff options
Diffstat (limited to 'vnext/src/components/Post.js')
-rw-r--r-- | vnext/src/components/Post.js | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/vnext/src/components/Post.js b/vnext/src/components/Post.js index 8dd8f37a..fd577603 100644 --- a/vnext/src/components/Post.js +++ b/vnext/src/components/Post.js @@ -1,6 +1,6 @@ import React from 'react'; -import Button from './Button'; +import MessageInput from './MessageInput'; import { post } from '../api'; @@ -8,17 +8,15 @@ export default class Post extends React.Component { constructor(props) { super(props) this.state = { - attach : '', + attach: '', body: '' } this.fileinput = React.createRef(); console.log(props) } - submit = (event) => { - if (event.preventDefault) event.preventDefault(); - const {attach, body} = this.state; - const input = this.fileinput.current; - post(body, attach ? input.files[0] : '') + postMessage = (template) => { + const { attach, body } = template; + post(body, attach) .then(response => { console.log(response) if (response.status === 200) { @@ -40,19 +38,11 @@ export default class Post extends React.Component { } render() { return ( - <article> - <form id="postmsg"> - <p style={{ textAlign: 'left' }}> - <b>Фото:</b> <span id="attachmentfile"> - <input style={{ width: '100%' }} type="file" name="attach" ref={this.fileinput} value={this.state.attach} onChange={this.attachChanged}/> <i>(JPG/PNG)</i></span> - </p> - <p> - <textarea name="body" value={this.state.body} onChange={this.bodyChanged} className="newmessage" rows="7" cols="10" placeholder="*weather It's very cold today!"></textarea> - <br/> - <Button className="subm" onClick={this.submit}>POST</Button> - </p> - </form> - </article> + <article> + <MessageInput rows="7" data={{ mid: 0, timestamp: "0" }} onSend={this.postMessage}> + *weather It's very cold today! + </MessageInput> + </article> ); } } |