5 Commits
1234 ... 1207

Author SHA1 Message Date
cebe3a10ac fix1207 2025-07-12 18:21:09 +03:00
791152a862 Исправление UI страницы результатов поиска при отсутствии результатов
- Скрыт компонент InfoSearch когда нет результатов поиска
- Изменен текст с 'Найдено 0 предложений от -' на 'Ничего не найдено'
- Убраны фильтры и форма поиска внизу страницы при отсутствии результатов
- Разрешен конфликт в ProfileHistoryItem.tsx
2025-07-11 08:32:18 +03:00
b11142ad0f Добавлено условное отображение компонента InfoSearch и мобильных фильтров только при наличии результатов поиска. Обновлена логика отображения информации о найденных предложениях в компоненте InfoSearch. 2025-07-11 08:31:05 +03:00
508ad8cff3 Merge pull request '1234' (#23) from 1234 into main
Reviewed-on: #23
2025-07-11 03:02:39 +03:00
26e4a95ae4 Удалены уведомления об удалении товара из избранного в компонентах BestPriceItem и TopSalesItem. Добавлен новый запрос GraphQL для получения новых поступлений, реализована логика загрузки и отображения данных в компоненте NewArrivalsSection. Обновлены компоненты ProfileHistoryItem и ProfileHistoryMain для поддержки новых пропсов и пагинации. Улучшено взаимодействие с пользователем через обработку кликов и отображение состояния загрузки. 2025-07-11 02:42:46 +03:00
19 changed files with 721 additions and 209 deletions

BIN
public/images/resource2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -109,7 +109,6 @@ const BestPriceItem: React.FC<BestPriceItemProps> = ({
if (favoriteItem) {
removeFromFavorites(favoriteItem.id);
toast.success('Товар удален из избранного');
}
} else {
// Добавляем в избранное

View File

@ -227,41 +227,63 @@ const BottomHead = ({ menuOpen, onClose }: { menuOpen: boolean; onClose: () => v
<span>{mobileCategory.label}</span>
</div>
<div className="mobile-subcategories">
{mobileCategory.links.map((link: string, linkIndex: number) => (
{mobileCategory.links.length === 1 ? (
<div
className="mobile-subcategory"
key={link}
onClick={() => {
// Ищем соответствующую подгруппу по названию
let subcategoryId = `${mobileCategory.catalogId}_${linkIndex}`;
let subcategoryId = `${mobileCategory.catalogId}_0`;
if (mobileCategory.groups) {
for (const group of mobileCategory.groups) {
// Проверяем в подгруппах
if (group.subgroups && group.subgroups.length > 0) {
const foundSubgroup = group.subgroups.find((subgroup: any) => subgroup.name === link);
const foundSubgroup = group.subgroups.find((subgroup: any) => subgroup.name === mobileCategory.links[0]);
if (foundSubgroup) {
subcategoryId = foundSubgroup.id;
break;
}
}
// Если нет подгрупп, проверяем саму группу
else if (group.name === link) {
} else if (group.name === mobileCategory.links[0]) {
subcategoryId = group.id;
break;
}
}
}
// Получаем catalogId из данных
const activeCatalog = catalogsData?.partsIndexCategoriesWithGroups?.[tabData.findIndex(tab => tab === mobileCategory)];
const catalogId = activeCatalog?.id || 'fallback';
handleCategoryClick(catalogId, link, subcategoryId);
handleCategoryClick(catalogId, mobileCategory.links[0], subcategoryId);
}}
style={{ cursor: "pointer" }}
>
{link}
Показать все
</div>
))}
) : (
mobileCategory.links.map((link: string, linkIndex: number) => (
<div
className="mobile-subcategory"
key={link}
onClick={() => {
let subcategoryId = `${mobileCategory.catalogId}_${linkIndex}`;
if (mobileCategory.groups) {
for (const group of mobileCategory.groups) {
if (group.subgroups && group.subgroups.length > 0) {
const foundSubgroup = group.subgroups.find((subgroup: any) => subgroup.name === link);
if (foundSubgroup) {
subcategoryId = foundSubgroup.id;
break;
}
} else if (group.name === link) {
subcategoryId = group.id;
break;
}
}
}
const activeCatalog = catalogsData?.partsIndexCategoriesWithGroups?.[tabData.findIndex(tab => tab === mobileCategory)];
const catalogId = activeCatalog?.id || 'fallback';
handleCategoryClick(catalogId, link, subcategoryId);
}}
>
{link}
</div>
))
)}
</div>
</div>
) : (
@ -443,44 +465,66 @@ const BottomHead = ({ menuOpen, onClose }: { menuOpen: boolean; onClose: () => v
<h3 className="heading-16">{tab.heading}</h3>
<div className="w-layout-hflex flex-block-92">
<div className="w-layout-vflex flex-block-91">
{tab.links.map((link, linkIndex) => {
const catalog = catalogsData?.partsIndexCategoriesWithGroups?.[idx];
// Ищем соответствующую подгруппу по названию
let subcategoryId = `fallback_${idx}_${linkIndex}`;
if (catalog?.groups) {
for (const group of catalog.groups) {
// Проверяем в подгруппах
if (group.subgroups && group.subgroups.length > 0) {
const foundSubgroup = group.subgroups.find((subgroup: any) => subgroup.name === link);
if (foundSubgroup) {
subcategoryId = foundSubgroup.id;
{tab.links.length === 1 ? (
<div
className="link-2"
onClick={() => {
const catalog = catalogsData?.partsIndexCategoriesWithGroups?.[idx];
let subcategoryId = `fallback_${idx}_0`;
if (catalog?.groups) {
for (const group of catalog.groups) {
if (group.subgroups && group.subgroups.length > 0) {
const foundSubgroup = group.subgroups.find((subgroup: any) => subgroup.name === tab.links[0]);
if (foundSubgroup) {
subcategoryId = foundSubgroup.id;
break;
}
} else if (group.name === tab.links[0]) {
subcategoryId = group.id;
break;
}
}
}
const catalogId = catalog?.id || 'fallback';
handleCategoryClick(catalogId, tab.links[0], subcategoryId);
}}
style={{ cursor: "pointer" }}
>
Показать все
</div>
) : (
tab.links.map((link: string, linkIndex: number) => {
const catalog = catalogsData?.partsIndexCategoriesWithGroups?.[idx];
let subcategoryId = `fallback_${idx}_${linkIndex}`;
if (catalog?.groups) {
for (const group of catalog.groups) {
if (group.subgroups && group.subgroups.length > 0) {
const foundSubgroup = group.subgroups.find((subgroup: any) => subgroup.name === link);
if (foundSubgroup) {
subcategoryId = foundSubgroup.id;
break;
}
} else if (group.name === link) {
subcategoryId = group.id;
break;
}
}
// Если нет подгрупп, проверяем саму группу
else if (group.name === link) {
subcategoryId = group.id;
break;
}
}
}
return (
<div
className="link-2"
key={link}
onClick={() => {
const catalogId = catalog?.id || 'fallback';
handleCategoryClick(catalogId, link, subcategoryId);
}}
style={{ cursor: "pointer" }}
>
{link}
</div>
);
})}
return (
<div
className="link-2"
key={link}
onClick={() => {
const catalogId = catalog?.id || 'fallback';
handleCategoryClick(catalogId, link, subcategoryId);
}}
style={{ cursor: "pointer" }}
>
{link}
</div>
);
})
)}
</div>
<div className="w-layout-vflex flex-block-91-copy">
<img src="https://d3e54v103j8qbb.cloudfront.net/plugins/Basic/assets/placeholder.60f9b1840c.svg" loading="lazy" alt="" className="image-17" />

View File

@ -1,10 +1,16 @@
import React from "react";
import React, { useState } from "react";
const CatalogSubscribe: React.FC = () => (
<div className="w-layout-blockcontainer container subscribe w-container">
<div className="w-layout-hflex flex-block-18">
<img
src="/images/resource2.png"
alt="Ресурс 2"
className="mt-[-18px]"
/>
<div className="div-block-9">
<h3 className="heading-3 sub">Подпишитесь на новостную рассылку</h3>
{/* <h3 className="heading-3 sub">Подпишитесь на новостную рассылку</h3> */}
<div className="text-block-14">Оставайтесь в курсе акций, <br />новинок и специальных предложений</div>
</div>
<div className="form-block-3 w-form">
@ -13,6 +19,38 @@ const CatalogSubscribe: React.FC = () => (
<input type="submit" className="submit-button-copy w-button" value="Подписаться" />
</form>
</div>
<div className="flex flex-row items-center mt-2">
{/* Кастомный чекбокс без input/label */}
{(() => {
const [checked, setChecked] = useState(false);
return (
<>
<div
className={`h-[24px] w-[24px] border border-[#8893A1] rounded-sm mr-4 flex-shrink-0 flex items-center justify-center cursor-pointer transition-colors duration-150 ${checked ? 'bg-[#EC1C24]' : 'bg-transparent'}`}
onClick={() => setChecked(v => !v)}
role="checkbox"
aria-checked={checked}
tabIndex={0}
onKeyDown={e => { if (e.key === ' ' || e.key === 'Enter') setChecked(v => !v); }}
>
<svg
className={`w-5 h-5 text-white transition-opacity duration-150 ${checked ? 'opacity-100' : 'opacity-0'}`}
fill="none"
stroke="currentColor"
strokeWidth="2"
viewBox="0 0 24 24"
>
<path d="M5 13l4 4L19 7" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</div>
<span className="text-[#8893A1] text-[12px] leading-snug select-none">
Я даю свое согласие на обработку персональных данных<br />
и соглашаюсь с условиями <a href="/privacy-policy" className="underline hover:text-[#6c7684]">Политики конфиденциальности</a>
</span>
</>
);
})()}
</div>
</div>
</div>
);

View File

@ -385,7 +385,7 @@ const Header: React.FC<HeaderProps> = ({ onOpenAuthModal = () => console.log('Au
<section className="bottom_head">
<div className="w-layout-blockcontainer container nav w-container">
<div className="w-layout-hflex flex-block-93">
<Link href="/" className="code-embed-15 w-embed" style={{ display: 'block', cursor: 'pointer' }}>
<Link href="/" className="code-embed-15 w-embed protekauto-logo" style={{ display: 'block', cursor: 'pointer'}}>
<svg width="190" height="72" viewBox="0 0 190 72" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M138.377 29.5883V23.1172H112.878V29.5883H138.377Z" fill="white"></path>
<path d="M107.423 18.1195C109.21 18.1195 110.658 16.6709 110.658 14.884C110.658 13.097 109.21 11.6484 107.423 11.6484L88.395 11.6484C86.6082 11.6484 85.1596 13.097 85.1596 14.884C85.1596 16.6709 86.6082 18.1195 88.395 18.1195H107.423Z" fill="white"></path>

View File

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

View File

@ -0,0 +1,148 @@
import React from 'react';
interface PaginationProps {
currentPage: number;
totalPages: number;
onPageChange: (page: number) => void;
className?: string;
showPageInfo?: boolean;
}
const Pagination: React.FC<PaginationProps> = ({
currentPage,
totalPages,
onPageChange,
className = "",
showPageInfo = true
}) => {
const generatePageNumbers = () => {
const pages: (number | string)[] = [];
const delta = 2; // Количество страниц вокруг текущей
if (totalPages <= 7) {
// Если страниц мало, показываем все
for (let i = 1; i <= totalPages; i++) {
pages.push(i);
}
} else {
// Всегда показываем первую страницу
pages.push(1);
if (currentPage > delta + 2) {
pages.push('...');
}
// Показываем страницы вокруг текущей
const start = Math.max(2, currentPage - delta);
const end = Math.min(totalPages - 1, currentPage + delta);
for (let i = start; i <= end; i++) {
pages.push(i);
}
if (currentPage < totalPages - delta - 1) {
pages.push('...');
}
// Всегда показываем последнюю страницу
if (totalPages > 1) {
pages.push(totalPages);
}
}
return pages;
};
const pageNumbers = generatePageNumbers();
if (totalPages <= 1) {
return null;
}
return (
<div className={`flex flex-col items-center space-y-3 ${className}`}>
{/* Основные кнопки пагинации */}
<div className="flex items-center justify-center space-x-2">
{/* Предыдущая страница */}
<button
onClick={() => onPageChange(currentPage - 1)}
disabled={currentPage === 1}
className="flex items-center justify-center w-10 h-10 text-sm font-medium text-gray-500 bg-white border border-gray-200 rounded-lg hover:bg-gray-50 hover:text-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
style={{ cursor: currentPage === 1 ? 'not-allowed' : 'pointer' }}
>
<svg
className="w-4 h-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M15 19l-7-7 7-7"
/>
</svg>
</button>
{/* Номера страниц */}
{pageNumbers.map((page, index) => (
<React.Fragment key={index}>
{page === '...' ? (
<span className="flex items-center justify-center w-10 h-10 text-gray-400">
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
<circle cx="3" cy="10" r="1.5" />
<circle cx="10" cy="10" r="1.5" />
<circle cx="17" cy="10" r="1.5" />
</svg>
</span>
) : (
<button
onClick={() => onPageChange(page as number)}
className={`flex items-center justify-center w-10 h-10 text-sm font-medium border rounded-lg transition-colors ${
currentPage === page
? 'text-white bg-[#ec1c24] border-[#ec1c24] hover:bg-[#d91920]'
: 'text-gray-500 bg-white border-gray-200 hover:bg-gray-50 hover:text-gray-700'
}`}
style={{ cursor: 'pointer' }}
>
{page}
</button>
)}
</React.Fragment>
))}
{/* Следующая страница */}
<button
onClick={() => onPageChange(currentPage + 1)}
disabled={currentPage === totalPages}
className="flex items-center justify-center w-10 h-10 text-sm font-medium text-gray-500 bg-white border border-gray-200 rounded-lg hover:bg-gray-50 hover:text-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
style={{ cursor: currentPage === totalPages ? 'not-allowed' : 'pointer' }}
>
<svg
className="w-4 h-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M9 5l7 7-7 7"
/>
</svg>
</button>
</div>
{/* Информация о страницах */}
{showPageInfo && (
<div className="text-sm text-gray-500">
Страница {currentPage} из {totalPages}
</div>
)}
</div>
);
};
export default Pagination;

View File

@ -77,7 +77,6 @@ const TopSalesItem: React.FC<TopSalesItemProps> = ({
});
if (favoriteItem) {
removeFromFavorites(favoriteItem.id);
toast.success('Товар удален из избранного');
}
} else {
const numericPrice = parsePrice(price);

View File

@ -147,7 +147,7 @@ const BrandSelectionSection: React.FC = () => {
</svg>
</Combobox.Button>
<Combobox.Options
className="absolute left-0 top-full z-10 bg-white border-x border-b border-stone-300 rounded-b-lg shadow-lg w-full max-h-60 overflow-auto scrollbar-none"
className="absolute left-0 top-full z-100 bg-white border-x border-b border-stone-300 rounded-b-lg shadow-lg w-full max-h-60 overflow-auto scrollbar-none"
style={{ scrollbarWidth: 'none' }}
data-hide-scrollbar
>

View File

@ -1,57 +1,81 @@
import React, { useRef } from "react";
import { useQuery } from '@apollo/client';
import ArticleCard from "../ArticleCard";
import CatalogProductCardSkeleton from "../CatalogProductCardSkeleton";
import { GET_NEW_ARRIVALS } from "@/lib/graphql";
import { PartsAPIArticle } from "@/types/partsapi";
// Моковые данные для новых поступлений
const newArrivalsArticles: PartsAPIArticle[] = [
{
artId: "1",
artArticleNr: "6CT-60L",
artSupBrand: "TYUMEN BATTERY",
supBrand: "TYUMEN BATTERY",
supId: 1,
productGroup: "Аккумуляторная батарея",
ptId: 1,
},
{
artId: "2",
artArticleNr: "A0001",
artSupBrand: "Borsehung",
supBrand: "Borsehung",
supId: 2,
productGroup: "Масляный фильтр",
ptId: 2,
},
// ...добавьте еще 6 статей для примера
...Array(6).fill(0).map((_, i) => ({
artId: `${i+3}`,
artArticleNr: `ART${i+3}`,
artSupBrand: `Brand${i+3}`,
supBrand: `Brand${i+3}`,
supId: i+3,
productGroup: `Product Group ${i+3}`,
ptId: i+3,
}))
];
const imagePath = "images/162615.webp";
const SCROLL_AMOUNT = 340; // px, ширина одной карточки + отступ
// Интерфейс для товара из GraphQL
interface Product {
id: string;
name: string;
slug: string;
article?: string;
brand?: string;
retailPrice?: number;
wholesalePrice?: number;
createdAt: string;
images: Array<{
id: string;
url: string;
alt?: string;
order: number;
}>;
categories: Array<{
id: string;
name: string;
slug: string;
}>;
}
// Функция для преобразования Product в PartsAPIArticle
const transformProductToArticle = (product: Product, index: number): PartsAPIArticle => {
return {
artId: product.id,
artArticleNr: product.article || `PROD-${product.id}`,
artSupBrand: product.brand || 'Unknown Brand',
supBrand: product.brand || 'Unknown Brand',
supId: index + 1,
productGroup: product.categories?.[0]?.name || product.name,
ptId: index + 1,
};
};
const NewArrivalsSection: React.FC = () => {
const scrollRef = useRef<HTMLDivElement>(null);
// Получаем новые поступления через GraphQL
const { data, loading, error } = useQuery(GET_NEW_ARRIVALS, {
variables: { limit: 8 }
});
const scrollLeft = () => {
if (scrollRef.current) {
scrollRef.current.scrollBy({ left: -SCROLL_AMOUNT, behavior: 'smooth' });
}
};
const scrollRight = () => {
if (scrollRef.current) {
scrollRef.current.scrollBy({ left: SCROLL_AMOUNT, behavior: 'smooth' });
}
};
// Преобразуем данные для ArticleCard
const newArrivalsArticles = data?.newArrivals?.map((product: Product, index: number) =>
transformProductToArticle(product, index)
) || [];
// Получаем изображения для товаров
const getProductImage = (product: Product): string => {
if (product.images && product.images.length > 0) {
return product.images[0].url;
}
return "/images/162615.webp"; // fallback изображение
};
return (
<section className="main">
<div className="w-layout-blockcontainer container w-container">
@ -60,18 +84,71 @@ const NewArrivalsSection: React.FC = () => {
<h2 className="heading-4">Новое поступление</h2>
</div>
<div className="carousel-row">
<button className="carousel-arrow carousel-arrow-left" onClick={scrollLeft} aria-label="Прокрутить влево">
<button
className="carousel-arrow carousel-arrow-left"
onClick={scrollLeft}
aria-label="Прокрутить влево"
style={{ cursor: 'pointer' }}
>
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="16" cy="16" r="16" fill="#F3F4F6"/>
<path d="M19.5 24L12.5 16L19.5 8" stroke="#222" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
</button>
<div className="w-layout-hflex core-product-search carousel-scroll" ref={scrollRef}>
{newArrivalsArticles.map((article, i) => (
<ArticleCard key={article.artId || i} article={{ ...article, artId: article.artId }} index={i} image={imagePath} />
))}
{loading ? (
// Показываем скелетоны во время загрузки
Array(8).fill(0).map((_, index) => (
<CatalogProductCardSkeleton key={`skeleton-${index}`} />
))
) : error ? (
// Показываем сообщение об ошибке
<div className="error-message" style={{
padding: '20px',
textAlign: 'center',
color: '#666',
minWidth: '300px'
}}>
<p>Не удалось загрузить новые поступления</p>
<p style={{ fontSize: '14px', marginTop: '8px' }}>
{error.message}
</p>
</div>
) : newArrivalsArticles.length > 0 ? (
// Показываем товары
newArrivalsArticles.map((article: PartsAPIArticle, index: number) => {
const product = data.newArrivals[index];
const image = getProductImage(product);
return (
<ArticleCard
key={article.artId || `article-${index}`}
article={article}
index={index}
image={image}
/>
);
})
) : (
// Показываем сообщение о том, что товаров нет
<div className="no-products-message" style={{
padding: '20px',
textAlign: 'center',
color: '#666',
minWidth: '300px'
}}>
<p>Пока нет новых поступлений</p>
</div>
)}
</div>
<button className="carousel-arrow carousel-arrow-right" onClick={scrollRight} aria-label="Прокрутить вправо">
<button
className="carousel-arrow carousel-arrow-right"
onClick={scrollRight}
aria-label="Прокрутить вправо"
style={{ cursor: 'pointer' }}
>
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="16" cy="16" r="16" fill="#F3F4F6"/>
<path d="M12.5 8L19.5 16L12.5 24" stroke="#222" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/>

View File

@ -247,63 +247,65 @@ const ProfileGarageMain = () => {
</button>
</div>
</div>
</div>
{/* Расширенная информация об автомобиле */}
{expandedVehicle === vehicle.id && (
<div className="mt-4 px-5 py-4 bg-white rounded-lg border border-gray-200">
{/* Расширенная информация об автомобиле — вложена внутрь карточки */}
<div
className={
`overflow-hidden transition-all duration-300 rounded-lg flex flex-col gap-4` +
(expandedVehicle === vehicle.id ? ' py-4 max-h-[1000px] opacity-100 mt-4' : ' max-h-0 opacity-0 pointer-events-none')
}
>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 text-sm">
{vehicle.brand && (
<div>
<span className="font-medium text-gray-700">Бренд:</span>
<span className="ml-2 text-gray-900">{vehicle.brand}</span>
<div className="font-bold text-gray-950">Бренд</div>
<div className="mt-1.5 text-gray-600">{vehicle.brand}</div>
</div>
)}
{vehicle.model && (
<div>
<span className="font-medium text-gray-700">Модель:</span>
<span className="ml-2 text-gray-900">{vehicle.model}</span>
<div className="font-bold text-gray-950">Модель</div>
<div className="mt-1.5 text-gray-600">{vehicle.model}</div>
</div>
)}
{vehicle.modification && (
<div>
<span className="font-medium text-gray-700">Модификация:</span>
<span className="ml-2 text-gray-900">{vehicle.modification}</span>
<div className="font-bold text-gray-950">Модификация</div>
<div className="mt-1.5 text-gray-600">{vehicle.modification}</div>
</div>
)}
{vehicle.year && (
<div>
<span className="font-medium text-gray-700">Год:</span>
<span className="ml-2 text-gray-900">{vehicle.year}</span>
<div className="font-bold text-gray-950">Год</div>
<div className="mt-1.5 text-gray-600">{vehicle.year}</div>
</div>
)}
{vehicle.frame && (
<div>
<span className="font-medium text-gray-700">Номер кузова:</span>
<span className="ml-2 text-gray-900">{vehicle.frame}</span>
<div className="font-bold text-gray-950">Номер кузова</div>
<div className="mt-1.5 text-gray-600">{vehicle.frame}</div>
</div>
)}
{vehicle.licensePlate && (
<div>
<span className="font-medium text-gray-700">Госномер:</span>
<span className="ml-2 text-gray-900">{vehicle.licensePlate}</span>
<div className="font-bold text-gray-950">Госномер</div>
<div className="mt-1.5 text-gray-600">{vehicle.licensePlate}</div>
</div>
)}
{vehicle.mileage && (
<div>
<span className="font-medium text-gray-700">Пробег:</span>
<span className="ml-2 text-gray-900">{vehicle.mileage.toLocaleString()} км</span>
<div className="font-bold text-gray-950">Пробег</div>
<div className="mt-1.5 text-gray-600">{vehicle.mileage.toLocaleString()} км</div>
</div>
)}
<div>
<span className="font-medium text-gray-700">Добавлен:</span>
<span className="ml-2 text-gray-900">
<div className="font-bold text-gray-950">Добавлен</div>
<div className="mt-1.5 text-gray-600">
{new Date(vehicle.createdAt).toLocaleDateString('ru-RU')}
</span>
</div>
</div>
</div>
</div>
)}
</div>
</div>
))}
{!showAddCar && (

View File

@ -81,7 +81,7 @@ const ProfileHistoryItem: React.FC<ProfileHistoryItemProps> = ({
<>
<div className="mt-1.5 w-full border border-gray-200 border-solid min-h-[1px] max-md:max-w-full" />
<div
className="flex justify-between items-center px-5 pt-1.5 pb-2 mt-1.5 w-full bg-white rounded-lg max-md:max-w-full max-md:flex-col max-md:min-w-0 hover:bg-slate-200 transition-colors"
className="flex justify-between items-center px-5 pt-1.5 pb-2 mt-1.5 w-full bg-white rounded-lg max-md:max-w-full max-md:flex-col max-md:min-w-0 hover:bg-gray-50 transition-colors"
onClick={handleItemClick}
style={{ cursor: 'pointer' }}
>

View File

@ -3,6 +3,7 @@ import { useQuery, useMutation } from '@apollo/client';
import ProfileHistoryItem from "./ProfileHistoryItem";
import SearchInput from "./SearchInput";
import ProfileHistoryTabs from "./ProfileHistoryTabs";
import Pagination from '../Pagination';
import {
GET_PARTS_SEARCH_HISTORY,
DELETE_SEARCH_HISTORY_ITEM,
@ -19,6 +20,10 @@ const ProfileHistoryMain = () => {
const [sortField, setSortField] = useState<"date" | "manufacturer" | "name">("date");
const [sortOrder, setSortOrder] = useState<"asc" | "desc">("desc");
const [filteredItems, setFilteredItems] = useState<PartsSearchHistoryItem[]>([]);
// Состояние пагинации
const [currentPage, setCurrentPage] = useState(1);
const [itemsPerPage, setItemsPerPage] = useState(10); // Количество элементов на странице
const tabOptions = ["Все", "Сегодня", "Вчера", "Эта неделя", "Этот месяц"];
@ -26,7 +31,10 @@ const ProfileHistoryMain = () => {
const { data, loading, error, refetch } = useQuery<{ partsSearchHistory: PartsSearchHistoryResponse }>(
GET_PARTS_SEARCH_HISTORY,
{
variables: { limit: 100, offset: 0 },
variables: {
limit: 1000, // Загружаем больше для клиентской пагинации с фильтрами
offset: 0
},
fetchPolicy: 'cache-and-network',
onCompleted: (data) => {
console.log('История поиска загружена:', data);
@ -161,8 +169,32 @@ const ProfileHistoryMain = () => {
}
setFilteredItems(filtered);
// Сбрасываем страницу на первую при изменении фильтров
setCurrentPage(1);
}, [historyItems, search, activeTab, selectedManufacturer, sortField, sortOrder]);
// Вычисляем элементы для текущей страницы
const totalPages = Math.ceil(filteredItems.length / itemsPerPage);
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = startIndex + itemsPerPage;
const currentPageItems = filteredItems.slice(startIndex, endIndex);
// Обработчик изменения страницы
const handlePageChange = (page: number) => {
setCurrentPage(page);
// Прокручиваем к началу списка при смене страницы
const historyContainer = document.querySelector('.flex.flex-col.mt-5.w-full.text-gray-400');
if (historyContainer) {
historyContainer.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
};
// Обработчик изменения количества элементов на странице
const handleItemsPerPageChange = (newItemsPerPage: number) => {
setItemsPerPage(newItemsPerPage);
setCurrentPage(1); // Сбрасываем на первую страницу
};
const handleSort = (field: "date" | "manufacturer" | "name") => {
if (sortField === field) {
setSortOrder(sortOrder === "asc" ? "desc" : "asc");
@ -287,6 +319,7 @@ const ProfileHistoryMain = () => {
setSelectedManufacturer("Все");
setSearch("");
setActiveTab("Все");
setCurrentPage(1);
}}
className="px-4 py-2 text-sm text-gray-600 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors"
>
@ -424,7 +457,7 @@ const ProfileHistoryMain = () => {
</div>
</div>
) : (
filteredItems.map((item) => (
currentPageItems.map((item) => (
<ProfileHistoryItem
key={item.id}
id={item.id}
@ -441,18 +474,58 @@ const ProfileHistoryMain = () => {
vehicleInfo={item.vehicleInfo}
resultCount={item.resultCount}
onDelete={handleDeleteItem}
searchType={item.searchType}
articleNumber={item.articleNumber}
brand={item.brand}
/>
))
)}
</div>
{/* Пагинация */}
{filteredItems.length > 0 && (
<div className="mt-4 text-center text-sm text-gray-500">
Показано {filteredItems.length} из {historyItems.length} записей
{(selectedManufacturer !== "Все" || search.trim() || activeTab !== "Все") && (
<span className="ml-2 text-blue-600">
(применены фильтры)
</span>
<div className="mt-6 space-y-4">
{/* Селектор количества элементов на странице */}
<div className="flex flex-col sm:flex-row sm:justify-between sm:items-center space-y-2 sm:space-y-0">
<div className="flex items-center space-x-2 text-sm text-gray-500">
<span>Показывать по:</span>
<select
value={itemsPerPage}
onChange={(e) => handleItemsPerPageChange(Number(e.target.value))}
className="px-2 py-1 border border-gray-200 rounded text-gray-700 bg-white focus:outline-none focus:ring-2 focus:ring-[#ec1c24] focus:border-transparent"
style={{ cursor: 'pointer' }}
>
<option value={5}>5</option>
<option value={10}>10</option>
<option value={20}>20</option>
<option value={50}>50</option>
</select>
<span>записей</span>
</div>
<div className="text-sm text-gray-500 text-center sm:text-right">
Показано {startIndex + 1}-{Math.min(endIndex, filteredItems.length)} из {filteredItems.length} записей
{filteredItems.length !== historyItems.length && (
<span className="ml-1">
(всего {historyItems.length})
</span>
)}
{(selectedManufacturer !== "Все" || search.trim() || activeTab !== "Все") && (
<span className="ml-2 text-blue-600">
(применены фильтры)
</span>
)}
</div>
</div>
{/* Компонент пагинации */}
{filteredItems.length > itemsPerPage && (
<Pagination
currentPage={currentPage}
totalPages={totalPages}
onPageChange={handlePageChange}
showPageInfo={true}
/>
)}
</div>
)}

View File

@ -45,6 +45,8 @@ const VinQuick: React.FC<VinQuickProps> = ({ quickGroup, catalogCode, vehicleId,
}
};
const [shownCounts, setShownCounts] = useState<{ [unitid: string]: number }>({});
return (
<div className="w-full">
{/* <button onClick={onBack} className="mb-4 px-4 py-2 bg-gray-200 rounded self-start">Назад</button> */}
@ -71,16 +73,48 @@ const VinQuick: React.FC<VinQuickProps> = ({ quickGroup, catalogCode, vehicleId,
</div>
<div className="knot-img">
<h1 className="heading-19">{unit.name}</h1>
{unit.details && unit.details.length > 0 && unit.details.map((detail: any, index: number) => (
<div className="w-layout-hflex flex-block-115" key={`${unit.unitid}-${detail.detailid || index}`}>
<div className="oemnuber">{detail.oem}</div>
<div className="partsname">{detail.name}</div>
<a href="#" className="button-3 w-button" onClick={e => { e.preventDefault(); handleDetailClick(detail); }}>Показать цены</a>
</div>
))}
<a href="#" className="showallparts w-button" onClick={e => { e.preventDefault(); handleUnitClick(unit); }}>Подробнее</a>
{(() => {
const details = unit.details || [];
const total = details.length;
const shownCount = shownCounts[unit.unitid] ?? 3;
return (
<>
{details.slice(0, shownCount).map((detail: any, index: number) => (
<div className="w-layout-hflex flex-block-115" key={`${unit.unitid}-${detail.detailid || index}`}>
<div className="oemnuber">{detail.oem}</div>
<div className="partsname">{detail.name}</div>
<a href="#" className="button-3 w-button" onClick={e => { e.preventDefault(); handleDetailClick(detail); }}>Показать цены</a>
</div>
))}
{total > 3 && shownCount < total && (
<div className="flex gap-2 mt-2 w-full">
{shownCount + 3 < total && (
<button
className="expand-btn"
onClick={() => setShownCounts(prev => ({ ...prev, [unit.unitid]: shownCount + 3 }))}
style={{ border: '1px solid #EC1C24', borderRadius: 8, background: '#fff', color: '#222', padding: '6px 18px', minWidth: 180 }}
>
Развернуть
<svg width="16" height="16" viewBox="0 0 16 16" style={{ display: 'inline', verticalAlign: 'middle', marginLeft: 4 }}>
<path d="M4 6l4 4 4-4" stroke="#222" strokeWidth="2" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
</button>
)}
<button
className="showall-btn"
onClick={() => setShownCounts(prev => ({ ...prev, [unit.unitid]: total }))}
style={{ background: '#e9eef5', borderRadius: 8, color: '#222', padding: '6px 18px', border: 'none'}}
>
Показать все
</button>
</div>
)}
{shownCount >= total && (
<a href="#" className="showallparts w-button" onClick={e => { e.preventDefault(); handleUnitClick(unit); }}>Подробнее</a>
)}
</>
);
})()}
</div>
</div>
))

View File

@ -134,8 +134,13 @@ const FavoritesProvider: React.FC<FavoritesProviderProps> = ({ children }) => {
const [removeFavoriteMutation] = useMutation(REMOVE_FROM_FAVORITES, {
onCompleted: () => {
toast.success('Товар удален из избранного', {
toast('Товар удален из избранного', {
icon: <DeleteCartIcon size={20} color="#ec1c24" />,
style: {
background: '#6b7280', // Серый фон
color: '#fff', // Белый текст
},
duration: 3000,
})
},
onError: (error) => {

View File

@ -1678,4 +1678,31 @@ export const GET_DAILY_PRODUCTS = gql`
}
}
}
`
// Запрос для получения новых поступлений
export const GET_NEW_ARRIVALS = gql`
query GetNewArrivals($limit: Int) {
newArrivals(limit: $limit) {
id
name
slug
article
brand
retailPrice
wholesalePrice
createdAt
images {
id
url
alt
order
}
categories {
id
name
slug
}
}
}
`

View File

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

View File

@ -30,7 +30,7 @@
}
.bottom_head{
z-index: 60;
z-index: 3000;
}
.top_head{
@ -618,12 +618,48 @@ body {
font-size: 28px;
}
.form-block-4,
.flex-block-124,
.flex-block-6-copy
{
overflow: visible !important;
}
a.link-block.w-inline-block,
a.link-block-2.w-inline-block {
font-size: 12px;
}
.core-product-search.carousel-scroll {
display: flex;
flex-wrap: nowrap; /* Не переносить строки */
gap: 16px; /* Отступ между карточками, если нужно */
}
.subscribe{
padding-top: 10px !important;
padding-bottom: 10px !important;
}
.text-block-14, .div-block-9{
width: 350px !important;
max-width: 350px !important;
min-width: 350px !important;
}
@media screen and (max-width: 1920px) {
.text-block-14, .div-block-9{
width: 350px !important;
}
}
.flex-block-18{
row-gap: 40px !important;
}
.menu-button.w--open {
z-index: 2000;
@ -631,10 +667,9 @@ a.link-block-2.w-inline-block {
color: var(--white);
justify-content: center;
align-items: center;
height: 50px;
padding-top: 15px;
padding-bottom: 15px;
left: auto;
width: 50px;
height: 44px;
padding: 13px 12px;
}
.heading-7 {
z-index: 999;
@ -671,15 +706,25 @@ a.link-block-2.w-inline-block {
overflow: hidden;
}
.flex-block-14-copy-copy{
margin-bottom: 20px !important;
}
.showall-btn {
width: 100%;
}
.showall-btn:hover {
background: #ec1c24 !important;
color: #fff !important;
}
@media screen and (max-width: 991px) {
.flex-block-108, .flex-block-14-copy-copy {
flex-flow: column;
justify-content: space-between;
}
.flex-block-14-copy-copy{
align-items: center;
}
}
@media screen and (max-width: 991px) {
@ -994,3 +1039,7 @@ a.link-block-2.w-inline-block {
}
}
.protekauto-logo {
position: fixed;
z-index: 3000;
}

View File

@ -1008,10 +1008,9 @@ body {
color: var(--white);
justify-content: center;
align-items: center;
height: 50px;
padding-top: 15px;
padding-bottom: 15px;
left: auto;
width: 50px;
height: 44px;
padding: 13px 12px;
}
.menu-button.w--open:hover {