sort components into widgets and views

This commit is contained in:
or-else
2018-10-24 18:04:16 +03:00
parent 5367c71784
commit 99dfb0afeb
48 changed files with 454 additions and 453 deletions
+52
View File
@@ -0,0 +1,52 @@
import React from 'react';
export default class NewTopicById extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
groupId: '',
};
this.handleChange = this.handleChange.bind(this);
this.handleKeyPress = this.handleKeyPress.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(e) {
this.setState({groupId: e.target.value});
}
handleKeyPress(e) {
if (e.key === 'Enter') {
this.handleSubmit(e);
}
}
handleSubmit(e) {
e.preventDefault();
if (this.state.groupId) {
var name = this.state.groupId.trim();
if (name.length > 3 && (name.substr(0, 3) == 'usr' || name.substr(0, 3) == 'grp')) {
this.props.onSubmit(name);
} else {
this.props.onError("Invalid ID", 'err');
}
}
}
render() {
return (
<div className="panel-form">
<div className="panel-form-row">
<input type="text" placeholder="Group or User ID"
value={this.state.groupId} onChange={this.handleChange}
onKeyPress={this.handleKeyPress} required />
</div>
<div className="dialog-buttons">
<button className="blue" onClick={this.handleSubmit}>Subscribe</button>
</div>
</div>
);
}
};