1 import { Component, linkEvent } from 'inferno';
2 import { DataType } from '../interfaces';
4 import { i18n } from '../i18next';
6 interface DataTypeSelectProps {
8 onChange?(val: DataType): any;
11 interface DataTypeSelectState {
15 export class DataTypeSelect extends Component<
19 private emptyState: DataTypeSelectState = {
20 type_: this.props.type_,
23 constructor(props: any, context: any) {
24 super(props, context);
25 this.state = this.emptyState;
30 <div class="btn-group btn-group-toggle">
32 className={`pointer btn btn-sm btn-secondary
33 ${this.state.type_ == DataType.Post && 'active'}
39 checked={this.state.type_ == DataType.Post}
40 onChange={linkEvent(this, this.handleTypeChange)}
45 className={`pointer btn btn-sm btn-secondary ${this.state.type_ ==
46 DataType.Comment && 'active'}`}
50 value={DataType.Comment}
51 checked={this.state.type_ == DataType.Comment}
52 onChange={linkEvent(this, this.handleTypeChange)}
60 handleTypeChange(i: DataTypeSelect, event: any) {
61 i.state.type_ = Number(event.target.value);
63 i.props.onChange(i.state.type_);