mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 05:31:22 +00:00
Update get-search-variables.ts
This commit is contained in:
parent
23b1e6e70c
commit
7f38b25c1f
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user