diff --git a/CHANGELOG.md b/CHANGELOG.md index 044ece25..d7e5f25b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added + +- Passes advertisement options on products suggestion query. + ## [2.17.0] - 2024-05-06 ### Added diff --git a/react/components/Autocomplete/components/TileList/TileList.tsx b/react/components/Autocomplete/components/TileList/TileList.tsx index 8035589b..983504ba 100644 --- a/react/components/Autocomplete/components/TileList/TileList.tsx +++ b/react/components/Autocomplete/components/TileList/TileList.tsx @@ -22,10 +22,13 @@ interface TileListProps { onSeeAllClick: (term: string) => void HorizontalProductSummary?: React.ComponentType<{ product: Product + placement: string actionOnClick: () => void }> } +const AUTOCOMPLETE_PLACEMENT = 'autocomplete' + const TileList: FC = ({ term, title, @@ -72,6 +75,7 @@ const TileList: FC = ({ HorizontalProductSummary ? ( { onProductClick(productSummary.productId, index, term) }} @@ -88,6 +92,7 @@ const TileList: FC = ({ { onProductClick(productSummary.productId, index, term) }} diff --git a/react/components/Autocomplete/index.tsx b/react/components/Autocomplete/index.tsx index 8318fddb..e903f420 100644 --- a/react/components/Autocomplete/index.tsx +++ b/react/components/Autocomplete/index.tsx @@ -75,6 +75,7 @@ interface AutoCompleteProps { push: (data: any) => void HorizontalProductSummary?: React.ComponentType<{ product: Product + placement: string actionOnClick: () => void }> customPage?: string @@ -309,6 +310,12 @@ class AutoComplete extends React.Component< const session = await getSession(this.props.runtime.rootPath) const shippingOptions = session?.map((item: Record) => item.value) ?? [] + const advertisementOptions: AdvertisementOptions = { + showSponsored: true, + sponsoredCount: 2, + repeatSponsoredProducts: false, + advertisementPlacement: 'autocomplete', + } const result = await this.client.suggestionProducts( term, @@ -319,7 +326,8 @@ class AutoComplete extends React.Component< hideUnavailableItems, orderBy, this.props.maxSuggestedProducts || MAX_SUGGESTED_PRODUCTS_DEFAULT, - shippingOptions + shippingOptions, + advertisementOptions ) if (!queryFromHover) { diff --git a/react/typings/global.d.ts b/react/typings/global.d.ts index 856cac02..d0ac0383 100644 --- a/react/typings/global.d.ts +++ b/react/typings/global.d.ts @@ -100,6 +100,13 @@ declare global { TotalValuePlusInterestRate: number Value: number } + + interface AdvertisementOptions { + showSponsored?: boolean + sponsoredCount?: number + repeatSponsoredProducts?: boolean + advertisementPlacement?: string + } } export {} diff --git a/react/utils/biggy-client.ts b/react/utils/biggy-client.ts index cf8d4ae1..3d95d6cd 100644 --- a/react/utils/biggy-client.ts +++ b/react/utils/biggy-client.ts @@ -42,12 +42,14 @@ export default class BiggyClient { hideUnavailableItems = false, orderBy?: string, count?: number, - shippingOptions?: string[] + shippingOptions?: string[], + advertisementOptions?: AdvertisementOptions ): Promise> { return this.client.query({ query: suggestionProducts, variables: { simulationBehavior, + advertisementOptions, hideUnavailableItems, orderBy, fullText: term,