add best offer flag
This commit is contained in:
parent
56c6560a05
commit
4b7c100b3d
|
|
@ -270,14 +270,23 @@ export class CatalogService {
|
||||||
({ isFeatured }) => !isFeatured,
|
({ isFeatured }) => !isFeatured,
|
||||||
);
|
);
|
||||||
|
|
||||||
const featuredYacthIndex = clonedCatalog.findIndex(
|
const featuredYachtIndex = clonedCatalog.findIndex(
|
||||||
(item) => item.isFeatured === true,
|
(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 {
|
return {
|
||||||
featuredYacht: clonedCatalog[featuredYacthIndex],
|
featuredYacht: clonedCatalog[featuredYachtIndex],
|
||||||
restYachts: filteredCatalog.slice(0, 6),
|
restYachts: mappedRestYachts,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,5 @@ export class CatalogItemDto {
|
||||||
hasQuickRent: boolean;
|
hasQuickRent: boolean;
|
||||||
isFeatured: boolean;
|
isFeatured: boolean;
|
||||||
topText?: string;
|
topText?: string;
|
||||||
|
isBestOffer?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue