Skip to content

Commit

Permalink
Allow specification filters with type number
Browse files Browse the repository at this point in the history
  • Loading branch information
thalytafabrine committed May 29, 2020
1 parent 1cf676a commit f20d1eb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 25 deletions.
69 changes: 44 additions & 25 deletions node/commons/compatibility-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,32 +137,51 @@ export const biggyAttributesToVtexFilters = (attributes: any) =>

return {
name: attribute.label,
type: isNumber ? 'PRICERANGE' : attribute.type.toUpperCase(),
values: isNumber
? [
{
quantity: attribute.values.reduce(
(acum: number, value: any) => acum + value.count,
0
),
name: unescape(attribute.label),
key: attribute.key,
value: attribute.key,
range: {
from: attribute.minValue,
to: attribute.maxValue,
type: isNumber
? attribute.key === 'price'
? 'PRICERANGE'
: 'NUMBER'
: attribute.type.toUpperCase(),
values:
isNumber && attribute.key === 'price'
? [
{
quantity: attribute.values.reduce(
(acum: number, value: any) => acum + value.count,
0
),
name: unescape(attribute.label),
key: attribute.key,
value: attribute.key,
range: {
from: attribute.minValue,
to: attribute.maxValue,
},
},
},
]
: attribute.values.map((value: any) => {
return {
quantity: value.count,
name: unescape(value.label),
key: attribute.key,
value: value.key,
selected: value.active,
}
}),
]
: isNumber
? attribute.values.map((value: any) => {
return {
quantity: value.count,
name: unescape(`${value.from} - ${value.to}`),
key: attribute.key,
value: `${value.from}:${value.to}`,
selected: value.active,
range: {
from: value.from,
to: value.to,
},
}
})
: attribute.values.map((value: any) => {
return {
quantity: value.count,
name: unescape(value.label),
key: attribute.key,
value: value.key,
selected: value.active,
}
}),
}
})

Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


0 comments on commit f20d1eb

Please sign in to comment.