Удалены модальные окна выбора бренда из компонентов PartDetailCard, KnotParts, VinPartCard и VinQuick. Вместо этого добавлена логика для перехода на страницу выбора бренда при клике на деталь. Обновлены компоненты для передачи параметров catalogCode и vehicleId. Исправлены типы и улучшена читаемость кода.
This commit is contained in:
@ -1,22 +1,27 @@
|
||||
import React, { useState } from "react";
|
||||
import React from "react";
|
||||
import { useRouter } from 'next/router';
|
||||
import BrandSelectionModal from '../BrandSelectionModal';
|
||||
|
||||
interface VinPartCardProps {
|
||||
n?: number;
|
||||
oem: string;
|
||||
name: string;
|
||||
onPriceClick?: () => void;
|
||||
catalogCode?: string;
|
||||
vehicleId?: string;
|
||||
}
|
||||
|
||||
const VinPartCard: React.FC<VinPartCardProps> = ({ n, oem, name, onPriceClick }) => {
|
||||
const VinPartCard: React.FC<VinPartCardProps> = ({ n, oem, name, onPriceClick, catalogCode, vehicleId }) => {
|
||||
const router = useRouter();
|
||||
const [isBrandModalOpen, setIsBrandModalOpen] = useState(false);
|
||||
|
||||
const handlePriceClick = (e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
if (onPriceClick) onPriceClick();
|
||||
setIsBrandModalOpen(true);
|
||||
|
||||
if (catalogCode && vehicleId !== undefined) {
|
||||
// Переходим на страницу выбора бренда
|
||||
const url = `/vehicle-search/${catalogCode}/${vehicleId}/part/${oem}/brands?detailName=${encodeURIComponent(name || '')}`;
|
||||
router.push(url);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@ -36,12 +41,6 @@ const VinPartCard: React.FC<VinPartCardProps> = ({ n, oem, name, onPriceClick })
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<BrandSelectionModal
|
||||
isOpen={isBrandModalOpen}
|
||||
onClose={() => setIsBrandModalOpen(false)}
|
||||
articleNumber={oem}
|
||||
detailName={name}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
Reference in New Issue
Block a user