1 import { Component, linkEvent } from 'inferno';
2 import { SortType } from '../interfaces';
3 import { i18n } from '../i18next';
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 { i18n.t('sort_type') }
36 {!this.props.hideHot && (
37 <option value={SortType.Hot}>
41 <option value={SortType.New}>
44 <option disabled>─────</option>
45 <option value={SortType.TopDay}>
48 <option value={SortType.TopWeek}>
51 <option value={SortType.TopMonth}>
54 <option value={SortType.TopYear}>
57 <option value={SortType.TopAll}>
64 handleSortChange(i: SortSelect, event: any) {
65 i.state.sort = Number(event.target.value);
67 i.props.onChange(i.state.sort);