Merged in feat/SW-682-hotel-page-update-navigation-headers (pull request #1193)
feat/SW-682-hotel-page-update-navigation-headers * feat(SW-682): fetch tab values * feat(SW-682): change key name Approved-by: Erik Tiekstra Approved-by: Matilda Landström
This commit is contained in:
@@ -23,6 +23,7 @@ export default function TabNavigation({
|
|||||||
restaurantTitle,
|
restaurantTitle,
|
||||||
hasActivities,
|
hasActivities,
|
||||||
hasFAQ,
|
hasFAQ,
|
||||||
|
tabValues,
|
||||||
}: TabNavigationProps) {
|
}: TabNavigationProps) {
|
||||||
const hash = useHash()
|
const hash = useHash()
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
@@ -37,29 +38,36 @@ export default function TabNavigation({
|
|||||||
const tabLinks: { hash: HotelHashValues; text: string }[] = [
|
const tabLinks: { hash: HotelHashValues; text: string }[] = [
|
||||||
{
|
{
|
||||||
hash: HotelHashValues.overview,
|
hash: HotelHashValues.overview,
|
||||||
text: intl.formatMessage({ id: "Overview" }),
|
text: tabValues?.overview || intl.formatMessage({ id: "Overview" }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hash: HotelHashValues.rooms,
|
hash: HotelHashValues.rooms,
|
||||||
text: intl.formatMessage({ id: "Rooms" }),
|
text: tabValues?.rooms || intl.formatMessage({ id: "Rooms" }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hash: HotelHashValues.restaurant,
|
hash: HotelHashValues.restaurant,
|
||||||
text: intl.formatMessage({ id: restaurantTitle }, { count: 1 }),
|
text:
|
||||||
|
tabValues?.restaurant_bar ||
|
||||||
|
intl.formatMessage({ id: restaurantTitle }, { count: 1 }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hash: HotelHashValues.meetings,
|
hash: HotelHashValues.meetings,
|
||||||
text: intl.formatMessage({ id: "Meetings & Conferences" }),
|
text:
|
||||||
|
tabValues?.conferences_meetings ||
|
||||||
|
intl.formatMessage({ id: "Meetings & Conferences" }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hash: HotelHashValues.wellness,
|
hash: HotelHashValues.wellness,
|
||||||
text: intl.formatMessage({ id: "Wellness & Exercise" }),
|
text:
|
||||||
|
tabValues?.health_wellness ||
|
||||||
|
intl.formatMessage({ id: "Wellness & Exercise" }),
|
||||||
},
|
},
|
||||||
...(hasActivities
|
...(hasActivities
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
hash: HotelHashValues.activities,
|
hash: HotelHashValues.activities,
|
||||||
text: intl.formatMessage({ id: "Activities" }),
|
text:
|
||||||
|
tabValues?.activities || intl.formatMessage({ id: "Activities" }),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
@@ -67,7 +75,7 @@ export default function TabNavigation({
|
|||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
hash: HotelHashValues.faq,
|
hash: HotelHashValues.faq,
|
||||||
text: intl.formatMessage({ id: "FAQ" }),
|
text: tabValues?.faq || intl.formatMessage({ id: "FAQ" }),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export default async function HotelPage({ hotelId }: HotelPageProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const jsonSchema = generateHotelSchema(hotelData.data.attributes)
|
const jsonSchema = generateHotelSchema(hotelData.data.attributes)
|
||||||
const { faq, content } = hotelPageData
|
const { faq, content, tabValues } = hotelPageData
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
address,
|
address,
|
||||||
@@ -142,6 +142,7 @@ export default async function HotelPage({ hotelId }: HotelPageProps) {
|
|||||||
restaurantTitle={getRestaurantHeading(detailedFacilities)}
|
restaurantTitle={getRestaurantHeading(detailedFacilities)}
|
||||||
hasActivities={activitiesCards.length > 0}
|
hasActivities={activitiesCards.length > 0}
|
||||||
hasFAQ={!!faq.accordions.length}
|
hasFAQ={!!faq.accordions.length}
|
||||||
|
tabValues={tabValues}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<main className={styles.mainSection}>
|
<main className={styles.mainSection}>
|
||||||
|
|||||||
@@ -19,6 +19,16 @@ query GetHotelPage($locale: String!, $uid: String!) {
|
|||||||
hotel_page_id
|
hotel_page_id
|
||||||
title
|
title
|
||||||
url
|
url
|
||||||
|
hotel_navigation {
|
||||||
|
overview
|
||||||
|
rooms
|
||||||
|
restaurant_bar
|
||||||
|
conferences_meetings
|
||||||
|
health_wellness
|
||||||
|
activities
|
||||||
|
offers
|
||||||
|
faq
|
||||||
|
}
|
||||||
faq {
|
faq {
|
||||||
__typename
|
__typename
|
||||||
title
|
title
|
||||||
|
|||||||
@@ -36,38 +36,55 @@ export const contentBlock = z.discriminatedUnion("__typename", [
|
|||||||
])
|
])
|
||||||
|
|
||||||
export const hotelPageSchema = z.object({
|
export const hotelPageSchema = z.object({
|
||||||
hotel_page: z.object({
|
hotel_page: z
|
||||||
content: discriminatedUnionArray(contentBlock.options)
|
.object({
|
||||||
.nullable()
|
hotel_navigation: z
|
||||||
.transform((data) => {
|
.object({
|
||||||
let spaPage: SpaPage | undefined
|
overview: z.string().optional(),
|
||||||
let activitiesCards: ActivitiesCard[] = []
|
rooms: z.string().optional(),
|
||||||
|
restaurant_bar: z.string().optional(),
|
||||||
data?.map((block) => {
|
conferences_meetings: z.string().optional(),
|
||||||
switch (block.typename) {
|
health_wellness: z.string().optional(),
|
||||||
case HotelPageEnum.ContentStack.blocks.ActivitiesCard:
|
activities: z.string().optional(),
|
||||||
activitiesCards.push(block)
|
offers: z.string().optional(),
|
||||||
break
|
faq: z.string().optional(),
|
||||||
case HotelPageEnum.ContentStack.blocks.SpaPage:
|
|
||||||
spaPage = block
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return { spaPage, activitiesCards }
|
.nullable(),
|
||||||
}),
|
content: discriminatedUnionArray(contentBlock.options)
|
||||||
faq: hotelFaqSchema,
|
.nullable()
|
||||||
hotel_page_id: z.string(),
|
.transform((data) => {
|
||||||
title: z.string(),
|
let spaPage: SpaPage | undefined
|
||||||
url: z.string(),
|
let activitiesCards: ActivitiesCard[] = []
|
||||||
system: systemSchema.merge(
|
|
||||||
z.object({
|
data?.map((block) => {
|
||||||
created_at: z.string(),
|
switch (block.typename) {
|
||||||
updated_at: z.string(),
|
case HotelPageEnum.ContentStack.blocks.ActivitiesCard:
|
||||||
})
|
activitiesCards.push(block)
|
||||||
),
|
break
|
||||||
}),
|
case HotelPageEnum.ContentStack.blocks.SpaPage:
|
||||||
|
spaPage = block
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return { spaPage, activitiesCards }
|
||||||
|
}),
|
||||||
|
faq: hotelFaqSchema,
|
||||||
|
hotel_page_id: z.string(),
|
||||||
|
title: z.string(),
|
||||||
|
url: z.string(),
|
||||||
|
system: systemSchema.merge(
|
||||||
|
z.object({
|
||||||
|
created_at: z.string(),
|
||||||
|
updated_at: z.string(),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
})
|
||||||
|
.transform(({ hotel_navigation, ...rest }) => ({
|
||||||
|
tabValues: hotel_navigation,
|
||||||
|
...rest,
|
||||||
|
})),
|
||||||
})
|
})
|
||||||
|
|
||||||
/** REFS */
|
/** REFS */
|
||||||
|
|||||||
@@ -8,8 +8,20 @@ export enum HotelHashValues {
|
|||||||
faq = "faq",
|
faq = "faq",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Tabs = {
|
||||||
|
overview?: string
|
||||||
|
rooms?: string
|
||||||
|
restaurant_bar?: string
|
||||||
|
conferences_meetings?: string
|
||||||
|
health_wellness?: string
|
||||||
|
activities?: string
|
||||||
|
offers?: string
|
||||||
|
faq?: string
|
||||||
|
}
|
||||||
|
|
||||||
export type TabNavigationProps = {
|
export type TabNavigationProps = {
|
||||||
restaurantTitle: string
|
restaurantTitle: string
|
||||||
hasActivities: boolean
|
hasActivities: boolean
|
||||||
hasFAQ: boolean
|
hasFAQ: boolean
|
||||||
|
tabValues?: Tabs | null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user