Merge branch 'develop' into feature/tracking

This commit is contained in:
Linus Flood
2024-10-08 15:13:16 +02:00
178 changed files with 3745 additions and 1291 deletions

View File

@@ -6,7 +6,7 @@ export namespace endpoints {
profile = "profile/v0/Profile",
}
export const enum v1 {
availability = "availability/v1/availabilities/city",
hotelsAvailability = "availability/v1/availabilities/city",
profile = "profile/v1/Profile",
booking = "booking/v1/Bookings",
creditCards = `${profile}/creditCards`,
@@ -21,6 +21,7 @@ export namespace endpoints {
upcomingStays = "booking/v1/Stays/future",
rewards = `${profile}/reward`,
tierRewards = `${profile}/TierRewards`,
subscriberId = `${profile}/SubscriberId`,
}
}

View File

@@ -21,7 +21,7 @@ import type {
* is an Interface e.g).
*/
export function discriminatedUnion<T extends Option>(options: T[]) {
export function discriminatedUnion<R>(options: Option[]) {
return z
.discriminatedUnion("__typename", [
z.object({ __typename: z.literal(undefined) }),
@@ -37,6 +37,12 @@ export function discriminatedUnion<T extends Option>(options: T[]) {
}
throw new Error(error.message)
})
.transform((data) => {
if (data.__typename === "undefined" || data.__typename === undefined) {
return null
}
return data as R
})
}
export function discriminatedUnionArray<T extends Option>(options: T[]) {

View File

@@ -1,11 +1,13 @@
#import "../../Fragments/PageLink/ContentPageLink.graphql"
query GetHotelPage($locale: String!, $uid: String!) {
hotel_page(locale: $locale, uid: $uid) {
hotel_page_id
title
url
content {
__typename
... on HotelPageContentUpcomingActivitiesCard {
__typename
upcoming_activities_card {
background_image
cta_text
@@ -16,15 +18,8 @@ query GetHotelPage($locale: String!, $uid: String!) {
hotel_page_activities_content_pageConnection {
edges {
node {
... on ContentPage {
url
web {
original_url
}
system {
locale
}
}
__typename
...ContentPageLink
}
}
}

View File

@@ -10,6 +10,12 @@ export const getProfile = cache(async function getMemoizedProfile() {
return serverClient().user.get()
})
export const getProfileSafely = cache(
async function getMemoizedProfileSafely() {
return serverClient().user.getSafely()
}
)
export const getFooter = cache(async function getMemoizedFooter() {
return serverClient().contentstack.base.footer()
})