Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: pass placement to product summary and query #668

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- Pass `placement` to product search query and product-summary.

## [3.132.2] - 2024-05-20

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions react/components/GalleryLayoutItem.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { ComponentType } from 'react'
import React, { useMemo, useCallback, memo } from 'react'
import ProductSummary from 'vtex.product-summary/ProductSummaryCustom'
import React, { memo, useCallback, useMemo } from 'react'
import { usePixel } from 'vtex.pixel-manager'
import ProductSummary from 'vtex.product-summary/ProductSummaryCustom'
import { useSearchPage } from 'vtex.search-page-context/SearchPageContext'

import type { Product } from '../Gallery'
import type { PreferredSKU } from '../GalleryLayout'

interface GalleryLayoutItemProps {
GalleryItemComponent: ComponentType<any>

Check warning on line 11 in react/components/GalleryLayoutItem.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
item: Product
displayMode: string
summary: unknown
Expand Down
24 changes: 15 additions & 9 deletions react/components/SearchQuery.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { useMemo, useRef, useCallback, useEffect, useState } from 'react'
import { canUseDOM } from 'exenv'
import { equals } from 'ramda'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useQuery } from 'react-apollo'
import { useRuntime } from 'vtex.render-runtime'
import facetsQuery from 'vtex.store-resources/QueryFacetsV2'
import productSearchQuery from 'vtex.store-resources/QueryProductSearchV3'
import searchMetadataQuery from 'vtex.store-resources/QuerySearchMetadataV2'
import facetsQuery from 'vtex.store-resources/QueryFacetsV2'
import { equals } from 'ramda'
import { canUseDOM } from 'exenv'

import { FACETS_RENDER_THRESHOLD } from '../constants/filterConstants'
import useRedirect from '../hooks/useRedirect'
import useSession from '../hooks/useSession'
import {
buildQueryArgsFromSelectedFacets,
buildSelectedFacetsAndFullText,
detachFiltersByType,
buildQueryArgsFromSelectedFacets,
} from '../utils/compatibilityLayer'
import { FACETS_RENDER_THRESHOLD } from '../constants/filterConstants'
import useRedirect from '../hooks/useRedirect'
import useSession from '../hooks/useSession'

function getCookie(cname) {
if (!canUseDOM) {
Expand Down Expand Up @@ -124,7 +124,7 @@

const isCurrentDifferent = (ref, currentVal) => ref.current !== currentVal

const useShouldResetPage = (query, map, orderBy, priceRange) => {

Check warning on line 127 in react/components/SearchQuery.js

View workflow job for this annotation

GitHub Actions / Lint

Arrow function has too many parameters (4). Maximum allowed is 3
const queryRef = useRef(query)
const mapRef = useRef(map)
const orderByRef = useRef(orderBy)
Expand Down Expand Up @@ -153,7 +153,7 @@
operator,
searchState,
fullText
) => {

Check warning on line 156 in react/components/SearchQuery.js

View workflow job for this annotation

GitHub Actions / Lint

Arrow function has too many parameters (4). Maximum allowed is 3
const fullTextRef = useRef(fullText)
const shouldReset = isCurrentDifferent(fullTextRef, fullText)

Expand All @@ -170,15 +170,21 @@

const useQueries = (variables, facetsArgs, price) => {
const { getSettings, query: runtimeQuery } = useRuntime()

const settings = getSettings('vtex.store')

const isLazyFacetsFetchEnabled = settings?.enableFiltersFetchOptimization

const productSearchResult = useQuery(productSearchQuery, {
variables: {
...variables,
showSponsored: true,
variant: getCookie('sp-variant'),
advertisementOptions: {
showSponsored: true,
sponsoredCount: 3,
advertisementPlacement: 'top_search',
repeatSponsoredProducts: true,
},
},
})

Expand Down
Loading