1 import { Component, linkEvent } from 'inferno';
2 import { ListingType } from '../interfaces';
3 import { UserService } from '../services';
5 import { i18n } from '../i18next';
7 interface ListingTypeSelectProps {
9 onChange?(val: ListingType): any;
12 interface ListingTypeSelectState {
16 export class ListingTypeSelect extends Component<
17 ListingTypeSelectProps,
18 ListingTypeSelectState
20 private emptyState: ListingTypeSelectState = {
21 type_: this.props.type_,
24 constructor(props: any, context: any) {
25 super(props, context);
26 this.state = this.emptyState;
31 <div class="btn-group btn-group-toggle">
33 className={`btn btn-sm btn-secondary
34 ${this.state.type_ == ListingType.Subscribed && 'active'}
35 ${UserService.Instance.user == undefined ? 'disabled' : 'pointer'}
40 value={ListingType.Subscribed}
41 checked={this.state.type_ == ListingType.Subscribed}
42 onChange={linkEvent(this, this.handleTypeChange)}
43 disabled={UserService.Instance.user == undefined}
45 {i18n.t('subscribed')}
48 className={`pointer btn btn-sm btn-secondary ${this.state.type_ ==
49 ListingType.All && 'active'}`}
53 value={ListingType.All}
54 checked={this.state.type_ == ListingType.All}
55 onChange={linkEvent(this, this.handleTypeChange)}
63 handleTypeChange(i: ListingTypeSelect, event: any) {
64 i.state.type_ = Number(event.target.value);
66 i.props.onChange(i.state.type_);