fix: clean up hotel and its typings

This commit is contained in:
Simon Emanuelsson
2024-12-17 16:17:25 +01:00
parent ec74af8814
commit 13a164242f
110 changed files with 1931 additions and 1559 deletions

View File

@@ -6,12 +6,15 @@ import type {
BreackfastPackagesInput,
PackagesInput,
} from "@/types/requests/packages"
import type {
CityCoordinatesInput,
HotelInput,
} from "@/types/trpc/routers/hotel/hotel"
import type { Lang } from "@/constants/languages"
import type {
GetHotelsInput,
GetRoomsAvailabilityInput,
GetSelectedRoomAvailabilityInput,
HotelDataInput,
} from "@/server/routers/hotels/input"
import type { GetSavedPaymentCardsInput } from "@/server/routers/user/input"
@@ -35,9 +38,9 @@ export const getProfileSafely = cache(
export const getSavedPaymentCardsSafely = cache(
async function getMemoizedSavedPaymentCardsSafely(
args: GetSavedPaymentCardsInput
input: GetSavedPaymentCardsInput
) {
return serverClient().user.safePaymentCards(args)
return serverClient().user.safePaymentCards(input)
}
)
@@ -69,10 +72,13 @@ export const getHotels = cache(async function getMemoizedHotels(
return serverClient().hotel.hotels.get(input)
})
export const getHotelData = cache(async function getMemoizedHotelData(
input: HotelDataInput
export const getHotel = cache(async function getMemoizedHotelData(
input: HotelInput
) {
return serverClient().hotel.hotelData.get(input)
if (!input.isCardOnlyPayment) {
input.isCardOnlyPayment = false
}
return serverClient().hotel.get(input)
})
export const getHotelPage = cache(async function getMemoizedHotelPage() {
@@ -87,9 +93,9 @@ export const getRoomsAvailability = cache(
export const getSelectedRoomAvailability = cache(
function getMemoizedSelectedRoomAvailability(
args: GetSelectedRoomAvailabilityInput
input: GetSelectedRoomAvailabilityInput
) {
return serverClient().hotel.availability.room(args)
return serverClient().hotel.availability.room(input)
}
)
@@ -129,29 +135,26 @@ export const getSiteConfig = cache(async function getMemoizedSiteConfig() {
return serverClient().contentstack.base.siteConfig()
})
export const getBreakfastPackages = cache(function getMemoizedBreakfastPackages(
input: BreackfastPackagesInput
) {
return serverClient().hotel.packages.breakfast(input)
})
export const getBreakfastPackages = cache(
async function getMemoizedBreakfastPackages(input: BreackfastPackagesInput) {
return serverClient().hotel.packages.breakfast(input)
}
)
export const getPackages = cache(function getMemoizedPackages(
export const getPackages = cache(async function getMemoizedPackages(
input: PackagesInput
) {
return serverClient().hotel.packages.get(input)
})
export const getBookingConfirmation = cache(
function getMemoizedBookingConfirmation(confirmationNumber: string) {
async function getMemoizedBookingConfirmation(confirmationNumber: string) {
return serverClient().booking.confirmation({ confirmationNumber })
}
)
export const getCityCoordinates = cache(
async function getMemoizedCityCoordinates(input: {
city: string
hotel: { address: string | undefined }
}) {
async function getMemoizedCityCoordinates(input: CityCoordinatesInput) {
return serverClient().hotel.map.city(input)
}
)