diff --git a/src/catalog/catalog.service.ts b/src/catalog/catalog.service.ts index 775e3d3..8ebd880 100644 --- a/src/catalog/catalog.service.ts +++ b/src/catalog/catalog.service.ts @@ -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, }; } diff --git a/src/catalog/dto/catalog-item.dto.ts b/src/catalog/dto/catalog-item.dto.ts index 8c07837..859b642 100644 --- a/src/catalog/dto/catalog-item.dto.ts +++ b/src/catalog/dto/catalog-item.dto.ts @@ -9,4 +9,5 @@ export class CatalogItemDto { hasQuickRent: boolean; isFeatured: boolean; topText?: string; + isBestOffer?: boolean; }