type_: ListingType;
showLocal: boolean;
showSubscribed: boolean;
- onChange?(val: ListingType): any;
+ onChange(val: ListingType): void;
}
interface ListingTypeSelectState {
> {
private id = `listing-type-input-${randomStr()}`;
- private emptyState: ListingTypeSelectState = {
+ state: ListingTypeSelectState = {
type_: this.props.type_,
};
constructor(props: any, context: any) {
super(props, context);
- this.state = this.emptyState;
}
- static getDerivedStateFromProps(props: any): ListingTypeSelectProps {
+ static getDerivedStateFromProps(
+ props: ListingTypeSelectProps
+ ): ListingTypeSelectState {
return {
type_: props.type_,
- showLocal: props.showLocal,
- showSubscribed: props.showSubscribed,
};
}
render() {
return (
- <div class="btn-group btn-group-toggle flex-wrap mb-2">
+ <div className="btn-group btn-group-toggle flex-wrap mb-2">
{this.props.showSubscribed && (
<label
title={i18n.t("subscribed_description")}
className={`btn btn-outline-secondary
- ${this.state.type_ == ListingType.Subscribed && "active"}
- ${
- UserService.Instance.myUserInfo == undefined
- ? "disabled"
- : "pointer"
- }
+ ${this.state.type_ == "Subscribed" && "active"}
+ ${!UserService.Instance.myUserInfo ? "disabled" : "pointer"}
`}
>
<input
id={`${this.id}-subscribed`}
type="radio"
- value={ListingType.Subscribed}
- checked={this.state.type_ == ListingType.Subscribed}
+ value={"Subscribed"}
+ checked={this.state.type_ == "Subscribed"}
onChange={linkEvent(this, this.handleTypeChange)}
- disabled={UserService.Instance.myUserInfo == undefined}
+ disabled={!UserService.Instance.myUserInfo}
/>
{i18n.t("subscribed")}
</label>
<label
title={i18n.t("local_description")}
className={`pointer btn btn-outline-secondary ${
- this.state.type_ == ListingType.Local && "active"
+ this.state.type_ == "Local" && "active"
}`}
>
<input
id={`${this.id}-local`}
type="radio"
- value={ListingType.Local}
- checked={this.state.type_ == ListingType.Local}
+ value={"Local"}
+ checked={this.state.type_ == "Local"}
onChange={linkEvent(this, this.handleTypeChange)}
/>
{i18n.t("local")}
<label
title={i18n.t("all_description")}
className={`pointer btn btn-outline-secondary ${
- (this.state.type_ == ListingType.All && "active") ||
- (!this.props.showLocal &&
- this.state.type_ == ListingType.Local &&
- "active")
+ (this.state.type_ == "All" && "active") ||
+ (!this.props.showLocal && this.state.type_ == "Local" && "active")
}`}
>
<input
id={`${this.id}-all`}
type="radio"
- value={ListingType.All}
- checked={this.state.type_ == ListingType.All}
+ value={"All"}
+ checked={this.state.type_ == "All"}
onChange={linkEvent(this, this.handleTypeChange)}
/>
{i18n.t("all")}