refactor(SW-303): refactoring
This commit is contained in:
@@ -26,22 +26,23 @@ export const activityCardSchema = z.object({
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const contentBlockActivity = z.object({
|
||||||
|
__typename: z.literal(
|
||||||
|
HotelBlocksTypenameEnum.HotelPageContentUpcomingActivitiesCard
|
||||||
|
),
|
||||||
|
upcoming_activities_card: activityCardSchema.optional(),
|
||||||
|
})
|
||||||
|
|
||||||
|
const contentBlockItem = z.discriminatedUnion("__typename", [
|
||||||
|
contentBlockActivity,
|
||||||
|
])
|
||||||
|
|
||||||
export const validateHotelPageSchema = z.object({
|
export const validateHotelPageSchema = 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(),
|
||||||
url: z.string(),
|
url: z.string(),
|
||||||
content: z
|
content: z.array(contentBlockItem).nullable(),
|
||||||
.array(
|
|
||||||
z.object({
|
|
||||||
__typename: z.literal(
|
|
||||||
HotelBlocksTypenameEnum.HotelPageContentUpcomingActivitiesCard
|
|
||||||
),
|
|
||||||
upcoming_activities_card: activityCardSchema.optional(),
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.nullable()
|
|
||||||
.optional(),
|
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ const availabilityFailCounter = meter.createCounter(
|
|||||||
"trpc.hotel.availability-fail"
|
"trpc.hotel.availability-fail"
|
||||||
)
|
)
|
||||||
|
|
||||||
async function getContenstackData(
|
async function getContentstackData(
|
||||||
locale: string,
|
locale: string,
|
||||||
uid: string | null | undefined
|
uid: string | null | undefined
|
||||||
) {
|
) {
|
||||||
@@ -90,7 +90,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 contentstackData = await getContentstackData(lang, uid)
|
||||||
const hotelId = contentstackData?.hotel_page_id
|
const hotelId = contentstackData?.hotel_page_id
|
||||||
|
|
||||||
if (!hotelId) {
|
if (!hotelId) {
|
||||||
|
|||||||
@@ -39,9 +39,6 @@ export function getTheme(theme: CardProps["theme"]) {
|
|||||||
secondaryLinkColor = "burgundy"
|
secondaryLinkColor = "burgundy"
|
||||||
break
|
break
|
||||||
case "primaryStrong":
|
case "primaryStrong":
|
||||||
buttonTheme = "primaryStrong"
|
|
||||||
primaryLinkColor = "red"
|
|
||||||
secondaryLinkColor = "white"
|
|
||||||
case "image":
|
case "image":
|
||||||
buttonTheme = "primaryStrong"
|
buttonTheme = "primaryStrong"
|
||||||
primaryLinkColor = "red"
|
primaryLinkColor = "red"
|
||||||
|
|||||||
Reference in New Issue
Block a user