chore: Cleanup scandic-web * Remove unused files * Remove unused and add missing packages * Remove unused exports Approved-by: Linus Flood
235 lines
6.6 KiB
TypeScript
235 lines
6.6 KiB
TypeScript
import { cache } from "@/utils/cache"
|
|
|
|
import { serverClient } from "../server"
|
|
|
|
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 { Country } from "@scandic-hotels/trpc/types/country"
|
|
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 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 getDestinationsMapData = cache(
|
|
async function getMemoizedDestinationsMapData() {
|
|
const caller = await serverClient()
|
|
return caller.hotel.hotels.getDestinationsMapData()
|
|
}
|
|
)
|
|
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()
|
|
}
|
|
)
|