blob: fd577603c87a6999b7d85c289ba962e098f04b01 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import React from 'react';
import MessageInput from './MessageInput';
import { post } from '../api';
export default class Post extends React.Component {
constructor(props) {
super(props)
this.state = {
attach: '',
body: ''
}
this.fileinput = React.createRef();
console.log(props)
}
postMessage = (template) => {
const { attach, body } = template;
post(body, attach)
.then(response => {
console.log(response)
if (response.status === 200) {
const msg = response.data.newMessage;
console.log(msg)
this.props.history.push(`/${this.props.visitor.uname}/${msg.mid}`);
}
}).catch(console.log);
}
attachChanged = (event) => {
this.setState({
attach: event.target.value
})
}
bodyChanged = (event) => {
this.setState({
body: event.target.value
})
}
render() {
return (
<article>
<MessageInput rows="7" data={{ mid: 0, timestamp: "0" }} onSend={this.postMessage}>
*weather It's very cold today!
</MessageInput>
</article>
);
}
}
|