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 state: DataTypeSelectState = {
19 type_: this.props.type_,
22 constructor(props: any, context: any) {
23 super(props, context);
26 static getDerivedStateFromProps(props: any): DataTypeSelectProps {
34 <div className="btn-group btn-group-toggle flex-wrap mb-2">
36 className={`pointer btn btn-outline-secondary
37 ${this.state.type_ == DataType.Post && "active"}
43 checked={this.state.type_ == DataType.Post}
44 onChange={linkEvent(this, this.handleTypeChange)}
49 className={`pointer btn btn-outline-secondary ${
50 this.state.type_ == DataType.Comment && "active"
55 value={DataType.Comment}
56 checked={this.state.type_ == DataType.Comment}
57 onChange={linkEvent(this, this.handleTypeChange)}
65 handleTypeChange(i: DataTypeSelect, event: any) {
66 i.props.onChange?.(Number(event.target.value));