Добавлено получение информации о деталях из Parts Index и обновлены компоненты для отображения этой информации. Включены новые типы для работы с данными Parts Index.
This commit is contained in:
@ -15,6 +15,7 @@ import CatalogSortDropdown from "@/components/CatalogSortDropdown";
|
||||
import MobileMenuBottomSection from '../components/MobileMenuBottomSection';
|
||||
import { SEARCH_PRODUCT_OFFERS, GET_ANALOG_OFFERS } from "@/lib/graphql";
|
||||
import { useArticleImage } from "@/hooks/useArticleImage";
|
||||
import { usePartsIndexEntityInfo } from "@/hooks/usePartsIndex";
|
||||
|
||||
const ANALOGS_CHUNK_SIZE = 5;
|
||||
|
||||
@ -255,6 +256,12 @@ export default function SearchResult() {
|
||||
});
|
||||
|
||||
const { imageUrl: mainImageUrl } = useArticleImage(artId as string, { enabled: !!artId });
|
||||
|
||||
// Получаем информацию о детали из Parts Index
|
||||
const { entityInfo, loading: partsIndexLoading } = usePartsIndexEntityInfo(
|
||||
searchQuery || null,
|
||||
brandQuery || null
|
||||
);
|
||||
|
||||
const [
|
||||
getAnalogOffers,
|
||||
@ -568,15 +575,20 @@ export default function SearchResult() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Используем фотографию из Parts Index, если она есть, иначе fallback на mainImageUrl
|
||||
const partsIndexImage = entityInfo?.images?.[0];
|
||||
const displayImage = partsIndexImage || mainImageUrl;
|
||||
|
||||
return (
|
||||
<>
|
||||
<CoreProductCard
|
||||
brand={result.brand}
|
||||
article={result.articleNumber}
|
||||
name={result.name}
|
||||
image={mainImageUrl}
|
||||
image={displayImage}
|
||||
offers={mainProductOffers}
|
||||
showMoreText={mainProductOffers.length < filteredOffers.filter(o => !o.isAnalog).length ? "Показать еще" : undefined}
|
||||
partsIndexPowered={!!partsIndexImage}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
Reference in New Issue
Block a user