1 Commits

Author SHA1 Message Date
936a08aa11 Merge pull request 'pravki 29.06' (#3) from pravki2906 into main
Reviewed-on: #3
2025-06-29 00:42:23 +03:00
5 changed files with 29 additions and 85 deletions

View File

@ -31,8 +31,6 @@ const FulltextSearchSection: React.FC<FulltextSearchSectionProps> = ({
return; return;
} }
console.log('SEARCH PARAMS', { catalogCode, vehicleId, searchQuery: searchQuery.trim(), ssd });
executeSearch({ executeSearch({
variables: { variables: {
catalogCode, catalogCode,
@ -201,4 +199,6 @@ const FulltextSearchSection: React.FC<FulltextSearchSectionProps> = ({
); );
}; };
export default FulltextSearchSection; export default FulltextSearchSection;

View File

@ -25,7 +25,7 @@ const VinCategory: React.FC<VinCategoryProps> = ({ catalogCode, vehicleId, ssd,
...prev, ...prev,
[lastCategoryIdRef.current!]: data.laximoUnits || [], [lastCategoryIdRef.current!]: data.laximoUnits || [],
})); }));
} }
}, },
}); });
const [selectedCategory, setSelectedCategory] = useState<any | null>(null); const [selectedCategory, setSelectedCategory] = useState<any | null>(null);
@ -71,7 +71,7 @@ const VinCategory: React.FC<VinCategoryProps> = ({ catalogCode, vehicleId, ssd,
if (categoriesError) return <div style={{ color: "red" }}>Ошибка: {categoriesError.message}</div>; if (categoriesError) return <div style={{ color: "red" }}>Ошибка: {categoriesError.message}</div>;
return ( return (
<div className="w-layout-vflex flex-block-14-copy-copy"> <div className="w-layout-vflex flex-block-14-copy-copy">
{!selectedCategory ? ( {!selectedCategory ? (
// Список категорий // Список категорий
categories.map((cat: any, idx: number) => ( categories.map((cat: any, idx: number) => (
@ -111,18 +111,18 @@ const VinCategory: React.FC<VinCategoryProps> = ({ catalogCode, vehicleId, ssd,
style={{ cursor: "pointer" }} style={{ cursor: "pointer" }}
> >
<div className="text-block-57">{subcat.name}</div> <div className="text-block-57">{subcat.name}</div>
<div className="w-embed"> <div className="w-embed">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="24" width="24" height="24" rx="12" transform="rotate(90 24 0)" fill="currentcolor"></rect> <rect x="24" width="24" height="24" rx="12" transform="rotate(90 24 0)" fill="currentcolor"></rect>
<path fillRule="evenodd" clipRule="evenodd" d="M10.9303 17L10 16.0825L14.1395 12L10 7.91747L10.9303 7L16 12L10.9303 17Z" fill="white"></path> <path fillRule="evenodd" clipRule="evenodd" d="M10.9303 17L10 16.0825L14.1395 12L10 7.91747L10.9303 7L16 12L10.9303 17Z" fill="white"></path>
</svg> </svg>
</div> </div>
</div> </div>
))} ))}
</> </>
)} )}
</div> </div>
); );
}; };
export default VinCategory; export default VinCategory;

View File

