-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FW-1848] SEO categories with ignored filters (#2891)
- Loading branch information
Showing
29 changed files
with
666 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
project-base/storefront/components/Blocks/SortingBar/SortingBar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
import { ProductOrderingModeEnumApi } from 'graphql/generated'; | ||
|
||
export const DEFAULT_PAGE_SIZE = 9; | ||
export const DEFAULT_SORT = ProductOrderingModeEnumApi.PriorityApi as const; | ||
/** | ||
* For those that are set to "true", we optimistically navigate out from a SEO category when a value of that type is changed | ||
* This setting needs to mirror the API functionality in the following way | ||
* - if a filter type "blocks" SEO category on API, it needs to be set as SEO sensitive | ||
* - if a filter type "allows" SEO category on API, it needs to be set as SEO insensitive | ||
* | ||
* @example | ||
* if the current URL is a SEO category "/my-seo-category" and sorting (which is SEO sensitive) | ||
* is changed, we navigate right away to "/my-normal-category?sort=NEW_SORTING" | ||
* | ||
* if the current URL is a SEO category "/my-seo-category" and availability (which is SEO insensitive) | ||
* is changed, we stay in the SEO category and navigate to "/my-seo-category?onlyInStock=true" | ||
*/ | ||
export const SEO_SENSITIVE_FILTERS = { | ||
SORT: true, | ||
AVAILABILITY: false, | ||
PRICE: false, | ||
FLAGS: true, | ||
BRANDS: false, | ||
PARAMETERS: { | ||
CHECKBOX: true, | ||
SLIDER: false, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
export const createEmptyArray = (length: number): null[] => Array(length).fill(null); | ||
|
||
export const mergeNullableArrays = <T>(array1: T[] | undefined | null, array2: T[] | undefined | null) => { | ||
const nonNullableArray1 = array1 ? array1 : []; | ||
const nonNullableArray2 = array2 ? array2 : []; | ||
|
||
return [...nonNullableArray1, ...nonNullableArray2]; | ||
}; |
37 changes: 37 additions & 0 deletions
37
project-base/storefront/helpers/filterOptions/buildNewQueryAfterFilterChange.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { DEFAULT_SORT } from 'config/constants'; | ||
import { ProductOrderingModeEnumApi } from 'graphql/generated'; | ||
import { | ||
PAGE_QUERY_PARAMETER_NAME, | ||
LOAD_MORE_QUERY_PARAMETER_NAME, | ||
FILTER_QUERY_PARAMETER_NAME, | ||
SORT_QUERY_PARAMETER_NAME, | ||
} from 'helpers/queryParamNames'; | ||
import { UrlQueries, FilterQueries } from 'hooks/useQueryParams'; | ||
|
||
export const buildNewQueryAfterFilterChange = ( | ||
currentQuery: UrlQueries, | ||
newFilter: FilterQueries, | ||
newSort: ProductOrderingModeEnumApi | undefined, | ||
) => { | ||
const isWithFilterParams = | ||
!!newFilter && | ||
(!!newFilter.onlyInStock || | ||
!!(newFilter.minimalPrice ?? undefined) || | ||
!!(newFilter.maximalPrice ?? null) || | ||
!!newFilter.brands?.length || | ||
!!newFilter.flags?.length || | ||
!!newFilter.parameters?.length); | ||
|
||
const newQuery: UrlQueries = { | ||
...currentQuery, | ||
[PAGE_QUERY_PARAMETER_NAME]: undefined, | ||
[LOAD_MORE_QUERY_PARAMETER_NAME]: undefined, | ||
[FILTER_QUERY_PARAMETER_NAME]: isWithFilterParams ? JSON.stringify(newFilter) : undefined, | ||
} as const; | ||
|
||
if (newSort && newSort !== DEFAULT_SORT) { | ||
newQuery[SORT_QUERY_PARAMETER_NAME] = newSort; | ||
} | ||
|
||
return newQuery; | ||
}; |
18 changes: 18 additions & 0 deletions
18
project-base/storefront/helpers/filterOptions/getFilterWithoutEmpty.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { FilterOptionsUrlQueryType } from 'types/productFilter'; | ||
|
||
export const getFilterWithoutEmpty = (filter: FilterOptionsUrlQueryType | undefined | null) => { | ||
if (!filter) { | ||
return undefined; | ||
} | ||
|
||
const updatedFilter = { ...filter }; | ||
|
||
(Object.keys(updatedFilter) as Array<keyof typeof updatedFilter>).forEach((key) => { | ||
const newFilterValue = updatedFilter[key]; | ||
if (Array.isArray(newFilterValue) && newFilterValue.length === 0) { | ||
delete updatedFilter[key]; | ||
} | ||
}); | ||
|
||
return updatedFilter; | ||
}; |
Oops, something went wrong.