Feat/SW-3028 hotel page campaigns
* feat(SW-3028): Added query and typings to fetch campaigns by hotelUid * feat(SW-3028): Added components for campaigns to the hotel page * feat(SW-3028): Implemented prioritized campaigns list * chore(SW-3028): Refactor how campaigns are fetched on hotel pages * feat(SW-3028): Added offers/campaigns to tab navigation Approved-by: Matilda Landström
This commit is contained in:
@@ -7,6 +7,7 @@ import { batchedHotelPageUrlsSchema, hotelPageCountSchema } from "./output"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import type { Campaigns } from "../../../types/campaignPage"
|
||||
import type {
|
||||
GetHotelPageCountData,
|
||||
GetHotelPageUrlsData,
|
||||
@@ -97,3 +98,16 @@ export async function getHotelPageUrls(lang: Lang) {
|
||||
|
||||
return validatedResponse.data
|
||||
}
|
||||
|
||||
export function getSortedCampaigns(
|
||||
prioritizedCampaignUids: string[],
|
||||
campaigns: Campaigns
|
||||
) {
|
||||
const prioritizedSet = new Set(prioritizedCampaignUids)
|
||||
const prioritized = prioritizedCampaignUids.flatMap((id) => {
|
||||
const found = campaigns.find((c) => c.id === id)
|
||||
return found ? [found] : []
|
||||
})
|
||||
const others = campaigns.filter((c) => !prioritizedSet.has(c.id))
|
||||
return [...prioritized, ...others]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user