-
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.
feat(commerce): add location facets actions loader (#4569)
See: #4562 [COMHUB-247] [COMHUB-247]: https://coveord.atlassian.net/browse/COMHUB-247?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
1 parent
7b9144d
commit 05cb497
Showing
3 changed files
with
58 additions
and
1 deletion.
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
54 changes: 54 additions & 0 deletions
54
...ges/headless/src/features/commerce/facets/location-facet/location-facet-actions-loader.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,54 @@ | ||
import {PayloadAction} from '@reduxjs/toolkit'; | ||
import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; | ||
import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice.js'; | ||
import { | ||
ToggleExcludeFacetValuePayload, | ||
ToggleSelectFacetValuePayload, | ||
} from '../regular-facet/regular-facet-actions.js'; | ||
import { | ||
toggleExcludeLocationFacetValue, | ||
toggleSelectLocationFacetValue, | ||
} from './location-facet-actions.js'; | ||
|
||
export type {ToggleExcludeFacetValuePayload, ToggleSelectFacetValuePayload}; | ||
|
||
/** | ||
* The location facet action creators. | ||
*/ | ||
export interface LocationFacetActionCreators { | ||
/** | ||
* Toggles the exclusion of a given location facet value. | ||
* | ||
* @param payload - The action creator payload. | ||
* @returns A dispatchable action. | ||
*/ | ||
toggleExcludeLocationFacetValue( | ||
payload: ToggleExcludeFacetValuePayload | ||
): PayloadAction<ToggleExcludeFacetValuePayload>; | ||
|
||
/** | ||
* Toggles the selection of a given location facet value. | ||
* | ||
* @param payload - The action creator payload. | ||
* @returns A dispatchable action. | ||
*/ | ||
toggleSelectLocationFacetValue( | ||
payload: ToggleSelectFacetValuePayload | ||
): PayloadAction<ToggleSelectFacetValuePayload>; | ||
} | ||
|
||
/** | ||
* Loads the commerce facet set reducer and returns the available location facet action creators. | ||
* | ||
* @param engine - The commerce engine. | ||
* @returns An object holding the location facet action creators. | ||
*/ | ||
export function loadLocationFacetActions( | ||
engine: CommerceEngine | ||
): LocationFacetActionCreators { | ||
engine.addReducers({commerceFacetSet}); | ||
return { | ||
toggleExcludeLocationFacetValue, | ||
toggleSelectLocationFacetValue, | ||
}; | ||
} |