Merge master

This commit is contained in:
Linus Flood
2024-11-28 13:37:45 +01:00
225 changed files with 4488 additions and 3192 deletions

View File

@@ -59,6 +59,9 @@ export namespace endpoints {
export function status(confirmationNumber: string) {
return `${bookings}/${confirmationNumber}/status`
}
export function priceChange(confirmationNumber: string) {
return `${bookings}/${confirmationNumber}/priceChange`
}
export const enum Stays {
future = `${base.path.booking}/${version}/${base.enitity.Stays}/future`,

View File

@@ -34,13 +34,7 @@ export async function get(
) {
const url = new URL(env.API_BASEURL)
url.pathname = endpoint
const searchParams = new URLSearchParams(params)
if (searchParams.size) {
searchParams.forEach((value, key) => {
url.searchParams.append(key, value)
})
url.searchParams.sort()
}
url.search = new URLSearchParams(params).toString()
return wrappedFetch(
url,
merge.all([defaultOptions, { method: "GET" }, options])
@@ -55,13 +49,7 @@ export async function patch(
const { body, ...requestOptions } = options
const url = new URL(env.API_BASEURL)
url.pathname = endpoint
const searchParams = new URLSearchParams(params)
if (searchParams.size) {
searchParams.forEach((value, key) => {
url.searchParams.set(key, value)
})
url.searchParams.sort()
}
url.search = new URLSearchParams(params).toString()
return wrappedFetch(
url,
merge.all([
@@ -80,13 +68,7 @@ export async function post(
const { body, ...requestOptions } = options
const url = new URL(env.API_BASEURL)
url.pathname = endpoint
const searchParams = new URLSearchParams(params)
if (searchParams.size) {
searchParams.forEach((value, key) => {
url.searchParams.set(key, value)
})
url.searchParams.sort()
}
url.search = new URLSearchParams(params).toString()
return wrappedFetch(
url,
merge.all([
@@ -97,6 +79,25 @@ export async function post(
)
}
export async function put(
endpoint: Endpoint | `${Endpoint}/${string}`,
options: RequestOptionsWithJSONBody,
params = {}
) {
const { body, ...requestOptions } = options
const url = new URL(env.API_BASEURL)
url.pathname = endpoint
url.search = new URLSearchParams(params).toString()
return wrappedFetch(
url,
merge.all([
defaultOptions,
{ body: JSON.stringify(body), method: "PUT" },
requestOptions,
])
)
}
export async function remove(
endpoint: Endpoint | `${Endpoint}/${string}`,
options: RequestOptionsWithOutBody,
@@ -104,13 +105,7 @@ export async function remove(
) {
const url = new URL(env.API_BASEURL)
url.pathname = endpoint
const searchParams = new URLSearchParams(params)
if (searchParams.size) {
searchParams.forEach((value, key) => {
url.searchParams.set(key, value)
})
url.searchParams.sort()
}
url.search = new URLSearchParams(params).toString()
return wrappedFetch(
url,
merge.all([defaultOptions, { method: "DELETE" }, options])

View File

@@ -0,0 +1,19 @@
#import "../../Fragments/Metadata.graphql"
#import "../../Fragments/System.graphql"
query GetHotelPageMetadata($locale: String!, $uid: String!) {
hotel_page(locale: $locale, uid: $uid) {
hotel_page_id
web {
breadcrumbs {
title
}
seo_metadata {
...Metadata
}
}
system {
...System
}
}
}

View File

@@ -1,10 +1,6 @@
import { cache } from "react"
import { Lang } from "@/constants/languages"
import {
GetRoomsAvailabilityInput,
GetSelectedRoomAvailabilityInput,
} from "@/server/routers/hotels/input"
import { cache } from "@/utils/cache"
import { serverClient } from "../server"
@@ -12,6 +8,12 @@ import type {
BreackfastPackagesInput,
PackagesInput,
} from "@/types/requests/packages"
import type {
GetRoomsAvailabilityInput,
GetSelectedRoomAvailabilityInput,
HotelDataInput,
} from "@/server/routers/hotels/input"
import type { GetSavedPaymentCardsInput } from "@/server/routers/user/input"
export const getLocations = cache(async function getMemoizedLocations() {
return serverClient().hotel.locations.get()
@@ -31,9 +33,11 @@ export const getProfileSafely = cache(
}
)
export const getCreditCardsSafely = cache(
async function getMemoizedCreditCardsSafely() {
return serverClient().user.safeCreditCards()
export const getSavedPaymentCardsSafely = cache(
async function getMemoizedSavedPaymentCardsSafely(
args: GetSavedPaymentCardsInput
) {
return serverClient().user.safePaymentCards(args)
}
)
@@ -59,46 +63,24 @@ export const getUserTracking = cache(async function getMemoizedUserTracking() {
return serverClient().user.tracking()
})
export const getHotelData = cache(async function getMemoizedHotelData({
hotelId,
language,
isCardOnlyPayment,
}: {
hotelId: string
language: string
isCardOnlyPayment?: boolean
}) {
return serverClient().hotel.hotelData.get({
hotelId,
language,
isCardOnlyPayment,
})
export const getHotelData = cache(async function getMemoizedHotelData(
input: HotelDataInput
) {
return serverClient().hotel.hotelData.get(input)
})
export const getRoomAvailability = cache(
async function getMemoizedRoomAvailability({
hotelId,
adults,
roomStayStartDate,
roomStayEndDate,
children,
bookingCode,
rateCode,
}: GetRoomsAvailabilityInput) {
return serverClient().hotel.availability.rooms({
hotelId,
adults,
roomStayStartDate,
roomStayEndDate,
children,
bookingCode,
rateCode,
})
export const getHotelPage = cache(async function getMemoizedHotelPage() {
return serverClient().contentstack.hotelPage.get()
})
export const getRoomsAvailability = cache(
async function getMemoizedRoomAvailability(input: GetRoomsAvailabilityInput) {
return serverClient().hotel.availability.rooms(input)
}
)
export const getSelectedRoomAvailability = cache(
async function getMemoizedRoomAvailability(
function getMemoizedSelectedRoomAvailability(
args: GetSelectedRoomAvailabilityInput
) {
return serverClient().hotel.availability.room(args)
@@ -141,13 +123,13 @@ export const getSiteConfig = cache(async function getMemoizedSiteConfig() {
return serverClient().contentstack.base.siteConfig()
})
export const getBreakfastPackages = cache(async function getMemoizedPackages(
export const getBreakfastPackages = cache(function getMemoizedBreakfastPackages(
input: BreackfastPackagesInput
) {
return serverClient().hotel.packages.breakfast(input)
})
export const getPackages = cache(async function getMemoizedPackages(
export const getPackages = cache(function getMemoizedPackages(
input: PackagesInput
) {
return serverClient().hotel.packages.get(input)
@@ -160,7 +142,10 @@ export const getBookingConfirmation = cache(
)
export const getCityCoordinates = cache(
async function getMemoizedCityCoordinates(input: { city: string }) {
async function getMemoizedCityCoordinates(input: {
city: string
hotel: { address: string }
}) {
return serverClient().hotel.map.city(input)
}
)