aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Post.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-06-28 13:28:02 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:53 +0300
commit3c61705c062234adc954c8a42e3ea53ff1007bb6 (patch)
tree62660e83321b13963cdeb45e46cfa0a1203552a4 /vnext/src/components/Post.js
parentc3cd88c90cf3866324af4b12ab573a0392681c74 (diff)
MessageInput in Post
Diffstat (limited to 'vnext/src/components/Post.js')
-rw-r--r--vnext/src/components/Post.js30
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>
);
}
}