@ -1,7 +1,6 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { useLazyQuery, useQuery } from '@apollo/client'; import { useLazyQuery, useQuery } from '@apollo/client';
import { SEARCH_LAXIMO_FULLTEXT, GET_LAXIMO_CATEGORIES, GET_LAXIMO_UNITS } from '@/lib/graphql/laximo'; import { SEARCH_LAXIMO_FULLTEXT, GET_LAXIMO_CATEGORIES, GET_LAXIMO_UNITS } from '@/lib/graphql/laximo';
import VinPartCard from './VinPartCard';
interface VinLeftbarProps { interface VinLeftbarProps {
catalogCode?: string; catalogCode?: string;
@ -47,12 +46,7 @@ const VinLeftbar: React.FC<VinLeftbarProps> = ({ catalogCode, vehicleId, ssd, on
}; };
const handleSearch = () => { const handleSearch = () => {
if (!searchQuery.trim()) return; if (!searchQuery.trim() || !catalogCode || !vehicleId || !ssd) return;
if (!ssd || ssd.trim() === '') {
console.error('SSD обязателен для поиска по названию');
return;
}
console.log('SEARCH PARAMS', { catalogCode, vehicleId, searchQuery: searchQuery.trim(), ssd });
executeSearch({ executeSearch({
variables: { variables: {
catalogCode, catalogCode,
@ -81,19 +75,12 @@ const VinLeftbar: React.FC<VinLeftbarProps> = ({ catalogCode, vehicleId, ssd, on
} }
}, [searchResults, searchQuery, onSearchResults]); }, [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 ( return (
<div className="w-layout-vflex vinleftbar"> <div className="w-layout-vflex vinleftbar">
<div className="div-block-2"> <div className="div-block-2">
<div className="form-block w-form"> <div className="form-block w-form">
<form id="vin-form-search" name="vin-form-search" data-name="vin-form-search" action="#" method="post" className="form"> <form id="vin-form-search" name="vin-form-search" data-name="vin-form-search" action="#" method="post" className="form">
<a href="#" className="link-block-3 w-inline-block" onClick={e => { e.preventDefault(); if (!ssd || ssd.trim() === '') { return; } handleSearch(); }}> <a href="#" className="link-block-3 w-inline-block" onClick={e => { e.preventDefault(); handleSearch(); }}>
<div className="code-embed-6 w-embed"> <div className="code-embed-6 w-embed">
{/* SVG */} {/* SVG */}
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
@ -114,11 +101,10 @@ const VinLeftbar: React.FC<VinLeftbarProps> = ({ catalogCode, vehicleId, ssd, on
value={searchQuery} value={searchQuery}
onChange={e => setSearchQuery(e.target.value)} onChange={e => setSearchQuery(e.target.value)}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
disabled={loading} disabled={!catalogCode || !vehicleId || !ssd}
/> />
</form> </form>
{/* Варианты отображения: предупреждение, ошибка, подсказки, результаты */} {error && <div style={{ color: 'red', fontSize: 12 }}>Ошибка поиска: {error.message}</div>}
</div> </div>
</div> </div>
<div className="w-layout-vflex flex-block-113"> <div className="w-layout-vflex flex-block-113">

View File

@ -157,17 +157,17 @@ const VehicleDetailsPage = () => {
if (vehicleLoading) { if (vehicleLoading) {
return ( return (
<> <>
<Head> <Head>
<title>Загрузка автомобиля...</title> <title>Загрузка автомобиля...</title>
</Head> </Head>
<div style={{ minHeight: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', background: '#f9fafb' }}> <main className="min-h-screen bg-gray-50 flex items-center justify-center">
<div className="text-center"> <div className="text-center">
<div className="animate-spin rounded-full h-32 w-32 border-b-2 border-red-600 mx-auto"></div> <div className="animate-spin rounded-full h-32 w-32 border-b-2 border-red-600 mx-auto"></div>
<p className="mt-4 text-lg text-gray-600">Загружаем информацию об автомобиле...</p> <p className="mt-4 text-lg text-gray-600">Загружаем информацию об автомобиле...</p>
</div> </div>
</div> </main>
</> </>
); );
} }
@ -194,49 +194,16 @@ const VehicleDetailsPage = () => {
); );
} }
// Если vehicleId невалидный (например, '0'), показываем предупреждение и не рендерим поиск // Если информация об автомобиле недоступна, создаем заглушку
if (!vehicleId || vehicleId === '0') { const vehicleInfo = vehicleData?.laximoVehicleInfo || {
return ( vehicleid: vehicleId as string,
<main className="min-h-screen bg-yellow-50 flex items-center justify-center">
<div className="text-center">
<h1 className="text-2xl font-bold text-yellow-900 mb-4">Автомобиль не выбран</h1>
<p className="text-yellow-700 mb-8">Для поиска по деталям необходимо выбрать конкретный автомобиль через VIN или мастер подбора.</p>
<button
onClick={() => router.back()}
className="bg-yellow-600 text-white px-6 py-3 rounded-lg hover:bg-yellow-700 transition-colors"
>
Назад к поиску
</button>
</div>
</main>
);
}
// Гарантируем, что vehicleId — строка
const vehicleIdStr = Array.isArray(vehicleId) ? (vehicleId[0] || '') : (vehicleId || '');
const fallbackVehicleId = (vehicleIdStr !== '0' ? vehicleIdStr : '');
let vehicleInfo = vehicleData?.laximoVehicleInfo || {
vehicleid: fallbackVehicleId,
name: `Автомобиль ${catalogData.laximoCatalogInfo.name}`, name: `Автомобиль ${catalogData.laximoCatalogInfo.name}`,
ssd: finalSsd, ssd: finalSsd,
brand: catalogData.laximoCatalogInfo.brand, brand: catalogData.laximoCatalogInfo.brand,
catalog: catalogData.laximoCatalogInfo.code, catalog: catalogData.laximoCatalogInfo.code,
attributes: [] as never[] attributes: []
}; };
// Если вдруг с сервера пришёл 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 hasError = vehicleError && !vehicleData?.laximoVehicleInfo;
const catalogInfo = catalogData.laximoCatalogInfo; const catalogInfo = catalogData.laximoCatalogInfo;

View File

@ -387,12 +387,13 @@ input.input-receiver:focus {
} }
.knotin { .knotin {
max-width: 100%; height: 100%;
display: flex; display: flex;
align-items: stretch; align-items: stretch;
} }
.knotin img { .knotin img {
max-width: 100%; height: 100%;
width: auto;
object-fit: contain; /* или cover */ object-fit: contain; /* или cover */
} }
@ -418,14 +419,4 @@ input#VinSearchInput {
text-overflow: ellipsis; text-overflow: ellipsis;
display: block; display: block;
max-width: 90%; 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;
} }