-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(commerce): fix commerce search facet selectors and facet order (#…
…3496) * set facet order on commerce search query response * use solution type-specific selector * test selector usage * test selectors in specific controllers
- Loading branch information
1 parent
61dc3cd
commit 0166932
Showing
22 changed files
with
277 additions
and
116 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
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
35 changes: 35 additions & 0 deletions
35
...src/controllers/commerce/product-listing/facets/headless-product-listing-facet-options.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,35 @@ | ||
import {isFacetResponse} from '../../../../features/commerce/facets/facet-set/facet-set-selector'; | ||
import {fetchProductListing} from '../../../../features/commerce/product-listing/product-listing-actions'; | ||
import { | ||
CommerceFacetSetSection, | ||
ProductListingV2Section, | ||
} from '../../../../state/state-sections'; | ||
import {CoreCommerceFacetOptions} from '../../facets/core/headless-core-commerce-facet'; | ||
|
||
const facetResponseSelector = ( | ||
state: ProductListingV2Section & CommerceFacetSetSection, | ||
facetId: string | ||
) => { | ||
const response = state.productListing.facets.find( | ||
(response) => response.facetId === facetId | ||
); | ||
if (isFacetResponse(state, response)) { | ||
return response; | ||
} | ||
|
||
return undefined; | ||
}; | ||
|
||
const isFacetLoadingResponseSelector = (state: ProductListingV2Section) => | ||
state.productListing.isLoading; | ||
|
||
export const commonOptions: Pick< | ||
CoreCommerceFacetOptions, | ||
| 'fetchResultsActionCreator' | ||
| 'facetResponseSelector' | ||
| 'isFacetLoadingResponseSelector' | ||
> = { | ||
fetchResultsActionCreator: fetchProductListing, | ||
facetResponseSelector, | ||
isFacetLoadingResponseSelector, | ||
}; |
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
Oops, something went wrong.