add best offer flag

This commit is contained in:
Иван 2025-12-14 20:09:32 +03:00
parent 56c6560a05
commit 4b7c100b3d
2 changed files with 14 additions and 4 deletions

View File

@ -270,14 +270,23 @@ export class CatalogService {
({ isFeatured }) => !isFeatured,
);
const featuredYacthIndex = clonedCatalog.findIndex(
const featuredYachtIndex = clonedCatalog.findIndex(
(item) => item.isFeatured === true,
);
if (featuredYacthIndex !== -1) {
if (featuredYachtIndex !== -1) {
const minCost = Math.min(
...filteredCatalog.map((item) => item.minCost || Infinity),
);
const mappedRestYachts = filteredCatalog.slice(0, 6).map((item) => ({
...item,
isBestOffer: item.minCost === minCost,
}));
return {
featuredYacht: clonedCatalog[featuredYacthIndex],
restYachts: filteredCatalog.slice(0, 6),
featuredYacht: clonedCatalog[featuredYachtIndex],
restYachts: mappedRestYachts,
};
}

View File

@ -9,4 +9,5 @@ export class CatalogItemDto {
hasQuickRent: boolean;
isFeatured: boolean;
topText?: string;
isBestOffer?: boolean;
}