1 import { Component, linkEvent } from "inferno";
2 import { DataType } from "../../interfaces";
3 import { I18NextService } from "../../services";
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="data-type-select btn-group btn-group-toggle flex-wrap">
36 className={`pointer btn btn-outline-secondary
37 ${this.state.type_ == DataType.Post && "active"}
44 checked={this.state.type_ == DataType.Post}
45 onChange={linkEvent(this, this.handleTypeChange)}
47 {I18NextService.i18n.t("posts")}
50 className={`pointer btn btn-outline-secondary ${
51 this.state.type_ == DataType.Comment && "active"
57 value={DataType.Comment}
58 checked={this.state.type_ == DataType.Comment}
59 onChange={linkEvent(this, this.handleTypeChange)}
61 {I18NextService.i18n.t("comments")}
67 handleTypeChange(i: DataTypeSelect, event: any) {
68 i.props.onChange?.(Number(event.target.value));