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;
28 static getDerivedStateFromProps(props: any): DataTypeSelectProps {
36 <div class="btn-group btn-group-toggle flex-wrap mb-2">
38 className={`pointer btn btn-outline-secondary
39 ${this.state.type_ == DataType.Post && "active"}
45 checked={this.state.type_ == DataType.Post}
46 onChange={linkEvent(this, this.handleTypeChange)}
51 className={`pointer btn btn-outline-secondary ${
52 this.state.type_ == DataType.Comment && "active"
57 value={DataType.Comment}
58 checked={this.state.type_ == DataType.Comment}
59 onChange={linkEvent(this, this.handleTypeChange)}
67 handleTypeChange(i: DataTypeSelect, event: any) {
68 i.props.onChange(Number(event.target.value));