Merged in feat/BOOK-591-jotform (pull request #3350)
Feat/BOOK-591 jotform * feat(BOOK-591): create jotform * feat(BOOK-591): jotform * feat(BOOK-591): jotform * fix(BOOK-591): add embedhandler * feat(BOOK-591): refactor jotform * feat(BOOK-591): remove inline styles * feat(BOOK-591): remove typename * feat(BOOK-591): add jotformembedhandler Approved-by: Erik Tiekstra
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
dynamicContentSchema as blockDynamicContentSchema,
|
||||
} from "../schemas/blocks/dynamicContent"
|
||||
import { contentPageHotelListingSchema } from "../schemas/blocks/hotelListing"
|
||||
import { jotformRefsSchema, jotformSchema } from "../schemas/blocks/jotform"
|
||||
import {
|
||||
shortcutsRefsSchema,
|
||||
shortcutsSchema,
|
||||
@@ -103,6 +104,12 @@ export const contentPageUspGrid = z
|
||||
})
|
||||
.merge(uspGridSchema)
|
||||
|
||||
export const contentPageJotform = z
|
||||
.object({
|
||||
__typename: z.literal(ContentPageEnum.ContentStack.blocks.Jotform),
|
||||
})
|
||||
.merge(jotformSchema)
|
||||
|
||||
export const contentPageTable = z
|
||||
.object({
|
||||
__typename: z.literal(ContentPageEnum.ContentStack.blocks.Table),
|
||||
@@ -142,6 +149,7 @@ export const blocksSchema = z.discriminatedUnion("__typename", [
|
||||
contentPageTable,
|
||||
contentPageTextCols,
|
||||
contentPageUspGrid,
|
||||
contentPageJotform,
|
||||
contentPageHotelListing,
|
||||
contentPageVideoCard,
|
||||
contentPageVideo,
|
||||
@@ -298,6 +306,12 @@ const contentPageVideoRefs = z
|
||||
})
|
||||
.merge(videoBlockRefsSchema)
|
||||
|
||||
const contentPageJotformRefs = z
|
||||
.object({
|
||||
__typename: z.literal(ContentPageEnum.ContentStack.blocks.Jotform),
|
||||
})
|
||||
.merge(jotformRefsSchema)
|
||||
|
||||
const contentPageBlockRefsItem = z.discriminatedUnion("__typename", [
|
||||
contentPageAccordionRefs,
|
||||
contentPageBlockContentRefs,
|
||||
@@ -307,6 +321,7 @@ const contentPageBlockRefsItem = z.discriminatedUnion("__typename", [
|
||||
contentPageTextColsRefs,
|
||||
contentPageUspGridRefs,
|
||||
contentPageVideoCardRefs,
|
||||
contentPageJotformRefs,
|
||||
contentPageVideoRefs,
|
||||
])
|
||||
|
||||
|
||||
@@ -172,6 +172,11 @@ export function getConnections({ content_page }: ContentPageRefs) {
|
||||
break
|
||||
case ContentPageEnum.ContentStack.blocks.Video:
|
||||
break
|
||||
case ContentPageEnum.ContentStack.blocks.Jotform:
|
||||
if (block.jotform) {
|
||||
connections.push(block.jotform.system)
|
||||
}
|
||||
break
|
||||
default:
|
||||
const _exhaustiveCheck: never = typeName
|
||||
break
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||
import { systemSchema } from "../system"
|
||||
|
||||
export const jotformSchema = z.object({
|
||||
typename: z
|
||||
.literal(BlocksEnums.block.Jotform)
|
||||
.optional()
|
||||
.default(BlocksEnums.block.Jotform),
|
||||
jotform: z
|
||||
.object({
|
||||
formConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
form_id: z.string().nullish(),
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
.transform((data) => {
|
||||
return data.formConnection.edges[0]?.node || null
|
||||
}),
|
||||
})
|
||||
|
||||
export const jotformRefsSchema = z.object({
|
||||
jotform: z
|
||||
.object({
|
||||
formConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({ system: systemSchema }),
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
.transform((data) => {
|
||||
return data.formConnection.edges[0]?.node || null
|
||||
}),
|
||||
})
|
||||
Reference in New Issue
Block a user