From 1dce74c95fbbb7efb02f240fe1bc5336408416e0 Mon Sep 17 00:00:00 2001 From: Bianca Widstam Date: Tue, 16 Dec 2025 14:35:45 +0000 Subject: [PATCH] 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 --- .../components/Blocks/Jotform/index.tsx | 58 +++++++++++++++++++ .../Blocks/Jotform/jotform.module.css | 5 ++ apps/scandic-web/components/Blocks/index.tsx | 3 + apps/scandic-web/types/window.d.ts | 1 + .../Fragments/Blocks/Jotform.graphql.ts | 34 +++++++++++ .../lib/graphql/Fragments/Jotform.graphql.ts | 18 ++++++ .../Query/ContentPage/ContentPage.graphql.ts | 8 +++ .../contentstack/contentPage/output.ts | 15 +++++ .../routers/contentstack/contentPage/utils.ts | 5 ++ .../contentstack/schemas/blocks/jotform.ts | 42 ++++++++++++++ packages/trpc/lib/types/blocksEnum.ts | 1 + packages/trpc/lib/types/contentPage.ts | 16 +++-- 12 files changed, 200 insertions(+), 6 deletions(-) create mode 100644 apps/scandic-web/components/Blocks/Jotform/index.tsx create mode 100644 apps/scandic-web/components/Blocks/Jotform/jotform.module.css create mode 100644 packages/trpc/lib/graphql/Fragments/Blocks/Jotform.graphql.ts create mode 100644 packages/trpc/lib/graphql/Fragments/Jotform.graphql.ts create mode 100644 packages/trpc/lib/routers/contentstack/schemas/blocks/jotform.ts diff --git a/apps/scandic-web/components/Blocks/Jotform/index.tsx b/apps/scandic-web/components/Blocks/Jotform/index.tsx new file mode 100644 index 000000000..7aa9124fd --- /dev/null +++ b/apps/scandic-web/components/Blocks/Jotform/index.tsx @@ -0,0 +1,58 @@ +"use client" +import Script from "next/script" +import { useEffect, useRef, useState } from "react" + +import useLang from "@/hooks/useLang" + +import styles from "./jotform.module.css" + +type JotformProps = { + formId: string | null | undefined +} + +export default function Jotform({ formId }: JotformProps) { + const lang = useLang() + const [scriptInitialized, setScriptInitialized] = useState( + () => + typeof window !== "undefined" && + typeof window.jotformEmbedHandler === "function" + ) + const componentInitialized = useRef(false) + + useEffect(() => { + if ( + formId && + scriptInitialized && + !componentInitialized.current && + window.jotformEmbedHandler + ) { + window.jotformEmbedHandler( + `iframe[id='JotFormIFrame-${formId}']`, + "https://scandichotels.jotform.com/" + ) + componentInitialized.current = true + } + }, [formId, scriptInitialized]) + + if (!formId) { + return null + } + + const src = `https://scandichotels.jotform.com/${formId}?language=${lang}` + + return ( + <> +