mirror of
https://github.com/oceanprotocol/market.git
synced 2024-06-30 22:01:44 +02:00
eliminate no price elements on both price filters set
This commit is contained in:
parent
2283148e6d
commit
6eaf2efd95
|
@ -57,8 +57,8 @@ export default function FilterPrice({
|
||||||
|
|
||||||
async function handleSelectedFilter(isSelected: boolean, value: string) {
|
async function handleSelectedFilter(isSelected: boolean, value: string) {
|
||||||
if (
|
if (
|
||||||
FilterByPriceOptions.Dynamic.includes(value) ||
|
value === FilterByPriceOptions.Fixed ||
|
||||||
FilterByPriceOptions.Fixed.includes(value)
|
value === FilterByPriceOptions.Dynamic
|
||||||
) {
|
) {
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
if (priceSelections.length > 1) {
|
if (priceSelections.length > 1) {
|
||||||
|
@ -75,7 +75,7 @@ export default function FilterPrice({
|
||||||
} else {
|
} else {
|
||||||
if (priceSelections.length) {
|
if (priceSelections.length) {
|
||||||
// one already selected -> both selected
|
// one already selected -> both selected
|
||||||
await applyPriceFilter(undefined)
|
await applyPriceFilter(FilterByPriceOptions.All)
|
||||||
setPriceSelections(priceFilterItems.map((p) => p.value))
|
setPriceSelections(priceFilterItems.map((p) => p.value))
|
||||||
} else {
|
} else {
|
||||||
// none selected -> select
|
// none selected -> select
|
||||||
|
|
|
@ -28,7 +28,8 @@ type SortValueOptions = typeof SortValueOptions[keyof typeof SortValueOptions]
|
||||||
|
|
||||||
export const FilterByPriceOptions = {
|
export const FilterByPriceOptions = {
|
||||||
Fixed: 'exchange',
|
Fixed: 'exchange',
|
||||||
Dynamic: 'pool'
|
Dynamic: 'pool',
|
||||||
|
All: 'all'
|
||||||
} as const
|
} as const
|
||||||
type FilterByPriceOptions = typeof FilterByPriceOptions[keyof typeof FilterByPriceOptions]
|
type FilterByPriceOptions = typeof FilterByPriceOptions[keyof typeof FilterByPriceOptions]
|
||||||
|
|
||||||
|
@ -39,11 +40,20 @@ export const FilterByTypeOptions = {
|
||||||
type FilterByTypeOptions = typeof FilterByTypeOptions[keyof typeof FilterByTypeOptions]
|
type FilterByTypeOptions = typeof FilterByTypeOptions[keyof typeof FilterByTypeOptions]
|
||||||
|
|
||||||
function addPriceFilterToQuerry(sortTerm: string, priceFilter: string): string {
|
function addPriceFilterToQuerry(sortTerm: string, priceFilter: string): string {
|
||||||
sortTerm = priceFilter
|
if (priceFilter === FilterByPriceOptions.All) {
|
||||||
? sortTerm === ''
|
sortTerm = priceFilter
|
||||||
? `price.type:${priceFilter}`
|
? sortTerm === ''
|
||||||
: `${sortTerm} AND price.type:${priceFilter}`
|
? `(price.type:${FilterByPriceOptions.Fixed} OR price.type:${FilterByPriceOptions.Dynamic})`
|
||||||
: sortTerm
|
: `${sortTerm} AND (price.type:${FilterByPriceOptions.Dynamic} OR price.type:${FilterByPriceOptions.Fixed})`
|
||||||
|
: sortTerm
|
||||||
|
} else {
|
||||||
|
sortTerm = priceFilter
|
||||||
|
? sortTerm === ''
|
||||||
|
? `price.type:${priceFilter}`
|
||||||
|
: `${sortTerm} AND price.type:${priceFilter}`
|
||||||
|
: sortTerm
|
||||||
|
}
|
||||||
|
console.log('SORT TERM: ', sortTerm)
|
||||||
return sortTerm
|
return sortTerm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user