Добавлено условное отображение компонента InfoSearch и мобильных фильтров только при наличии результатов поиска. Обновлена логика отображения информации о найденных предложениях в компоненте InfoSearch.

This commit is contained in:
Bivekich
2025-07-11 08:31:05 +03:00
parent 26e4a95ae4
commit b11142ad0f
2 changed files with 78 additions and 60 deletions

View File

@ -32,7 +32,11 @@ const InfoSearch: React.FC<InfoSearchProps> = ({
<div className="w-layout-hflex flex-block-10"> <div className="w-layout-hflex flex-block-10">
<h1 className="heading">{name}</h1> <h1 className="heading">{name}</h1>
<div className="text-block-4"> <div className="text-block-4">
Найдено {offersCount} предложений от {minPrice} {offersCount > 0 ? (
<>Найдено {offersCount} предложений от {minPrice}</>
) : (
<>Ничего не найдено</>
)}
</div> </div>
</div> </div>
{/* <div className="w-layout-hflex flex-block-11"> {/* <div className="w-layout-hflex flex-block-11">

View File

@ -526,44 +526,52 @@ export default function SearchResult() {
return ( return (
<> <>
<MetaTags {...metaData} /> <MetaTags {...metaData} />
<InfoSearch {/* Показываем InfoSearch только если есть результаты */}
brand={result ? result.brand : brandQuery} {initialOffersExist && (
articleNumber={result ? result.articleNumber : searchQuery} <InfoSearch
name={result ? result.name : "деталь"} brand={result ? result.brand : brandQuery}
offersCount={result ? result.totalOffers : 0} articleNumber={result ? result.articleNumber : searchQuery}
minPrice={minPrice} name={result ? result.name : "деталь"}
/> offersCount={result ? result.totalOffers : 0}
<section className="main mobile-only"> minPrice={minPrice}
<div className="w-layout-blockcontainer container w-container"> />
<div className="w-layout-hflex flex-block-84"> )}
{/* <CatalogSortDropdown active={sortActive} onChange={setSortActive} /> */} {/* Показываем мобильные фильтры только если есть результаты */}
<div className="w-layout-hflex flex-block-85" onClick={() => setShowFiltersMobile((v) => !v)}> {initialOffersExist && (
<span className="code-embed-9 w-embed"> <>
<svg width="currentwidth" height="currentheight" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <section className="main mobile-only">
<path d="M21 4H14" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/> <div className="w-layout-blockcontainer container w-container">
<path d="M10 4H3" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/> <div className="w-layout-hflex flex-block-84">
<path d="M21 12H12" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/> {/* <CatalogSortDropdown active={sortActive} onChange={setSortActive} /> */}
<path d="M8 12H3" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/> <div className="w-layout-hflex flex-block-85" onClick={() => setShowFiltersMobile((v) => !v)}>
<path d="M21 20H16" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/> <span className="code-embed-9 w-embed">
<path d="M12 20H3" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/> <svg width="currentwidth" height="currentheight" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 2V6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/> <path d="M21 4H14" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M8 10V14" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/> <path d="M10 4H3" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M16 18V22" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/> <path d="M21 12H12" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg> <path d="M8 12H3" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</span> <path d="M21 20H16" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<div>Фильтры</div> <path d="M12 20H3" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</div> <path d="M14 2V6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</div> <path d="M8 10V14" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</div> <path d="M16 18V22" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</section> </svg>
{/* Мобильная панель фильтров */} </span>
<FiltersPanelMobile <div>Фильтры</div>
filters={searchResultFilters} </div>
open={showFiltersMobile} </div>
onClose={() => setShowFiltersMobile(false)} </div>
searchQuery={filterSearchTerm} </section>
onSearchChange={(value) => handleFilterChange('search', value)} {/* Мобильная панель фильтров */}
/> <FiltersPanelMobile
filters={searchResultFilters}
open={showFiltersMobile}
onClose={() => setShowFiltersMobile(false)}
searchQuery={filterSearchTerm}
onSearchChange={(value) => handleFilterChange('search', value)}
/>
</>
)}
{/* Лучшие предложения */} {/* Лучшие предложения */}
{bestOffersData.length > 0 && ( {bestOffersData.length > 0 && (
<section className="section-6"> <section className="section-6">
@ -621,24 +629,26 @@ export default function SearchResult() {
</div> </div>
</section> </section>
)} )}
<section className="main"> {/* Показываем основную секцию с фильтрами только если есть результаты */}
<div className="w-layout-blockcontainer container w-container"> {initialOffersExist && (
<div className="w-layout-hflex flex-block-13-copy"> <section className="main">
{/* Фильтры для десктопа */} <div className="w-layout-blockcontainer container w-container">
<div style={{ width: '300px', marginRight: '20px', marginBottom: '80px' }}> <div className="w-layout-hflex flex-block-13-copy">
<Filters {/* Фильтры для десктопа */}
filters={searchResultFilters} <div style={{ width: '300px', marginRight: '20px', marginBottom: '80px' }}>
onFilterChange={handleFilterChange} <Filters
filterValues={{ filters={searchResultFilters}
'Производитель': selectedBrands, onFilterChange={handleFilterChange}
'Цена (₽)': priceRange, filterValues={{
'Срок доставки (дни)': deliveryRange, 'Производитель': selectedBrands,
'Количество (шт.)': quantityRange 'Цена (₽)': priceRange,
}} 'Срок доставки (дни)': deliveryRange,
searchQuery={filterSearchTerm} 'Количество (шт.)': quantityRange
onSearchChange={(value) => handleFilterChange('search', value)} }}
/> searchQuery={filterSearchTerm}
</div> onSearchChange={(value) => handleFilterChange('search', value)}
/>
</div>
{/* Основной товар */} {/* Основной товар */}
<div className="w-layout-vflex flex-block-14-copy"> <div className="w-layout-vflex flex-block-14-copy">
@ -810,9 +820,13 @@ export default function SearchResult() {
</div> </div>
</div> </div>
</section> </section>
<section className="section-3"> )}
<CatalogSubscribe /> {/* Показываем CatalogSubscribe только если есть результаты */}
</section> {initialOffersExist && (
<section className="section-3">
<CatalogSubscribe />
</section>
)}
<Footer /> <Footer />
<MobileMenuBottomSection /> <MobileMenuBottomSection />
</> </>