commerce/providers/saleor/utils/get-search-variables.ts
Loui Nissen-Petersen 03dcf96fb1 rename folder
2021-07-16 16:58:03 +02:00

19 lines
467 B
TypeScript

import { getSortVariables } from './get-sort-variables'
import type { SearchProductsInput } from '../product/use-search'
export const getSearchVariables = ({ brandId, search, categoryId, sort }: SearchProductsInput) => {
const sortBy = {
field: 'NAME',
direction: 'ASC',
...getSortVariables(sort, !!categoryId),
channel: 'default-channel',
}
return {
categoryId,
filter: { search },
sortBy,
}
}
export default getSearchVariables