1 import { Component, linkEvent } from "inferno";
2 import { i18n } from "../../i18next";
3 import { DataType } from "../../interfaces";
5 interface DataTypeSelectProps {
7 onChange?(val: DataType): any;
10 interface DataTypeSelectState {
14 export class DataTypeSelect extends Component<
18 private emptyState: DataTypeSelectState = {
19 type_: this.props.type_,
22 constructor(props: any, context: any) {
23 super(props, context);
24 this.state = this.emptyState;
27 static getDerivedStateFromProps(props: any): DataTypeSelectProps {
35 <div class="btn-group btn-group-toggle flex-wrap mb-2">
37 className={`pointer btn btn-outline-secondary
38 ${this.state.type_ == DataType.Post && "active"}
44 checked={this.state.type_ == DataType.Post}
45 onChange={linkEvent(this, this.handleTypeChange)}
50 className={`pointer btn btn-outline-secondary ${
51 this.state.type_ == DataType.Comment && "active"
56 value={DataType.Comment}
57 checked={this.state.type_ == DataType.Comment}
58 onChange={linkEvent(this, this.handleTypeChange)}
66 handleTypeChange(i: DataTypeSelect, event: any) {
67 i.props.onChange(Number(event.target.value));