mirror of
https://github.com/vercel/commerce.git
synced 2025-05-20 16:36:59 +00:00
31 lines
584 B
TypeScript
31 lines
584 B
TypeScript
export const getSortVariables = (sort?: string, isCategory: boolean = false) => {
|
|
let output = {}
|
|
switch (sort) {
|
|
case 'price-asc':
|
|
output = {
|
|
field: 'PRICE',
|
|
direction: 'ASC',
|
|
}
|
|
break
|
|
case 'price-desc':
|
|
output = {
|
|
field: 'PRICE',
|
|
direction: 'DESC',
|
|
}
|
|
break
|
|
case 'trending-desc':
|
|
output = {
|
|
field: 'RANK',
|
|
direction: 'DESC',
|
|
}
|
|
break
|
|
case 'latest-desc':
|
|
output = {
|
|
field: 'DATE',
|
|
direction: 'DESC',
|
|
}
|
|
break
|
|
}
|
|
return output
|
|
}
|