add best offer flag
This commit is contained in:
parent
56c6560a05
commit
4b7c100b3d
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ export class CatalogItemDto {
|
|||
hasQuickRent: boolean;
|
||||
isFeatured: boolean;
|
||||
topText?: string;
|
||||
isBestOffer?: boolean;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue