Files
web/apps/scandic-web/lib/trpc/memoizedRequests/index.ts
Erik Tiekstra 0c6a4cf186 feat(BOOK-463): Fetching hotel filters from CMS and using these inside the destination pages and select hotel page
* feat(BOOK-463): Fetching hotel filters from CMS and using these inside the destination pages

* fix(BOOK-698): fetch hotel filters from CMS on select hotel page

Approved-by: Bianca Widstam
2026-01-12 12:02:25 +00:00

265 lines
7.5 KiB
TypeScript

import { cache } from "@/utils/cache"
import { serverClient } from "../server"
import type { Country } from "@scandic-hotels/common/constants/country"
import type { Lang } from "@scandic-hotels/common/constants/language"
import type { GetHotelsByCSFilterInput } from "@scandic-hotels/trpc/routers/hotels/input"
import type { GetSavedPaymentCardsInput } from "@scandic-hotels/trpc/routers/user/input"
import type { HotelInput } from "@scandic-hotels/trpc/types/hotel"
import type {
AncillaryPackagesInput,
PackagesInput,
} from "@scandic-hotels/trpc/types/packages"
export const getProfile = cache(async function getMemoizedProfile() {
const caller = await serverClient()
return caller.user.get()
})
export const getBasicProfile = cache(async function getMemoizedBasicProfile() {
const caller = await serverClient()
return caller.user.getBasic()
})
export const getProfileSafely = cache(
async function getMemoizedProfileSafely() {
const caller = await serverClient()
return caller.user.getSafely()
}
)
export const getProfileWithExtendedPartnerData = cache(
async function getMemoizedProfileWithPartnerData() {
const caller = await serverClient()
return caller.user.getWithExtendedPartnerData()
}
)
export const getSavedPaymentCardsSafely = cache(
async function getMemoizedSavedPaymentCardsSafely(
input: GetSavedPaymentCardsInput
) {
const caller = await serverClient()
return caller.user.safePaymentCards(input)
}
)
export const getMembershipLevel = cache(
async function getMemoizedMembershipLevel() {
const caller = await serverClient()
return caller.user.membershipLevel()
}
)
export const getMembershipLevelSafely = cache(
async function getMemoizedMembershipLevelSafely() {
const caller = await serverClient()
return caller.user.safeMembershipLevel()
}
)
export const getMembershipCards = cache(
async function getMemoizedMembershipCards() {
const caller = await serverClient()
return caller.user.membershipCards()
}
)
export const getHotelsByCSFilter = cache(async function getMemoizedHotels(
input: GetHotelsByCSFilterInput
) {
const caller = await serverClient()
return caller.hotel.hotels.byCSFilter.get(input)
})
export const getHotel = cache(async function getMemoizedHotelData(
input: HotelInput
) {
if (!input.isCardOnlyPayment) {
input.isCardOnlyPayment = false
}
const caller = await serverClient()
return caller.hotel.get(input)
})
export const getHotelPage = cache(async function getMemoizedHotelPage() {
const caller = await serverClient()
return caller.contentstack.hotelPage.get()
})
export const getFooter = cache(async function getMemoizedFooter() {
const caller = await serverClient()
return caller.contentstack.base.footer()
})
export const getHeader = cache(async function getMemoizedHeader() {
const caller = await serverClient()
return caller.contentstack.base.header()
})
export const getAncillaryPackages = cache(
async function getMemoizedAncillaryPackages(input: AncillaryPackagesInput) {
const caller = await serverClient()
return caller.hotel.packages.ancillary(input)
}
)
export const getPackages = cache(async function getMemoizedPackages(
input: PackagesInput
) {
const caller = await serverClient()
return caller.hotel.packages.get(input)
})
export const getBookingConfirmation = cache(
async function getMemoizedBookingConfirmation(refId: string) {
const caller = await serverClient()
return caller.booking.get({ refId })
}
)
export const findBooking = cache(async function getMemoizedFindBooking(
confirmationNumber: string,
lastName: string,
firstName: string,
email: string
) {
const caller = await serverClient()
return caller.booking.findBooking({
confirmationNumber,
lastName,
firstName,
email,
})
})
export const getLinkedReservations = cache(
async function getMemoizedLinkedReservations(refId: string) {
const caller = await serverClient()
return caller.booking.linkedReservations({
refId,
})
}
)
export const getCurrentRewards = cache(
async function getMemoizedCurrentRewards() {
const caller = await serverClient()
return caller.contentstack.rewards.current()
}
)
export const getMeetingRooms = cache(
async function getMemoizedMeetingRooms(input: {
hotelId: string
language: Lang
}) {
const caller = await serverClient()
return caller.hotel.meetingRooms(input)
}
)
export const getDestinationOverviewPage = cache(
async function getMemoizedDestinationOverviewPage() {
const caller = await serverClient()
return caller.contentstack.destinationOverviewPage.get()
}
)
export const getDestinationsList = cache(
async function getMemoizedDestinationsList() {
const caller = await serverClient()
return caller.contentstack.destinationOverviewPage.destinations.get()
}
)
export const getDestinationCountryPage = cache(
async function getMemoizedDestinationCountryPage() {
const caller = await serverClient()
return caller.contentstack.destinationCountryPage.get()
}
)
export const getDestinationCityPagesByCountry = cache(
async function getMemoizedDestinationCityPagesByCountry(country: Country) {
const caller = await serverClient()
return caller.contentstack.destinationCountryPage.cityPages({
country,
})
}
)
export const getHotelsByCountry = cache(
async function getMemoizedHotelsByCountry(country: Country) {
const caller = await serverClient()
return caller.hotel.hotels.byCountry.get({
country,
})
}
)
export const getHotelsByCityIdentifier = cache(
async function getMemoizedHotelsByCityIdentifier(cityIdentifier: string) {
const caller = await serverClient()
return caller.hotel.hotels.byCityIdentifier.get({
cityIdentifier,
})
}
)
export const getHotelFilters = cache(async function getMemoizedHotelFilters() {
const caller = await serverClient()
return caller.hotel.filters.get()
})
export const getAllHotelData = cache(async function getMemoizedAllHotelData() {
const caller = await serverClient()
return caller.hotel.hotels.getAllHotelData()
})
export const getDestinationCityPage = cache(
async function getMemoizedDestinationCityPage() {
const caller = await serverClient()
return caller.contentstack.destinationCityPage.get()
}
)
export const getStartPage = cache(async function getMemoizedStartPage() {
const caller = await serverClient()
return caller.contentstack.startPage.get()
})
export const getJobylonFeed = cache(async function getMemoizedJobylonFeed() {
const caller = await serverClient()
return caller.partner.jobylon.feed.get()
})
export const getCampaignPage = cache(async function getMemoizedCampaignPage() {
const caller = await serverClient()
return caller.contentstack.campaignPage.get()
})
export const getCampaignOverviewPage = cache(
async function getMemoizedCampaignOverviewPage() {
const caller = await serverClient()
return caller.contentstack.campaignOverviewPage.get()
}
)
export const getPromoCampaignPage = cache(
async function getMemoizedPromoCampaignPage() {
const caller = await serverClient()
return caller.contentstack.promoCampaignPage.get()
}
)
export const getProfilingConsent = cache(
async function getMemoizedProfilingConsent() {
const caller = await serverClient()
return caller.contentstack.profilingConsent.get()
}
)
export const getUsePointsModal = cache(
async function getMemoizedUsePointsModal() {
const caller = await serverClient()
return caller.contentstack.usePointsModal.get()
}
)