refactor(SW-303): add typing
This commit is contained in:
@@ -30,7 +30,7 @@ const contentBlockActivity = z.object({
|
||||
__typename: z.literal(
|
||||
HotelBlocksTypenameEnum.HotelPageContentUpcomingActivitiesCard
|
||||
),
|
||||
upcoming_activities_card: activityCardSchema.optional(),
|
||||
upcoming_activities_card: activityCardSchema,
|
||||
})
|
||||
|
||||
const contentBlockItem = z.discriminatedUnion("__typename", [
|
||||
@@ -61,3 +61,4 @@ type HotelPageRaw = HotelPageDataRaw["hotel_page"]
|
||||
export type HotelPage = HotelPageRaw
|
||||
|
||||
export type ActivityCard = z.infer<typeof activityCardSchema>
|
||||
export type ContentBlockItem = z.infer<typeof contentBlockItem>
|
||||
|
||||
@@ -21,7 +21,8 @@ import { makeImageVaultImage } from "@/utils/imageVault"
|
||||
import { removeMultipleSlashes } from "@/utils/url"
|
||||
|
||||
import {
|
||||
HotelPageDataRaw,
|
||||
type ContentBlockItem,
|
||||
type HotelPageDataRaw,
|
||||
validateHotelPageSchema,
|
||||
} from "../contentstack/hotelPage/output"
|
||||
import {
|
||||
@@ -212,13 +213,13 @@ export const hotelQueryRouter = router({
|
||||
: []
|
||||
|
||||
const activities = contentstackData?.content
|
||||
? contentstackData.content.map((block: any) => {
|
||||
? contentstackData.content.map((block: ContentBlockItem) => {
|
||||
switch (block.__typename) {
|
||||
case HotelBlocksTypenameEnum.HotelPageContentUpcomingActivitiesCard:
|
||||
return {
|
||||
...block.upcoming_activities_card,
|
||||
background_image: makeImageVaultImage(
|
||||
block.upcoming_activities_card.background_image
|
||||
block.upcoming_activities_card?.background_image
|
||||
),
|
||||
contentPage:
|
||||
block.upcoming_activities_card?.hotel_page_activities_content_pageConnection?.edges.map(
|
||||
|
||||
Reference in New Issue
Block a user