* feat(BOOK-257): Added VideoPlayer with card component * feat(BOOK-257): Added queries and component for VideoCard block to Content and Collection pages * fix(BOOK-257): Only setting object-fit: cover on the video if it is not fullscreen * feat(BOOK-257): Added queries and component for VideoCard block to Startpage * feat(BOOK-257): Added queries and component for Video block to content/collection/start page Approved-by: Chuma Mcphoy (We Ahead)
149 lines
3.9 KiB
TypeScript
149 lines
3.9 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { transformedImageVaultAssetSchema } from "@scandic-hotels/common/utils/imageVault"
|
|
|
|
import { discriminatedUnionArray } from "../../../utils/discriminatedUnion"
|
|
import {
|
|
cardGridRefsSchema,
|
|
cardsGridSchema,
|
|
} from "../schemas/blocks/cardsGrid"
|
|
import {
|
|
carouselCardsRefsSchema,
|
|
carouselCardsSchema,
|
|
} from "../schemas/blocks/carouselCards"
|
|
import {
|
|
fullWidthCampaignBlockRefsSchema,
|
|
fullWidthCampaignBlockSchema,
|
|
} from "../schemas/blocks/fullWidthCampaign"
|
|
import {
|
|
joinScandicFriendsBlockRefsSchema,
|
|
joinScandicFriendsBlockSchema,
|
|
} from "../schemas/blocks/joinScandicFriends"
|
|
import { videoBlockRefsSchema, videoBlockSchema } from "../schemas/blocks/video"
|
|
import {
|
|
videoCardRefsSchema,
|
|
videoCardSchema,
|
|
} from "../schemas/blocks/videoCard"
|
|
import { systemSchema } from "../schemas/system"
|
|
import { StartPageEnum } from "./utils"
|
|
|
|
const startPageCards = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.CardsGrid),
|
|
})
|
|
.merge(cardsGridSchema)
|
|
|
|
const startPageCarouselCards = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.CarouselCards),
|
|
})
|
|
.merge(carouselCardsSchema)
|
|
|
|
const startPageFullWidthCampaign = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.FullWidthCampaign),
|
|
})
|
|
.merge(fullWidthCampaignBlockSchema)
|
|
|
|
const startPageJoinScandicFriends = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.JoinScandicFriends),
|
|
})
|
|
.merge(joinScandicFriendsBlockSchema)
|
|
|
|
const startPageVideoCard = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.VideoCard),
|
|
})
|
|
.merge(videoCardSchema)
|
|
|
|
const startPageVideo = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.Video),
|
|
})
|
|
.merge(videoBlockSchema)
|
|
|
|
export const blocksSchema = z.discriminatedUnion("__typename", [
|
|
startPageCards,
|
|
startPageFullWidthCampaign,
|
|
startPageCarouselCards,
|
|
startPageJoinScandicFriends,
|
|
startPageVideoCard,
|
|
startPageVideo,
|
|
])
|
|
|
|
export const startPageSchema = z.object({
|
|
start_page: z.object({
|
|
title: z.string(),
|
|
header: z.object({
|
|
heading: z.string(),
|
|
hero_image: transformedImageVaultAssetSchema,
|
|
}),
|
|
blocks: discriminatedUnionArray(blocksSchema.options)
|
|
.nullable()
|
|
.transform((val) => val || []),
|
|
system: systemSchema.merge(
|
|
z.object({
|
|
created_at: z.string(),
|
|
updated_at: z.string(),
|
|
})
|
|
),
|
|
}),
|
|
trackingProps: z.object({
|
|
url: z.string(),
|
|
}),
|
|
})
|
|
|
|
/** REFS */
|
|
const startPageCardsRefs = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.CardsGrid),
|
|
})
|
|
.merge(cardGridRefsSchema)
|
|
|
|
const startPageFullWidthCampaignRef = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.FullWidthCampaign),
|
|
})
|
|
.merge(fullWidthCampaignBlockRefsSchema)
|
|
|
|
const startPageCarouselCardsRef = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.CarouselCards),
|
|
})
|
|
.merge(carouselCardsRefsSchema)
|
|
|
|
const startPageJoinScandicFriendsRef = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.JoinScandicFriends),
|
|
})
|
|
.merge(joinScandicFriendsBlockRefsSchema)
|
|
|
|
const startPageVideoCardRef = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.VideoCard),
|
|
})
|
|
.merge(videoCardRefsSchema)
|
|
|
|
const startPageVideoRef = z
|
|
.object({
|
|
__typename: z.literal(StartPageEnum.ContentStack.blocks.Video),
|
|
})
|
|
.merge(videoBlockRefsSchema)
|
|
|
|
const startPageBlockRefsItem = z.discriminatedUnion("__typename", [
|
|
startPageCardsRefs,
|
|
startPageFullWidthCampaignRef,
|
|
startPageCarouselCardsRef,
|
|
startPageJoinScandicFriendsRef,
|
|
startPageVideoCardRef,
|
|
startPageVideoRef,
|
|
])
|
|
|
|
export const startPageRefsSchema = z.object({
|
|
start_page: z.object({
|
|
blocks: discriminatedUnionArray(startPageBlockRefsItem.options).nullable(),
|
|
system: systemSchema,
|
|
}),
|
|
})
|