Revert "chore(SW-303): fetch activity card from CS"
This reverts commit dde9ca190a.
This commit is contained in:
@@ -141,4 +141,19 @@ export const MOCK_FACILITIES: Facilities = [
|
|||||||
columnSpan: "one",
|
columnSpan: "one",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
id: "activities",
|
||||||
|
theme: "primaryDark",
|
||||||
|
scriptedTopTitle: "Activities",
|
||||||
|
heading: "Upcoming activities at DownTown Camper",
|
||||||
|
bodyText: "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
|
||||||
|
secondaryButton: {
|
||||||
|
href: `?s=${activities[lang]}`,
|
||||||
|
title: "Discover activities",
|
||||||
|
isExternal: false,
|
||||||
|
},
|
||||||
|
columnSpan: "three",
|
||||||
|
},
|
||||||
|
],
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
import type { Facility } from "@/types/components/hotelPage/facilities"
|
|
||||||
import type { ImageVaultAsset } from "@/types/components/imageVault"
|
|
||||||
|
|
||||||
type ActivityCard = {
|
|
||||||
background_image?: ImageVaultAsset
|
|
||||||
scripted_title?: string
|
|
||||||
heading: string
|
|
||||||
body_text: string
|
|
||||||
cta_text: string
|
|
||||||
contentPage: Array<{ href: string }>
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setActivityCard(activitiesCard: ActivityCard): Facility {
|
|
||||||
const hasImage = activitiesCard.background_image
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
id: "activities",
|
|
||||||
theme: hasImage ? "image" : "primaryDark",
|
|
||||||
scriptedTopTitle: activitiesCard.scripted_title,
|
|
||||||
heading: activitiesCard.heading,
|
|
||||||
bodyText: activitiesCard.body_text,
|
|
||||||
backgroundImage: hasImage ? activitiesCard.background_image : undefined,
|
|
||||||
primaryButton: hasImage
|
|
||||||
? {
|
|
||||||
href: activitiesCard.contentPage[0].href,
|
|
||||||
title: activitiesCard.cta_text,
|
|
||||||
isExternal: false,
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
secondaryButton: hasImage
|
|
||||||
? undefined
|
|
||||||
: {
|
|
||||||
href: activitiesCard.contentPage[0].href,
|
|
||||||
title: activitiesCard.cta_text,
|
|
||||||
isExternal: false,
|
|
||||||
},
|
|
||||||
columnSpan: "three",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getCardTheme() {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,6 @@ export default function TabNavigation() {
|
|||||||
const hash = useHash()
|
const hash = useHash()
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const hotelTabLinks: { href: HotelHashValues; text: string }[] = [
|
const hotelTabLinks: { href: HotelHashValues; text: string }[] = [
|
||||||
// TODO these titles will need to reflect the facility card titles, which will vary between hotels
|
|
||||||
{ href: HotelHashValues.overview, text: "Overview" },
|
{ href: HotelHashValues.overview, text: "Overview" },
|
||||||
{ href: HotelHashValues.rooms, text: "Rooms" },
|
{ href: HotelHashValues.rooms, text: "Rooms" },
|
||||||
{ href: HotelHashValues.restaurant, text: "Restaurant & Bar" },
|
{ href: HotelHashValues.restaurant, text: "Restaurant & Bar" },
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { serverClient } from "@/lib/trpc/server"
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
|
|
||||||
import { MOCK_FACILITIES } from "./Facilities/mockData"
|
import { MOCK_FACILITIES } from "./Facilities/mockData"
|
||||||
import { setActivityCard } from "./Facilities/utils"
|
|
||||||
import AmenitiesList from "./AmenitiesList"
|
import AmenitiesList from "./AmenitiesList"
|
||||||
import Facilities from "./Facilities"
|
import Facilities from "./Facilities"
|
||||||
import IntroSection from "./IntroSection"
|
import IntroSection from "./IntroSection"
|
||||||
@@ -29,11 +28,8 @@ export default async function HotelPage() {
|
|||||||
hotelDetailedFacilities,
|
hotelDetailedFacilities,
|
||||||
hotelImages,
|
hotelImages,
|
||||||
roomCategories,
|
roomCategories,
|
||||||
activitiesCard,
|
|
||||||
} = hotelData
|
} = hotelData
|
||||||
|
|
||||||
MOCK_FACILITIES.push(setActivityCard(activitiesCard))
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.pageContainer}>
|
<div className={styles.pageContainer}>
|
||||||
<div className={styles.topSection}>
|
<div className={styles.topSection}>
|
||||||
|
|||||||
@@ -3,34 +3,6 @@ query GetHotelPage($locale: String!, $uid: String!) {
|
|||||||
hotel_page_id
|
hotel_page_id
|
||||||
url
|
url
|
||||||
title
|
title
|
||||||
content {
|
|
||||||
... on HotelPageContentUpcomingActivitiesCard {
|
|
||||||
__typename
|
|
||||||
upcoming_activities_card {
|
|
||||||
background_image
|
|
||||||
cta_text
|
|
||||||
heading
|
|
||||||
body_text
|
|
||||||
open_in_new_tab
|
|
||||||
scripted_title
|
|
||||||
hotel_page_activities_content_pageConnection {
|
|
||||||
edges {
|
|
||||||
node {
|
|
||||||
... on ContentPage {
|
|
||||||
url
|
|
||||||
web {
|
|
||||||
original_url
|
|
||||||
}
|
|
||||||
system {
|
|
||||||
locale
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { HotelBlocksTypenameEnum } from "@/types/components/hotelPage/enums"
|
|
||||||
|
|
||||||
export const activityCardSchema = z.object({
|
|
||||||
background_image: z.any(),
|
|
||||||
cta_text: z.string(),
|
|
||||||
heading: z.string(),
|
|
||||||
open_in_new_tab: z.boolean(),
|
|
||||||
scripted_title: z.string().optional(),
|
|
||||||
body_text: z.string(),
|
|
||||||
hotel_page_activities_content_pageConnection: z.object({
|
|
||||||
edges: z.array(
|
|
||||||
z.object({
|
|
||||||
node: z.object({
|
|
||||||
url: z.string(),
|
|
||||||
web: z.object({
|
|
||||||
original_url: z.string().optional(),
|
|
||||||
}),
|
|
||||||
system: z.object({
|
|
||||||
locale: z.string(),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const validateHotelPageSchema = z.object({
|
export const validateHotelPageSchema = z.object({
|
||||||
hotel_page: z.object({
|
|
||||||
hotel_page_id: z.string(),
|
|
||||||
title: z.string(),
|
|
||||||
url: z.string(),
|
|
||||||
content: z
|
|
||||||
.array(
|
|
||||||
z.object({
|
|
||||||
__typename: z.literal(
|
|
||||||
HotelBlocksTypenameEnum.HotelPageContentUpcomingActivitiesCard
|
|
||||||
),
|
|
||||||
upcoming_activities_card: activityCardSchema.optional(),
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.optional(),
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const hotelPageSchema = z.object({
|
|
||||||
hotel_page: z.object({
|
hotel_page: z.object({
|
||||||
hotel_page_id: z.string(),
|
hotel_page_id: z.string(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
@@ -56,6 +12,5 @@ export const hotelPageSchema = z.object({
|
|||||||
export type HotelPageDataRaw = z.infer<typeof validateHotelPageSchema>
|
export type HotelPageDataRaw = z.infer<typeof validateHotelPageSchema>
|
||||||
|
|
||||||
type HotelPageRaw = HotelPageDataRaw["hotel_page"]
|
type HotelPageRaw = HotelPageDataRaw["hotel_page"]
|
||||||
export type HotelPage = HotelPageRaw
|
|
||||||
|
|
||||||
export type ActivityCard = z.infer<typeof activityCardSchema>
|
export type HotelPage = HotelPageRaw
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ import {
|
|||||||
} from "@/server/trpc"
|
} from "@/server/trpc"
|
||||||
import { toApiLang } from "@/server/utils"
|
import { toApiLang } from "@/server/utils"
|
||||||
|
|
||||||
import { makeImageVaultImage } from "@/utils/imageVault"
|
|
||||||
import { removeMultipleSlashes } from "@/utils/url"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
HotelPageDataRaw,
|
HotelPageDataRaw,
|
||||||
validateHotelPageSchema,
|
validateHotelPageSchema,
|
||||||
@@ -40,7 +37,6 @@ import {
|
|||||||
import tempFilterData from "./tempFilterData.json"
|
import tempFilterData from "./tempFilterData.json"
|
||||||
import tempRatesData from "./tempRatesData.json"
|
import tempRatesData from "./tempRatesData.json"
|
||||||
|
|
||||||
import { HotelBlocksTypenameEnum } from "@/types/components/hotelPage/enums"
|
|
||||||
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
|
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
|
||||||
|
|
||||||
const meter = metrics.getMeter("trpc.hotels")
|
const meter = metrics.getMeter("trpc.hotels")
|
||||||
@@ -56,10 +52,7 @@ const availabilityFailCounter = meter.createCounter(
|
|||||||
"trpc.hotel.availability-fail"
|
"trpc.hotel.availability-fail"
|
||||||
)
|
)
|
||||||
|
|
||||||
async function getContenstackData(
|
async function getHotelId(locale: string, uid: string | null | undefined) {
|
||||||
locale: string,
|
|
||||||
uid: string | null | undefined
|
|
||||||
) {
|
|
||||||
const rawContentStackData = await request<HotelPageDataRaw>(GetHotelPage, {
|
const rawContentStackData = await request<HotelPageDataRaw>(GetHotelPage, {
|
||||||
locale,
|
locale,
|
||||||
uid,
|
uid,
|
||||||
@@ -81,7 +74,7 @@ async function getContenstackData(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return hotelPageData.data.hotel_page
|
return hotelPageData.data.hotel_page.hotel_page_id
|
||||||
}
|
}
|
||||||
|
|
||||||
export const hotelQueryRouter = router({
|
export const hotelQueryRouter = router({
|
||||||
@@ -90,8 +83,7 @@ export const hotelQueryRouter = router({
|
|||||||
.query(async ({ ctx, input }) => {
|
.query(async ({ ctx, input }) => {
|
||||||
const { lang, uid } = ctx
|
const { lang, uid } = ctx
|
||||||
const { include } = input
|
const { include } = input
|
||||||
const contentstackData = await getContenstackData(lang, uid)
|
const hotelId = await getHotelId(lang, uid)
|
||||||
const hotelId = contentstackData?.hotel_page_id
|
|
||||||
|
|
||||||
if (!hotelId) {
|
if (!hotelId) {
|
||||||
throw notFound(`Hotel not found for uid: ${uid}`)
|
throw notFound(`Hotel not found for uid: ${uid}`)
|
||||||
@@ -211,32 +203,6 @@ export const hotelQueryRouter = router({
|
|||||||
})
|
})
|
||||||
: []
|
: []
|
||||||
|
|
||||||
const activities = contentstackData?.content
|
|
||||||
? contentstackData.content.map((block: any) => {
|
|
||||||
switch (block.__typename) {
|
|
||||||
case HotelBlocksTypenameEnum.HotelPageContentUpcomingActivitiesCard:
|
|
||||||
return {
|
|
||||||
...block.upcoming_activities_card,
|
|
||||||
background_image: makeImageVaultImage(
|
|
||||||
block.upcoming_activities_card.background_image
|
|
||||||
),
|
|
||||||
contentPage:
|
|
||||||
block.upcoming_activities_card?.hotel_page_activities_content_pageConnection?.edges.map(
|
|
||||||
({ node: contentPage }: { node: any }) => {
|
|
||||||
return {
|
|
||||||
href:
|
|
||||||
contentPage.web?.original_url ||
|
|
||||||
removeMultipleSlashes(
|
|
||||||
`/${contentPage.system.locale}/${contentPage.url}`
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})[0]
|
|
||||||
: null
|
|
||||||
|
|
||||||
getHotelSuccessCounter.add(1, { hotelId, lang, include })
|
getHotelSuccessCounter.add(1, { hotelId, lang, include })
|
||||||
console.info(
|
console.info(
|
||||||
"api.hotels.hotel success",
|
"api.hotels.hotel success",
|
||||||
@@ -253,7 +219,6 @@ export const hotelQueryRouter = router({
|
|||||||
hotelDetailedFacilities: hotelAttributes.detailedFacilities,
|
hotelDetailedFacilities: hotelAttributes.detailedFacilities,
|
||||||
hotelImages: images,
|
hotelImages: images,
|
||||||
roomCategories,
|
roomCategories,
|
||||||
activitiesCard: activities,
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
availability: router({
|
availability: router({
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
export enum HotelBlocksTypenameEnum {
|
|
||||||
HotelPageContentUpcomingActivitiesCard = "HotelPageContentUpcomingActivitiesCard",
|
|
||||||
}
|
|
||||||
@@ -38,11 +38,7 @@ export function getTheme(theme: CardProps["theme"]) {
|
|||||||
primaryLinkColor = "pale"
|
primaryLinkColor = "pale"
|
||||||
secondaryLinkColor = "burgundy"
|
secondaryLinkColor = "burgundy"
|
||||||
break
|
break
|
||||||
case "primaryStrong":
|
case "primaryStrong" || "image":
|
||||||
buttonTheme = "primaryStrong"
|
|
||||||
primaryLinkColor = "red"
|
|
||||||
secondaryLinkColor = "white"
|
|
||||||
case "image":
|
|
||||||
buttonTheme = "primaryStrong"
|
buttonTheme = "primaryStrong"
|
||||||
primaryLinkColor = "red"
|
primaryLinkColor = "red"
|
||||||
secondaryLinkColor = "white"
|
secondaryLinkColor = "white"
|
||||||
|
|||||||
Reference in New Issue
Block a user