fix11072025 histitem
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import React from "react";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
interface VehicleInfo {
|
||||
brand?: string;
|
||||
@ -15,6 +16,10 @@ interface ProfileHistoryItemProps {
|
||||
vehicleInfo?: VehicleInfo;
|
||||
resultCount?: number;
|
||||
onDelete?: (id: string) => void;
|
||||
// Добавляем новые пропсы для поиска
|
||||
searchType?: 'TEXT' | 'ARTICLE' | 'OEM' | 'VIN' | 'PLATE' | 'WIZARD' | 'PART_VEHICLES';
|
||||
articleNumber?: string;
|
||||
brand?: string;
|
||||
}
|
||||
|
||||
const ProfileHistoryItem: React.FC<ProfileHistoryItemProps> = ({
|
||||
@ -26,7 +31,12 @@ const ProfileHistoryItem: React.FC<ProfileHistoryItemProps> = ({
|
||||
vehicleInfo,
|
||||
resultCount,
|
||||
onDelete,
|
||||
searchType,
|
||||
articleNumber,
|
||||
brand,
|
||||
}) => {
|
||||
const router = useRouter();
|
||||
|
||||
const handleDeleteClick = (e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
if (onDelete) {
|
||||
@ -34,6 +44,28 @@ const ProfileHistoryItem: React.FC<ProfileHistoryItemProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
const handleItemClick = () => {
|
||||
// Определяем куда перенаправлять в зависимости от типа поиска
|
||||
if (searchType === 'VIN' || searchType === 'PLATE') {
|
||||
// Для VIN и госномера перенаправляем на vehicle-search-results
|
||||
router.push(`/vehicle-search-results?q=${encodeURIComponent(name)}`);
|
||||
} else if (searchType === 'ARTICLE' || searchType === 'OEM' || (searchType === 'TEXT' && articleNumber)) {
|
||||
// Для поиска по артикулу/OEM или текстового поиска с артикулом
|
||||
const searchBrand = brand || manufacturer || '';
|
||||
const searchArticle = articleNumber || name;
|
||||
router.push(`/search-result?article=${encodeURIComponent(searchArticle)}&brand=${encodeURIComponent(searchBrand)}`);
|
||||
} else if (searchType === 'TEXT') {
|
||||
// Для обычного текстового поиска
|
||||
router.push(`/search?q=${encodeURIComponent(name)}&mode=parts`);
|
||||
} else if (searchType === 'PART_VEHICLES') {
|
||||
// Для поиска автомобилей по детали
|
||||
router.push(`/vehicles-by-part?partNumber=${encodeURIComponent(name)}`);
|
||||
} else {
|
||||
// По умолчанию - обычный поиск
|
||||
router.push(`/search?q=${encodeURIComponent(name)}&mode=parts`);
|
||||
}
|
||||
};
|
||||
|
||||
const getSearchTypeDisplay = (article: string) => {
|
||||
if (article.includes('TEXT')) return 'Текстовый поиск';
|
||||
if (article.includes('ARTICLE')) return 'По артикулу';
|
||||
@ -48,7 +80,11 @@ const ProfileHistoryItem: React.FC<ProfileHistoryItemProps> = ({
|
||||
return (
|
||||
<>
|
||||
<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">
|
||||
<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"
|
||||
onClick={handleItemClick}
|
||||
style={{ cursor: 'pointer' }}
|
||||
>
|
||||
<div className="flex flex-wrap flex-1 shrink gap-5 items-center self-stretch pr-5 my-auto w-full basis-0 max-md:max-w-full max-md:flex-col max-md:gap-2 max-md:p-0 max-md:min-w-0">
|
||||
<div className="self-stretch my-auto w-40 max-md:w-full text-sm">
|
||||
<div className="font-medium text-gray-900">{date}</div>
|
||||
|
Reference in New Issue
Block a user