Skip to content

Commit

Permalink
feat(search): handle display tagging from search response
Browse files Browse the repository at this point in the history
  • Loading branch information
CachedaCodes committed Jan 3, 2024
1 parent 8cce44c commit 86a46f4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export const searchResponseSchema = createMutableSchema<PlatformSearchResponse,
$path: 'catalog.partials',
$subSchema: partialResultsSchema
},
queryTagging: ({ catalog }) => getTaggingInfoFromUrl(catalog?.tagging?.query)
queryTagging: ({ catalog }) => getTaggingInfoFromUrl(catalog?.tagging?.query),
displayTagging: ({ catalog }) => getTaggingInfoFromUrl(catalog?.tagging?.display)
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface PlatformSearchResponse {
partials: PlatformPartialResult[];
tagging: {
query: string;
display: string;
};
};
direct: {
Expand Down
7 changes: 7 additions & 0 deletions packages/x-components/src/x-modules/search/store/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export const searchXStoreModule: SearchXStoreModule = {
setQueryTagging(state, queryTagging) {
state.queryTagging = queryTagging;
},
setDisplayTagging(state, displayTagging) {
state.displayTagging = displayTagging;
},
updateResult(state, result) {
const stateResult = state.results.find(stateResult => result.id === stateResult.id);
if (stateResult) {
Expand Down Expand Up @@ -153,6 +156,10 @@ export function resettableState() {
queryTagging: {
url: '',
params: {}
},
displayTagging: {
url: '',
params: {}
}
};
}
8 changes: 8 additions & 0 deletions packages/x-components/src/x-modules/search/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export interface SearchState extends StatusState, QueryState {
promoteds: Promoted[];
/** The query tagging used to track the search events. */
queryTagging: TaggingRequest;
/** The display tagging used to track the search events. */
displayTagging: TaggingRequest;
/** The redirections associated to the `query`. */
redirections: Redirection[];
/** The list of the related tags, related to the `query` property of the state. */
Expand Down Expand Up @@ -172,6 +174,12 @@ export interface SearchMutations
* @param queryTagging - The new query tagging object to save to the state.
*/
setQueryTagging(queryTagging: TaggingRequest): void;
/**
* Sets the display tagging of the module.
*
* @param displayTagging - The new display tagging object to save to the state.
*/
setDisplayTagging(DisplayTagging: TaggingRequest): void;
/**
* Sets the redirection of the module.
*
Expand Down
1 change: 1 addition & 0 deletions packages/x-types/src/response/search-response.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface SearchResponse {
partialResults?: PartialResult[];
promoteds?: Promoted[];
queryTagging?: TaggingRequest;
displayTagging?: TaggingRequest;
redirections?: Redirection[];
results: Result[];
spellcheck?: string;
Expand Down

0 comments on commit 86a46f4

Please sign in to comment.