diff --git a/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/page.tsx b/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/page.tsx new file mode 100644 index 0000000000..cf9817f314 --- /dev/null +++ b/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/page.tsx @@ -0,0 +1,55 @@ +import { withAppDirSsr } from "app/WithAppDirSsr"; +import type { PageProps as ServerPageProps } from "app/_types"; +import { _generateMetadata } from "app/_utils"; +import { cookies, headers } from "next/headers"; + +import type { routingServerSidePropsConfig } from "@calcom/app-store/routing-forms/pages/app-routing.config"; +import LayoutHandler from "@calcom/app-store/routing-forms/pages/layout-handler/[...appPages]"; +import Shell from "@calcom/features/shell/Shell"; + +import { getServerSideProps } from "@lib/apps/routing-forms/[...pages]/getServerSideProps"; +import { buildLegacyCtx } from "@lib/buildLegacyCtx"; + +const normalizePages = (pages: string[] | string | undefined) => { + const normalizedPages = Array.isArray(pages) ? pages : pages?.split("/") ?? []; + return { + mainPage: normalizedPages[0], + subPages: normalizedPages.slice(1), + }; +}; + +export const generateMetadata = async ({ params }: { params: { pages: string[] } }) => { + const { mainPage } = normalizePages(params.pages); + return await _generateMetadata( + // TODO: Need to show the actual form name instead of "Form" + (t) => (mainPage === "routing-link" ? `Form | Cal.com Forms` : `${t("routing_forms")} | Cal.com Forms`), + () => "" + ); +}; + +type GetServerSidePropsResult = + (typeof routingServerSidePropsConfig)[keyof typeof routingServerSidePropsConfig]; +const getData = withAppDirSsr(getServerSideProps); + +const ServerPage = async ({ params, searchParams }: ServerPageProps) => { + const context = buildLegacyCtx(headers(), cookies(), params, searchParams); + const props = await getData(context); + const { mainPage, subPages } = normalizePages(params.pages); + + const componentProps = { + ...props, + pages: subPages, + }; + + if (mainPage === "routing-link") { + return ; + } + + return ( + + + + ); +}; + +export default ServerPage; diff --git a/apps/web/app/(use-page-wrapper)/apps/routing-forms/page.tsx b/apps/web/app/(use-page-wrapper)/apps/routing-forms/page.tsx new file mode 100644 index 0000000000..06a1a03d53 --- /dev/null +++ b/apps/web/app/(use-page-wrapper)/apps/routing-forms/page.tsx @@ -0,0 +1,7 @@ +import { redirect } from "next/navigation"; + +const ServerPage = async () => { + redirect("/apps/routing-forms/forms"); +}; + +export default ServerPage; diff --git a/apps/web/app/future/apps/[slug]/[...pages]/page.tsx b/apps/web/app/future/apps/[slug]/[...pages]/page.tsx deleted file mode 100644 index 70e08d657c..0000000000 --- a/apps/web/app/future/apps/[slug]/[...pages]/page.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { withAppDirSsr } from "app/WithAppDirSsr"; -import type { PageProps } from "app/_types"; -import { _generateMetadata } from "app/_utils"; -import { WithLayout } from "app/layoutHOC"; -import type { GetServerSidePropsResult } from "next"; -import { cookies, headers } from "next/headers"; -import { notFound } from "next/navigation"; -import z from "zod"; - -import { getServerSideProps } from "@lib/apps/[slug]/[...pages]/getServerSideProps"; -import { buildLegacyCtx } from "@lib/buildLegacyCtx"; - -import LegacyPage, { getLayout } from "~/apps/[slug]/[...pages]/pages-view"; - -const paramsSchema = z.object({ - slug: z.string(), - pages: z.array(z.string()), -}); - -export const generateMetadata = async ({ params, searchParams }: PageProps) => { - const p = paramsSchema.safeParse(params); - - if (!p.success) { - return notFound(); - } - - const legacyContext = buildLegacyCtx(headers(), cookies(), params, searchParams); - const data = await getData(legacyContext); - const form = "form" in data ? (data.form as { name?: string; description?: string }) : null; - const formName = form?.name; - const formDescription = form?.description; - - return await _generateMetadata( - (t) => formName ?? t("routing_forms"), - (t) => formDescription ?? t("routing_forms_description") - ); -}; - -const getData = withAppDirSsr>(getServerSideProps); - -export default WithLayout({ - getLayout, - getData, - Page: LegacyPage, -}); diff --git a/apps/web/lib/apps/[slug]/[...pages]/getServerSideProps.ts b/apps/web/lib/apps/[slug]/[...pages]/getServerSideProps.ts deleted file mode 100644 index 5cd62aade0..0000000000 --- a/apps/web/lib/apps/[slug]/[...pages]/getServerSideProps.ts +++ /dev/null @@ -1,135 +0,0 @@ -import type { GetServerSidePropsContext, GetServerSidePropsResult } from "next"; -import { z } from "zod"; - -import { getAppWithMetadata } from "@calcom/app-store/_appRegistry"; -import RoutingFormsRoutingConfig from "@calcom/app-store/routing-forms/pages/app-routing.config"; -import TypeformRoutingConfig from "@calcom/app-store/typeform/pages/app-routing.config"; -import { getServerSession } from "@calcom/features/auth/lib/getServerSession"; -import prisma from "@calcom/prisma"; -import type { AppGetServerSideProps } from "@calcom/types/AppGetServerSideProps"; - -import type { AppProps } from "@lib/app-providers"; - -import { ssrInit } from "@server/lib/ssr"; - -type AppPageType = { - getServerSideProps?: AppGetServerSideProps; - // A component than can accept any properties - // eslint-disable-next-line @typescript-eslint/no-explicit-any - default: ((props: any) => JSX.Element) & - Pick; -}; - -type Found = { - notFound: false; - Component: AppPageType["default"]; - getServerSideProps: AppPageType["getServerSideProps"]; -}; - -type NotFound = { - notFound: true; -}; - -// TODO: It is a candidate for apps.*.generated.* -const AppsRouting = { - "routing-forms": RoutingFormsRoutingConfig, - typeform: TypeformRoutingConfig, -}; - -function getRoute(appName: string, pages: string[]) { - const routingConfig = AppsRouting[appName as keyof typeof AppsRouting] as Record; - - if (!routingConfig) { - return { - notFound: true, - } as NotFound; - } - const mainPage = pages[0]; - const appPage = routingConfig.layoutHandler || (routingConfig[mainPage] as AppPageType); - if (!appPage) { - return { - notFound: true, - } as NotFound; - } - return { notFound: false, Component: appPage.default, ...appPage } as Found; -} - -const paramsSchema = z.object({ - slug: z.string(), - pages: z.array(z.string()), -}); - -export async function getServerSideProps( - context: GetServerSidePropsContext -): Promise> { - const { params, req } = context; - if (!params) { - return { - notFound: true, - }; - } - - const parsedParams = paramsSchema.safeParse(params); - if (!parsedParams.success) { - return { - notFound: true, - }; - } - - const appName = parsedParams.data.slug; - const pages = parsedParams.data.pages; - const route = getRoute(appName, pages); - - if (route.notFound) { - return { notFound: true }; - } - - if (route.getServerSideProps) { - // TODO: Document somewhere that right now it is just a convention that filename should have appPages in it's name. - // appPages is actually hardcoded here and no matter the fileName the same variable would be used. - // We can write some validation logic later on that ensures that [...appPages].tsx file exists - params.appPages = pages.slice(1); - const session = await getServerSession({ req }); - const user = session?.user; - const app = await getAppWithMetadata({ slug: appName }); - - if (!app) { - return { - notFound: true, - }; - } - - const result = await route.getServerSideProps( - context as GetServerSidePropsContext<{ - slug: string; - pages: string[]; - appPages: string[]; - }>, - prisma, - user, - ssrInit - ); - - if (result.notFound) { - return { notFound: true }; - } - - if (result.redirect) { - return { redirect: result.redirect }; - } - - return { - props: { - appName, - appUrl: app.simplePath || `/apps/${appName}`, - ...result.props, - }, - }; - } else { - return { - props: { - appName, - }, - }; - } -} diff --git a/apps/web/lib/apps/routing-forms/[...pages]/getServerSideProps.ts b/apps/web/lib/apps/routing-forms/[...pages]/getServerSideProps.ts new file mode 100644 index 0000000000..0afed87af6 --- /dev/null +++ b/apps/web/lib/apps/routing-forms/[...pages]/getServerSideProps.ts @@ -0,0 +1,62 @@ +import type { GetServerSidePropsResult, GetServerSidePropsContext } from "next"; +import { z } from "zod"; + +import { getAppWithMetadata } from "@calcom/app-store/_appRegistry"; +import { routingServerSidePropsConfig } from "@calcom/app-store/routing-forms/pages/app-routing.config"; +import { getServerSession } from "@calcom/features/auth/lib/getServerSession"; +import prisma from "@calcom/prisma"; +import type { AppGetServerSidePropsContext } from "@calcom/types/AppGetServerSideProps"; + +import { ssrInit } from "@server/lib/ssr"; + +const paramsSchema = z.object({ + pages: z.array(z.string()), +}); + +export async function getServerSideProps( + context: GetServerSidePropsContext +): Promise> { + const { params, req } = context; + + const parsedParams = paramsSchema.safeParse(params); + if (!parsedParams.success) { + return { + notFound: true, + }; + } + + const pages = parsedParams.data.pages; + const mainPage = pages[0]; + const getServerSideProps = routingServerSidePropsConfig[mainPage]; + + if (!getServerSideProps) { + return { notFound: true }; + } + + const session = await getServerSession({ req }); + const user = session?.user; + const app = await getAppWithMetadata({ slug: "routing-forms" }); + + if (!app) { + return { + notFound: true, + }; + } + + const result = await getServerSideProps(context as AppGetServerSidePropsContext, prisma, user, ssrInit); + + if (result.notFound) { + return { notFound: true }; + } + + if (result.redirect) { + return { redirect: result.redirect }; + } + + return { + props: { + appUrl: app.simplePath || `/apps/routing-forms`, + ...result.props, + }, + }; +} diff --git a/apps/web/lib/hooks/useIsBookingPage.ts b/apps/web/lib/hooks/useIsBookingPage.ts index 3245b5a2be..7b1f10c574 100644 --- a/apps/web/lib/hooks/useIsBookingPage.ts +++ b/apps/web/lib/hooks/useIsBookingPage.ts @@ -4,9 +4,14 @@ import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; export default function useIsBookingPage(): boolean { const pathname = usePathname(); - const isBookingPage = ["/booking", "/cancel", "/reschedule", "/d"].some((route) => - pathname?.startsWith(route) - ); + const isBookingPage = [ + "/booking", + "/cancel", + "/reschedule", + "/d", // Private Link of booking page + "/apps/routing-forms/routing-link", // Routing Form page + "/forms/", // Rewrites to /apps/routing-forms/routing-link + ].some((route) => pathname?.startsWith(route)); const searchParams = useCompatSearchParams(); const userParam = Boolean(searchParams?.get("user")); diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index 5f748b579e..18a26f2a24 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -155,22 +155,11 @@ export const config = { "/api/auth/signup", "/api/trpc/:path*", "/login", + "/apps/:path*", "/auth/:path*", - /** - * Paths required by routingForms.handle - */ - "/apps/routing_forms/:path*", - "/event-types/:path*", - "/apps/installed/:category/", - "/apps/installation/:path*", - "/apps/:slug/", - "/apps/:slug/setup/", - "/apps/categories/", - "/apps/categories/:category/", "/workflows/:path*", "/getting-started/:path*", - "/apps", "/bookings/:path*", "/video/:path*", "/teams/:path*", diff --git a/apps/web/modules/apps/[slug]/[...pages]/pages-view.tsx b/apps/web/modules/apps/[slug]/[...pages]/pages-view.tsx deleted file mode 100644 index 1a1ca5d06f..0000000000 --- a/apps/web/modules/apps/[slug]/[...pages]/pages-view.tsx +++ /dev/null @@ -1,102 +0,0 @@ -"use client"; - -import RoutingFormsRoutingConfig from "@calcom/app-store/routing-forms/pages/app-routing.config"; -import TypeformRoutingConfig from "@calcom/app-store/typeform/pages/app-routing.config"; -import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback"; -import type { AppGetServerSideProps } from "@calcom/types/AppGetServerSideProps"; -import type { inferSSRProps } from "@calcom/types/inferSSRProps"; - -import type { AppProps } from "@lib/app-providers"; -import type { getServerSideProps } from "@lib/apps/[slug]/[...pages]/getServerSideProps"; - -type AppPageType = { - getServerSideProps: AppGetServerSideProps; - // A component than can accept any properties - // eslint-disable-next-line @typescript-eslint/no-explicit-any - default: ((props: any) => JSX.Element) & - Pick; -}; - -type Found = { - notFound: false; - Component: AppPageType["default"]; - getServerSideProps: AppPageType["getServerSideProps"]; -}; - -type NotFound = { - notFound: true; -}; - -// TODO: It is a candidate for apps.*.generated.* -const AppsRouting = { - "routing-forms": RoutingFormsRoutingConfig, - typeform: TypeformRoutingConfig, -}; - -function getRoute(appName: string, pages: string[]) { - const routingConfig = AppsRouting[appName as keyof typeof AppsRouting] as unknown as Record< - string, - AppPageType - >; - - if (!routingConfig) { - return { - notFound: true, - } as NotFound; - } - const mainPage = pages[0]; - const appPage = routingConfig.layoutHandler || (routingConfig[mainPage] as AppPageType); - if (!appPage) { - return { - notFound: true, - } as NotFound; - } - return { notFound: false, Component: appPage.default, ...appPage } as Found; -} -export type PageProps = inferSSRProps; - -const AppPage: AppPageType["default"] = function AppPage(props: PageProps) { - const appName = props.appName; - const params = useParamsWithFallback(); - const pages = Array.isArray(params.pages) ? params.pages : params.pages?.split("/") ?? []; - const route = getRoute(appName, pages); - - const componentProps = { - ...props, - pages: pages.slice(1), - }; - - if (!route || route.notFound) { - throw new Error("Route can't be undefined"); - } - return ; -}; - -AppPage.isBookingPage = ({ router }) => { - const route = getRoute(router.query.slug as string, router.query.pages as string[]); - if (route.notFound) { - return false; - } - const isBookingPage = route.Component.isBookingPage; - if (typeof isBookingPage === "function") { - return isBookingPage({ router }); - } - - return !!isBookingPage; -}; - -export const getLayout: NonNullable<(typeof AppPage)["getLayout"]> = (page) => { - // eslint-disable-next-line react-hooks/rules-of-hooks - const { slug, pages } = useParamsWithFallback(); - const route = getRoute(slug as string, pages as string[]); - - if (route.notFound) { - return null; - } - if (!route.Component.getLayout) { - return page; - } - return route.Component.getLayout(page); -}; - -export default AppPage; diff --git a/apps/web/pages/apps/[slug]/[...pages].tsx b/apps/web/pages/apps/[slug]/[...pages].tsx deleted file mode 100644 index 6de4cdfd96..0000000000 --- a/apps/web/pages/apps/[slug]/[...pages].tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { getServerSideProps } from "@lib/apps/[slug]/[...pages]/getServerSideProps"; - -import PageWrapper from "@components/PageWrapper"; - -import type { PageProps } from "~/apps/[slug]/[...pages]/pages-view"; -import PagesView, { getLayout } from "~/apps/[slug]/[...pages]/pages-view"; - -const Page = (props: PageProps) => ; - -Page.PageWrapper = PageWrapper; -Page.getLayout = getLayout; - -export { getServerSideProps }; - -export default Page; diff --git a/packages/app-store/routing-forms/components/SingleForm.tsx b/packages/app-store/routing-forms/components/SingleForm.tsx index 58a9cff63b..a47aa41b81 100644 --- a/packages/app-store/routing-forms/components/SingleForm.tsx +++ b/packages/app-store/routing-forms/components/SingleForm.tsx @@ -770,7 +770,7 @@ function SingleForm({ form, appUrl, Page, enrichedWithUserProfileForm }: SingleF } subtitle={form.description || ""} - backPath={`/${appUrl}/forms`} + backPath={`${appUrl}/forms`} CTA={}>
diff --git a/packages/app-store/routing-forms/components/getServerSidePropsSingleForm.ts b/packages/app-store/routing-forms/components/getServerSidePropsSingleForm.ts index 9b1b633144..582670de8f 100644 --- a/packages/app-store/routing-forms/components/getServerSidePropsSingleForm.ts +++ b/packages/app-store/routing-forms/components/getServerSidePropsSingleForm.ts @@ -30,8 +30,9 @@ export const getServerSidePropsForSingleFormView = async function getServerSideP notFound: true, }; } - const formId = params.appPages[0]; - if (!formId || params.appPages.length > 1) { + const appPages = params.pages.slice(1); + const formId = appPages[0]; + if (!formId || appPages.length > 1) { return { notFound: true, }; diff --git a/packages/app-store/routing-forms/pages/app-routing.config.tsx b/packages/app-store/routing-forms/pages/app-routing.config.tsx index 4c322f1c21..2c7ba5f788 100644 --- a/packages/app-store/routing-forms/pages/app-routing.config.tsx +++ b/packages/app-store/routing-forms/pages/app-routing.config.tsx @@ -7,7 +7,6 @@ import * as forms from "./forms/[...appPages]"; // extracts getServerSideProps function from the client component import { getServerSideProps as getServerSidePropsForms } from "./forms/getServerSideProps"; import * as IncompleteBooking from "./incomplete-booking/[...appPages]"; -import * as LayoutHandler from "./layout-handler/[...appPages]"; import * as Reporting from "./reporting/[...appPages]"; import * as RouteBuilder from "./route-builder/[...appPages]"; import * as RoutingLink from "./routing-link/[...appPages]"; @@ -19,11 +18,10 @@ const routingConfig = { forms: forms, "routing-link": RoutingLink, reporting: Reporting, - layoutHandler: LayoutHandler, "incomplete-booking": IncompleteBooking, }; -export const serverSidePropsConfig: Record = { +export const routingServerSidePropsConfig: Record = { forms: getServerSidePropsForms, "form-edit": getServerSidePropsSingleForm, "route-builder": getServerSidePropsSingleForm, diff --git a/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx b/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx index 2aa2e63f43..d9c3660376 100644 --- a/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx +++ b/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx @@ -6,7 +6,6 @@ import type { UseFormReturn } from "react-hook-form"; import { Controller, useFieldArray, useWatch } from "react-hook-form"; import { v4 as uuidv4 } from "uuid"; -import Shell from "@calcom/features/shell/Shell"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { @@ -479,11 +478,3 @@ export default function FormEditPage({ /> ); } - -FormEditPage.getLayout = (page: React.ReactElement) => { - return ( - - {page} - - ); -}; diff --git a/packages/app-store/routing-forms/pages/forms/[...appPages].tsx b/packages/app-store/routing-forms/pages/forms/[...appPages].tsx index 797646a1f4..58b69ef068 100644 --- a/packages/app-store/routing-forms/pages/forms/[...appPages].tsx +++ b/packages/app-store/routing-forms/pages/forms/[...appPages].tsx @@ -9,7 +9,7 @@ import SkeletonLoaderTeamList from "@calcom/features/ee/teams/components/Skeleto import { FilterResults } from "@calcom/features/filters/components/FilterResults"; import { TeamsFilter } from "@calcom/features/filters/components/TeamsFilter"; import { getTeamsFiltersFromQuery } from "@calcom/features/filters/lib/getTeamsFiltersFromQuery"; -import Shell, { ShellMain } from "@calcom/features/shell/Shell"; +import { ShellMain } from "@calcom/features/shell/Shell"; import { UpgradeTip } from "@calcom/features/tips"; import { WEBAPP_URL } from "@calcom/lib/constants"; import useApp from "@calcom/lib/hooks/useApp"; @@ -346,18 +346,4 @@ export default function RoutingForms({ ); } -const ShellContainer = ({ page }: { page: React.ReactElement }) => { - const { t } = useLocale(); - - return ( - - {page} - - ); -}; - -RoutingForms.getLayout = (page: React.ReactElement) => { - return ; -}; - export { getServerSideProps }; diff --git a/packages/app-store/routing-forms/pages/incomplete-booking/[...appPages].tsx b/packages/app-store/routing-forms/pages/incomplete-booking/[...appPages].tsx index 0bad763f40..ed81dd0078 100644 --- a/packages/app-store/routing-forms/pages/incomplete-booking/[...appPages].tsx +++ b/packages/app-store/routing-forms/pages/incomplete-booking/[...appPages].tsx @@ -6,7 +6,6 @@ import type z from "zod"; import { WhenToWriteToRecord, SalesforceFieldType } from "@calcom/app-store/salesforce/lib/enums"; import type { writeToRecordDataSchema as salesforceWriteToRecordDataSchema } from "@calcom/app-store/salesforce/zod"; import { routingFormIncompleteBookingDataSchema as salesforceRoutingFormIncompleteBookingDataSchema } from "@calcom/app-store/salesforce/zod"; -import Shell from "@calcom/features/shell/Shell"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { IncompleteBookingActionType } from "@calcom/prisma/enums"; import { trpc } from "@calcom/trpc/react"; @@ -320,12 +319,4 @@ export default function IncompleteBookingPage({ ); } -IncompleteBookingPage.getLayout = (page: React.ReactElement) => { - return ( - - {page} - - ); -}; - export { getServerSideProps }; diff --git a/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx b/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx index 5d1058cb28..c5370f7ae4 100644 --- a/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx +++ b/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx @@ -35,26 +35,3 @@ export default function LayoutHandler(props: { [key: string]: unknown }) { ); } - -LayoutHandler.getLayout = (page: React.ReactElement) => { - // eslint-disable-next-line react-hooks/rules-of-hooks - const params = useParamsWithFallback(); - const pageKey = Array.isArray(params.pages) - ? params.pages[0] - : params.pages?.split("/")[0] ?? DEFAULT_ROUTE; - - const component = getComponent(pageKey).default; - if (component && "getLayout" in component) { - return component.getLayout?.(page); - } else { - return page; - } -}; - -export async function getServerSideProps( - context: GetServerSidePropsContext, - ...rest: GetServerSidePropsRestArgs -) { - const component = getComponent(context.params?.pages?.[0] || ""); - return component.getServerSideProps?.(context, ...rest) || { props: {} }; -} diff --git a/packages/app-store/routing-forms/pages/reporting/[...appPages].tsx b/packages/app-store/routing-forms/pages/reporting/[...appPages].tsx index 855cdeef79..7ba1f7e1d4 100644 --- a/packages/app-store/routing-forms/pages/reporting/[...appPages].tsx +++ b/packages/app-store/routing-forms/pages/reporting/[...appPages].tsx @@ -10,7 +10,6 @@ import type { } from "react-awesome-query-builder"; import { Builder, Query, Utils as QbUtils } from "react-awesome-query-builder"; -import Shell from "@calcom/features/shell/Shell"; import { classNames } from "@calcom/lib"; import { downloadAsCsv, sanitizeValue } from "@calcom/lib/csvUtils"; import { useInViewObserver } from "@calcom/lib/hooks/useInViewObserver"; @@ -291,11 +290,3 @@ export default function ReporterWrapper({ /> ); } - -ReporterWrapper.getLayout = (page: React.ReactElement) => { - return ( - - {page} - - ); -}; diff --git a/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx b/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx index 24885325e4..8827a57ea2 100644 --- a/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx +++ b/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx @@ -9,7 +9,6 @@ import type { ImmutableTree, BuilderProps, Config } from "react-awesome-query-bu import type { JsonTree } from "react-awesome-query-builder"; import type { UseFormReturn } from "react-hook-form"; -import Shell from "@calcom/features/shell/Shell"; import { areTheySiblingEntitites } from "@calcom/lib/entityPermissionUtils"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { buildEmptyQueryValue, raqbQueryValueUtils } from "@calcom/lib/raqb/raqbUtils"; @@ -1243,12 +1242,4 @@ export default function RouteBuilder({ ); } -RouteBuilder.getLayout = (page: React.ReactElement) => { - return ( - - {page} - - ); -}; - export { getServerSideProps }; diff --git a/packages/app-store/routing-forms/pages/routing-link/[...appPages].tsx b/packages/app-store/routing-forms/pages/routing-link/[...appPages].tsx index 308d21df1d..ff05744f96 100644 --- a/packages/app-store/routing-forms/pages/routing-link/[...appPages].tsx +++ b/packages/app-store/routing-forms/pages/routing-link/[...appPages].tsx @@ -1,6 +1,5 @@ "use client"; -import Head from "next/head"; import { useRouter } from "next/navigation"; import type { FormEvent } from "react"; import { useEffect, useRef, useState } from "react"; @@ -163,9 +162,6 @@ function RoutingForm({ form, profile, ...restProps }: Props) {
{!customPageMessage ? ( <> - - {`${form.name} | Cal.com Forms`} -
@@ -213,8 +209,6 @@ export default function RoutingLink(props: inferSSRProps; } -RoutingLink.isBookingPage = true; - export { getServerSideProps }; const usePrefilledResponse = (form: Props["form"]) => { diff --git a/packages/app-store/routing-forms/pages/routing-link/getServerSideProps.ts b/packages/app-store/routing-forms/pages/routing-link/getServerSideProps.ts index a0671d861e..d46ac60af3 100644 --- a/packages/app-store/routing-forms/pages/routing-link/getServerSideProps.ts +++ b/packages/app-store/routing-forms/pages/routing-link/getServerSideProps.ts @@ -15,18 +15,16 @@ export const getServerSideProps = async function getServerSideProps( notFound: true, }; } - const formId = params.appPages[0]; - if (!formId || params.appPages.length > 2) { + const appPages = params.pages.slice(1); + const formId = appPages[0]; + if (!formId || appPages.length > 2) { return { notFound: true, }; } const { currentOrgDomain } = orgDomainConfig(context.req); - const isEmbed = params.appPages[1] === "embed"; - if (context.query["flag.coep"] === "true") { - context.res.setHeader("Cross-Origin-Embedder-Policy", "require-corp"); - } + const isEmbed = appPages[1] === "embed"; const form = await prisma.app_RoutingForms_Form.findFirst({ where: { diff --git a/packages/app-store/typeform/pages/app-routing.config.tsx b/packages/app-store/typeform/pages/app-routing.config.tsx deleted file mode 100644 index c0f855f1a6..0000000000 --- a/packages/app-store/typeform/pages/app-routing.config.tsx +++ /dev/null @@ -1,10 +0,0 @@ -"use client"; - -//TODO: Generate this file automatically so that like in Next.js file based routing can work automatically -import * as HowToUse from "./how-to-use/[...appPages]"; - -const routingConfig = { - "how-to-use": HowToUse, -}; - -export default routingConfig; diff --git a/packages/features/shell/Shell.tsx b/packages/features/shell/Shell.tsx index cdddf07caf..a7ceb860c1 100644 --- a/packages/features/shell/Shell.tsx +++ b/packages/features/shell/Shell.tsx @@ -152,18 +152,9 @@ export function ShellMain(props: LayoutProps) { variant="icon" size="sm" color="minimal" - onClick={() => { - if (typeof props.backPath === "string") { - // Prevents weird crash when navigating from /routing to /routing/forms - if (props.backPath.startsWith("/routing")) { - window.location.href = props.backPath; - } else { - router.push(props.backPath as string); - } - } else { - router.back(); - } - }} + onClick={() => + typeof props.backPath === "string" ? router.push(props.backPath as string) : router.back() + } StartIcon="arrow-left" aria-label="Go Back" className="rounded-md ltr:mr-2 rtl:ml-2" diff --git a/packages/features/shell/navigation/NavigationItem.tsx b/packages/features/shell/navigation/NavigationItem.tsx index 15cf9aad1c..0b0dd4d02f 100644 --- a/packages/features/shell/navigation/NavigationItem.tsx +++ b/packages/features/shell/navigation/NavigationItem.tsx @@ -57,13 +57,6 @@ export const NavigationItem: React.FC<{ { - // Prevents weird crash when navigating from /routing to /routing/forms - if (item.href.startsWith("/routing")) { - e.preventDefault(); - window.location.href = item.href; - } - }} aria-label={t(item.name)} target={item.target} className={classNames( diff --git a/packages/types/AppGetServerSideProps.d.ts b/packages/types/AppGetServerSideProps.d.ts index 3ad1b2eea6..c1750803c6 100644 --- a/packages/types/AppGetServerSideProps.d.ts +++ b/packages/types/AppGetServerSideProps.d.ts @@ -8,7 +8,7 @@ import type { ssrInit } from "@server/lib/ssr"; export type AppUser = CalendsoSessionUser | undefined; export type AppPrisma = typeof prisma; export type AppGetServerSidePropsContext = GetServerSidePropsContext<{ - appPages: string[]; + pages: string[]; }>; export type AppSsrInit = ssrInit; export type AppGetServerSideProps = (