blob: e8ebab5c25e77209215f4a9a1b0479d29e1051ec (
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
49
50
51
52
|
import React from 'react';
import * as qs from 'query-string';
import MessageInput from './MessageInput';
import { post } from '../api';
export default class Post extends React.Component {
constructor(props) {
super(props)
let params = qs.parse(window.location.search);
this.state = {
attach: '',
body: params.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 (
<div className="msgs">
<article className="msg-cont">
<MessageInput rows="7" text={this.state.body} data={{ mid: 0, timestamp: "0" }} onSend={this.postMessage}>
*weather It's very cold today!
</MessageInput>
</article>
</div>
);
}
}
|