mirror of
https://github.com/vercel/commerce.git
synced 2025-05-19 07:56:59 +00:00
add searchQuery
Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
parent
6f0dfb78f3
commit
76bb0c7e5d
@ -7,15 +7,15 @@ export const getSearchVariables = ({
|
|||||||
categoryId,
|
categoryId,
|
||||||
sort,
|
sort,
|
||||||
}: SearchProductsInput) => {
|
}: SearchProductsInput) => {
|
||||||
let query = ''
|
let searchQuery = ''
|
||||||
let tagIdsParam = {}
|
let tagIdsParam = {}
|
||||||
|
|
||||||
if (search) {
|
if (search) {
|
||||||
query += `product_type:${search} OR title:${search} OR tag:${search}`
|
searchQuery += search
|
||||||
}
|
}
|
||||||
|
|
||||||
if (brandId) {
|
if (brandId) {
|
||||||
query += `${search ? ' AND ' : ''}vendor:${brandId}`
|
searchQuery += `${search ? ' ' : ''}${brandId}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (categoryId) {
|
if (categoryId) {
|
||||||
@ -25,8 +25,7 @@ export const getSearchVariables = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// categoryId,
|
searchQuery,
|
||||||
// query,
|
|
||||||
...tagIdsParam,
|
...tagIdsParam,
|
||||||
...getSortVariables(sort, !!categoryId),
|
...getSortVariables(sort, !!categoryId),
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ catalogItems(
|
|||||||
sortBy: $sortBy
|
sortBy: $sortBy
|
||||||
tagIds: $tagIds
|
tagIds: $tagIds
|
||||||
shopIds: $shopIds
|
shopIds: $shopIds
|
||||||
|
searchQuery: $searchQuery
|
||||||
) {
|
) {
|
||||||
${catalogItemsConnection}
|
${catalogItemsConnection}
|
||||||
}
|
}
|
||||||
@ -60,6 +61,7 @@ const catalogItemsQuery = /* GraphQL */ `
|
|||||||
$sortBy: CatalogItemSortByField = updatedAt
|
$sortBy: CatalogItemSortByField = updatedAt
|
||||||
$tagIds: [ID]
|
$tagIds: [ID]
|
||||||
$shopIds: [ID]!
|
$shopIds: [ID]!
|
||||||
|
$searchQuery: String
|
||||||
) {
|
) {
|
||||||
${catalogItemsFragment}
|
${catalogItemsFragment}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user