commerce/framework/reactioncommerce/utils/get-sort-variables.ts
Loan Laux 09249045eb
Add Reaction Commerce provider
Signed-off-by: Loan Laux <loan@outgrow.io>
2021-03-30 20:07:48 +04:00

33 lines
635 B
TypeScript

const getSortVariables = (sort?: string, isCategory = false) => {
let output = {}
switch (sort) {
case 'price-asc':
output = {
sortKey: 'PRICE',
reverse: false,
}
break
case 'price-desc':
output = {
sortKey: 'PRICE',
reverse: true,
}
break
case 'trending-desc':
output = {
sortKey: 'BEST_SELLING',
reverse: false,
}
break
case 'latest-desc':
output = {
sortKey: isCategory ? 'CREATED' : 'CREATED_AT',
reverse: true,
}
break
}
return output
}
export default getSortVariables