-
Notifications
You must be signed in to change notification settings - Fork 24
/
AttendeesChatInputContainer.js
87 lines (79 loc) · 2.34 KB
/
AttendeesChatInputContainer.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "@voxeet/react-redux-5.1.1";
import attachIcon from '../../../static/images/icons/icon-attach.svg';
import sendIcon from '../../../static/images/icons/icon-tag.svg';
import { strings } from "../../languages/localizedStrings";
class AttendeesChatInputContainer extends Component {
constructor(props) {
super(props);
this.state = {
content: ""
};
this.onContentChange = this.onContentChange.bind(this);
this.escFunction = this.escFunction.bind(this);
}
componentDidMount() {
document.addEventListener("keydown", this.escFunction, false);
}
componentWillUnmount() {
document.removeEventListener("keydown", this.escFunction, false);
}
escFunction(event) {
const { sendMessage } = this.props;
if (event.keyCode === 13) {
sendMessage(this.state.content);
this.setState({ content: "" });
event.preventDefault();
}
}
onContentChange(e) {
let content = e.target.value;
this.setState({ content: content });
}
render() {
const { sendMessage } = this.props;
const { content } = this.state;
return (
<div className="container-input-chat">
<div className="container-attach">
<a
// onClick={e => {
// this.setState({ content: "" });
// sendMessage(this.state.content);
// e.preventDefault();
// }}
>
<img src={attachIcon} />
{/* {strings.sendMessage} */}
</a>
</div>
<div className="container-input">
<input
placeholder={strings.placeholderChat}
onChange={this.onContentChange}
value={content}
id="contentInputChat"
className="input-message"
></input>
</div>
<div className="container-send">
<a
onClick={e => {
this.setState({ content: "" });
sendMessage(this.state.content);
e.preventDefault();
}}
>
<img src={sendIcon} />
{/* {strings.sendMessage} */}
</a>
</div>
</div>
);
}
}
AttendeesChatInputContainer.propTypes = {
sendMessage: PropTypes.func.isRequired
};
export default AttendeesChatInputContainer;