Update get-search-variables.ts

This commit is contained in:
l198881 2021-05-28 09:36:21 -03:00 committed by GitHub
parent 23b1e6e70c
commit 7f38b25c1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,24 +1,25 @@
import { SearchProductsInput } from '../product/use-search' { SearchProductsInput } '../product/use-search'
import getSortVariables from './get-sort-variables'
export const getSearchVariables = ({ getSortVariables './get-sort-variables',
getSearchVariables ({
brandId, brandId,
search, search,
categoryId, categoryId
sort, sort,
locale, locale,
}: SearchProductsInput) => { }: SearchProductsInput) {
let query = '' query ''
if (search) { (search) {
query += `product_type:${search} OR title:${search} OR tag:${search}` query `product_type:${search} OR title:${search} OR tag:${search}`
} }
if (brandId) { (brandId) {
query += `${search ? ' AND ' : ''}vendor:${brandId}` query `${search ? ' AND ' : ''}vendor:${brandId}`
} }
return { {
categoryId, categoryId,
query, query,
locale, locale,
@ -26,4 +27,4 @@ export const getSearchVariables = ({
} }
} }
export default getSearchVariables getSearchVariables