@faststore/api 2.2.33 → 2.2.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "2.2.33",
3
+ "version": "2.2.35",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -58,5 +58,5 @@
58
58
  "@envelop/core": "^1 || ^2",
59
59
  "graphql": "^15.6.0"
60
60
  },
61
- "gitHead": "3ef3bacdc55e2a9719398e5920a564b231a86bc5"
61
+ "gitHead": "dbb59ea5a444b7b542481b6842ab8bc230ed9a94"
62
62
  }
@@ -9,7 +9,12 @@ export type Root = {
9
9
  productSearchPromise: Promise<ProductSearchResult>
10
10
  }
11
11
 
12
- const isRootFacet = (facet: Facet) => facet.key === 'category-1'
12
+ const isRootFacet = (facet: Facet, isDepartment: boolean, isBrand: boolean) =>
13
+ isDepartment
14
+ ? facet.key === 'category-1'
15
+ : isBrand
16
+ ? facet.key === 'brand'
17
+ : false
13
18
 
14
19
  export const StoreSearchResult: Record<string, Resolver<Root>> = {
15
20
  suggestions: async (root, _, ctx) => {
@@ -89,9 +94,21 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
89
94
 
90
95
  const isCollectionPage = !searchArgs.query
91
96
 
97
+ const isDepartment = searchArgs.selectedFacets?.length
98
+ ? searchArgs.selectedFacets[0].key === 'category-1'
99
+ : false
100
+
101
+ const isBrand = searchArgs.selectedFacets?.length
102
+ ? searchArgs.selectedFacets[0].key === 'brand'
103
+ : false
104
+
92
105
  const filteredFacets = facets
93
- // Remove root facet on category pages
94
- .filter((facet) => !isCollectionPage || !isRootFacet(facet))
106
+ // Remove root facet on category and brand pages
107
+ // TODO: Hide category filters for category pages. E.g. /office/desks
108
+ .filter(
109
+ (facet) =>
110
+ !isCollectionPage || !isRootFacet(facet, isDepartment, isBrand)
111
+ )
95
112
 
96
113
  return filteredFacets
97
114
  },