From d4ba549a81f0520b5f1861d9d2a798e21dd67d33 Mon Sep 17 00:00:00 2001 From: egortriston Date: Sun, 29 Jun 2025 03:20:45 +0300 Subject: [PATCH] pravkiend 29.06 --- src/components/FulltextSearchSection.tsx | 4 +- src/components/vin/VinCategory.tsx | 24 ++++----- src/components/vin/VinLeftbar.tsx | 22 +++++++-- .../vehicle-search/[brand]/[vehicleId].tsx | 49 ++++++++++++++++--- src/styles/my.css | 15 ++++-- 5 files changed, 85 insertions(+), 29 deletions(-) diff --git a/src/components/FulltextSearchSection.tsx b/src/components/FulltextSearchSection.tsx index 993b087..5dd4d2b 100644 --- a/src/components/FulltextSearchSection.tsx +++ b/src/components/FulltextSearchSection.tsx @@ -31,6 +31,8 @@ const FulltextSearchSection: React.FC = ({ return; } + console.log('SEARCH PARAMS', { catalogCode, vehicleId, searchQuery: searchQuery.trim(), ssd }); + executeSearch({ variables: { catalogCode, @@ -199,6 +201,4 @@ const FulltextSearchSection: React.FC = ({ ); }; - - export default FulltextSearchSection; \ No newline at end of file diff --git a/src/components/vin/VinCategory.tsx b/src/components/vin/VinCategory.tsx index 2686210..60d23b8 100644 --- a/src/components/vin/VinCategory.tsx +++ b/src/components/vin/VinCategory.tsx @@ -25,7 +25,7 @@ const VinCategory: React.FC = ({ catalogCode, vehicleId, ssd, ...prev, [lastCategoryIdRef.current!]: data.laximoUnits || [], })); - } +} }, }); const [selectedCategory, setSelectedCategory] = useState(null); @@ -71,7 +71,7 @@ const VinCategory: React.FC = ({ catalogCode, vehicleId, ssd, if (categoriesError) return
Ошибка: {categoriesError.message}
; return ( -
+
{!selectedCategory ? ( // Список категорий categories.map((cat: any, idx: number) => ( @@ -111,18 +111,18 @@ const VinCategory: React.FC = ({ catalogCode, vehicleId, ssd, style={{ cursor: "pointer" }} >
{subcat.name}
-
- - - - -
-
- ))} +
+ + + + +
+
+ ))} )} - - ); + +); }; export default VinCategory; \ No newline at end of file diff --git a/src/components/vin/VinLeftbar.tsx b/src/components/vin/VinLeftbar.tsx index f45a63f..fba4f3e 100644 --- a/src/components/vin/VinLeftbar.tsx +++ b/src/components/vin/VinLeftbar.tsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from "react"; import { useLazyQuery, useQuery } from '@apollo/client'; import { SEARCH_LAXIMO_FULLTEXT, GET_LAXIMO_CATEGORIES, GET_LAXIMO_UNITS } from '@/lib/graphql/laximo'; +import VinPartCard from './VinPartCard'; interface VinLeftbarProps { catalogCode?: string; @@ -46,7 +47,12 @@ const VinLeftbar: React.FC = ({ catalogCode, vehicleId, ssd, on }; const handleSearch = () => { - if (!searchQuery.trim() || !catalogCode || !vehicleId || !ssd) return; + if (!searchQuery.trim()) return; + if (!ssd || ssd.trim() === '') { + console.error('SSD обязателен для поиска по названию'); + return; + } + console.log('SEARCH PARAMS', { catalogCode, vehicleId, searchQuery: searchQuery.trim(), ssd }); executeSearch({ variables: { catalogCode, @@ -75,12 +81,19 @@ const VinLeftbar: React.FC = ({ catalogCode, vehicleId, ssd, on } }, [searchResults, searchQuery, onSearchResults]); + // --- Новый блок: вычисляем доступность поиска --- + const isSearchAvailable = !!catalogCode && !!vehicleId && !!ssd && ssd.trim() !== ''; + const showWarning = !isSearchAvailable; + const showError = !!error && isSearchAvailable && searchQuery.trim(); + const showNotFound = isSearchAvailable && searchQuery.trim() && !loading && data && searchResults && searchResults.details && searchResults.details.length === 0; + const showTips = isSearchAvailable && !searchQuery.trim() && !loading; + return (
diff --git a/src/pages/vehicle-search/[brand]/[vehicleId].tsx b/src/pages/vehicle-search/[brand]/[vehicleId].tsx index 532a032..8430150 100644 --- a/src/pages/vehicle-search/[brand]/[vehicleId].tsx +++ b/src/pages/vehicle-search/[brand]/[vehicleId].tsx @@ -157,17 +157,17 @@ const VehicleDetailsPage = () => { if (vehicleLoading) { return ( -<> + <> Загрузка автомобиля... -
+

Загружаем информацию об автомобиле...

-
- +
+ ); } @@ -194,16 +194,49 @@ const VehicleDetailsPage = () => { ); } - // Если информация об автомобиле недоступна, создаем заглушку - const vehicleInfo = vehicleData?.laximoVehicleInfo || { - vehicleid: vehicleId as string, + // Если vehicleId невалидный (например, '0'), показываем предупреждение и не рендерим поиск + if (!vehicleId || vehicleId === '0') { + return ( +
+
+

Автомобиль не выбран

+

Для поиска по деталям необходимо выбрать конкретный автомобиль через VIN или мастер подбора.

+ +
+
+ ); + } + + // Гарантируем, что vehicleId — строка + const vehicleIdStr = Array.isArray(vehicleId) ? (vehicleId[0] || '') : (vehicleId || ''); + const fallbackVehicleId = (vehicleIdStr !== '0' ? vehicleIdStr : ''); + + let vehicleInfo = vehicleData?.laximoVehicleInfo || { + vehicleid: fallbackVehicleId, name: `Автомобиль ${catalogData.laximoCatalogInfo.name}`, ssd: finalSsd, brand: catalogData.laximoCatalogInfo.brand, catalog: catalogData.laximoCatalogInfo.code, - attributes: [] + attributes: [] as never[] }; + // Если вдруг с сервера пришёл vehicleid: '0', подменяем на корректный + if (vehicleInfo.vehicleid === '0' && fallbackVehicleId) { + vehicleInfo = { ...vehicleInfo, vehicleid: fallbackVehicleId }; + } + + // Логируем, что реально передаём в VinLeftbar + console.log('Передаём в VinLeftbar:', { + catalog: vehicleInfo.catalog, + vehicleid: vehicleInfo.vehicleid, + ssd: vehicleInfo.ssd + }); + // Если нет данных автомобиля и есть ошибка, показываем предупреждение const hasError = vehicleError && !vehicleData?.laximoVehicleInfo; const catalogInfo = catalogData.laximoCatalogInfo; diff --git a/src/styles/my.css b/src/styles/my.css index 293c0ea..4c2222d 100644 --- a/src/styles/my.css +++ b/src/styles/my.css @@ -387,13 +387,12 @@ input.input-receiver:focus { } .knotin { - height: 100%; + max-width: 100%; display: flex; align-items: stretch; } .knotin img { - height: 100%; - width: auto; + max-width: 100%; object-fit: contain; /* или cover */ } @@ -419,4 +418,14 @@ input#VinSearchInput { text-overflow: ellipsis; display: block; max-width: 90%; +} + +.text-block-55 { + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; + text-overflow: ellipsis; + max-height: 2.8em; + line-height: 1.4em; } \ No newline at end of file -- 2.49.0