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:
@@ -0,0 +1,34 @@
|
||||
import { gql } from "graphql-tag"
|
||||
|
||||
import { Jotform, JotformRef } from "../Jotform.graphql"
|
||||
export const Jotform_ContentPage = gql`
|
||||
fragment Jotform_ContentPage on ContentPageBlocksJotform {
|
||||
__typename
|
||||
jotform {
|
||||
formConnection {
|
||||
edges {
|
||||
node {
|
||||
...Jotform
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${Jotform}
|
||||
`
|
||||
|
||||
export const Jotform_ContentPageRefs = gql`
|
||||
fragment Jotform_ContentPageRefs on ContentPageBlocksJotform {
|
||||
__typename
|
||||
jotform {
|
||||
formConnection {
|
||||
edges {
|
||||
node {
|
||||
...JotformRef
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${JotformRef}
|
||||
`
|
||||
18
packages/trpc/lib/graphql/Fragments/Jotform.graphql.ts
Normal file
18
packages/trpc/lib/graphql/Fragments/Jotform.graphql.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { gql } from "graphql-tag"
|
||||
|
||||
import { System } from "./System.graphql"
|
||||
|
||||
export const Jotform = gql`
|
||||
fragment Jotform on Jotform {
|
||||
form_id
|
||||
}
|
||||
`
|
||||
|
||||
export const JotformRef = gql`
|
||||
fragment JotformRef on Jotform {
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
${System}
|
||||
`
|
||||
@@ -17,6 +17,10 @@ import {
|
||||
DynamicContent_ContentPageRefs,
|
||||
} from "../../Fragments/Blocks/DynamicContent.graphql"
|
||||
import { HotelListing_ContentPage } from "../../Fragments/Blocks/HotelListing.graphql"
|
||||
import {
|
||||
Jotform_ContentPage,
|
||||
Jotform_ContentPageRefs,
|
||||
} from "../../Fragments/Blocks/Jotform.graphql"
|
||||
import {
|
||||
Shortcuts_ContentPage,
|
||||
Shortcuts_ContentPageRefs,
|
||||
@@ -134,6 +138,7 @@ export const GetContentPageBlocksBatch1 = gql`
|
||||
...CardsGrid_ContentPage
|
||||
...Content_ContentPage
|
||||
...DynamicContent_ContentPage
|
||||
...Jotform_ContentPage
|
||||
...VideoCard_ContentPage
|
||||
...Video_ContentPage
|
||||
}
|
||||
@@ -143,6 +148,7 @@ export const GetContentPageBlocksBatch1 = gql`
|
||||
${CardsGrid_ContentPage}
|
||||
${Content_ContentPage}
|
||||
${DynamicContent_ContentPage}
|
||||
${Jotform_ContentPage}
|
||||
${VideoCard_ContentPage}
|
||||
${Video_ContentPage}
|
||||
`
|
||||
@@ -216,6 +222,7 @@ export const GetContentPageBlocksRefs = gql`
|
||||
...Shortcuts_ContentPageRefs
|
||||
...TextCols_ContentPageRef
|
||||
...UspGrid_ContentPageRefs
|
||||
...Jotform_ContentPageRefs
|
||||
...VideoCard_ContentPageRefs
|
||||
...Video_ContentPageRefs
|
||||
}
|
||||
@@ -228,6 +235,7 @@ export const GetContentPageBlocksRefs = gql`
|
||||
${Shortcuts_ContentPageRefs}
|
||||
${TextCols_ContentPageRef}
|
||||
${UspGrid_ContentPageRefs}
|
||||
${Jotform_ContentPageRefs}
|
||||
${VideoCard_ContentPageRefs}
|
||||
${Video_ContentPageRefs}
|
||||
`
|
||||
|
||||
@@ -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
|
||||
}),
|
||||
})
|
||||
@@ -12,6 +12,7 @@ export namespace BlocksEnums {
|
||||
CampaignPageHotelListing = "CampaignPageHotelListing",
|
||||
ContentPageHotelListing = "ContentPageHotelListing",
|
||||
JoinScandicFriends = "JoinScandicFriends",
|
||||
Jotform = "Jotform",
|
||||
Shortcuts = "Shortcuts",
|
||||
Table = "Table",
|
||||
TextCols = "TextCols",
|
||||
|
||||
@@ -7,14 +7,17 @@ import type {
|
||||
sidebarSchema,
|
||||
} from "../routers/contentstack/contentPage/output"
|
||||
|
||||
export interface GetContentPageRefsSchema
|
||||
extends z.input<typeof contentPageRefsSchema> {}
|
||||
export interface GetContentPageRefsSchema extends z.input<
|
||||
typeof contentPageRefsSchema
|
||||
> {}
|
||||
|
||||
export interface ContentPageRefs
|
||||
extends z.output<typeof contentPageRefsSchema> {}
|
||||
export interface ContentPageRefs extends z.output<
|
||||
typeof contentPageRefsSchema
|
||||
> {}
|
||||
|
||||
export interface GetContentPageSchema
|
||||
extends z.input<typeof contentPageSchema> {}
|
||||
export interface GetContentPageSchema extends z.input<
|
||||
typeof contentPageSchema
|
||||
> {}
|
||||
|
||||
export interface ContentPage extends z.output<typeof contentPageSchema> {}
|
||||
|
||||
@@ -34,6 +37,7 @@ export namespace ContentPageEnum {
|
||||
Shortcuts = "ContentPageBlocksShortcuts",
|
||||
TextCols = "ContentPageBlocksTextCols",
|
||||
UspGrid = "ContentPageBlocksUspGrid",
|
||||
Jotform = "ContentPageBlocksJotform",
|
||||
Table = "ContentPageBlocksTable",
|
||||
HotelListing = "ContentPageBlocksHotelListing",
|
||||
VideoCard = "ContentPageBlocksVideoCard",
|
||||
|
||||
Reference in New Issue
Block a user