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;
26 console.log(this.state);
29 static getDerivedStateFromProps(props: any): DataTypeSelectProps {
37 <div class="btn-group btn-group-toggle flex-wrap mb-2">
39 className={`pointer btn btn-outline-secondary
40 ${this.state.type_ == DataType.Post && 'active'}
46 checked={this.state.type_ == DataType.Post}
47 onChange={linkEvent(this, this.handleTypeChange)}
52 className={`pointer btn btn-outline-secondary ${
53 this.state.type_ == DataType.Comment && 'active'
58 value={DataType.Comment}
59 checked={this.state.type_ == DataType.Comment}
60 onChange={linkEvent(this, this.handleTypeChange)}
68 handleTypeChange(i: DataTypeSelect, event: any) {
69 i.props.onChange(Number(event.target.value));