1 import { Component, linkEvent } from 'inferno';
2 import { SortType } from '../interfaces';
4 import { T } from 'inferno-i18next';
6 interface SortSelectProps {
8 onChange?(val: SortType): any;
12 interface SortSelectState {
16 export class SortSelect extends Component<SortSelectProps, SortSelectState> {
17 private emptyState: SortSelectState = {
18 sort: this.props.sort,
21 constructor(props: any, context: any) {
22 super(props, context);
23 this.state = this.emptyState;
29 value={this.state.sort}
30 onChange={linkEvent(this, this.handleSortChange)}
31 class="custom-select custom-select-sm w-auto"
34 <T i18nKey="sort_type">#</T>
36 {!this.props.hideHot && (
37 <option value={SortType.Hot}>
38 <T i18nKey="hot">#</T>
41 <option value={SortType.New}>
42 <T i18nKey="new">#</T>
44 <option disabled>─────</option>
45 <option value={SortType.TopDay}>
46 <T i18nKey="top_day">#</T>
48 <option value={SortType.TopWeek}>
49 <T i18nKey="week">#</T>
51 <option value={SortType.TopMonth}>
52 <T i18nKey="month">#</T>
54 <option value={SortType.TopYear}>
55 <T i18nKey="year">#</T>
57 <option value={SortType.TopAll}>
58 <T i18nKey="all">#</T>
64 handleSortChange(i: SortSelect, event: any) {
65 i.state.sort = Number(event.target.value);
67 i.props.onChange(i.state.sort);