Skip to content

Commit

Permalink
Merge pull request scandipwa#5225 from AleksandrsKondratjevs/ts-issue…
Browse files Browse the repository at this point in the history
…-price-filter

TypeScript - Fix price filter showing not correct
  • Loading branch information
AleksandrsKondratjevs authored Oct 5, 2022
2 parents d6ec391 + b928edf commit 5b1cfe9
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,14 @@ export class ResetAttributesContainer extends PureComponent<ResetAttributesConta
};
}

getFilterOptionsForPrice(values: string[], options: AggregationOption[]): FilterOption[] {
getFilterOptionsForPrice(values: string[]): FilterOption[] {
const { currency_code } = this.props;
const [value_string] = values;
// no multiselect for price, always 1 selected value
const [fromValue, toValue] = values[ 0 ].split('_');
const [fromValue, toValue] = value_string.split('_');
const label = getPriceFilterLabel(fromValue, toValue, currency_code as GQLCurrencyEnum);

return options
.filter(({ value_string }) => value_string.startsWith(fromValue))
.map((option) => {
const { currency_code } = this.props;
const { label: initialLabel, value_string } = option;

const [from, to] = initialLabel.split('~');
const rangeEnd = toValue === '*' ? toValue : to;

const label = getPriceFilterLabel(from, rangeEnd, currency_code as GQLCurrencyEnum);

return { value_string, label };
});
return [{ value_string, label }];
}

getFilterOptionsDefault(values: string[], options: AggregationOption[]): FilterOption[] {
Expand Down

0 comments on commit 5b1cfe9

Please sign in to comment.