refactor: make routing forms code more maintainable (#21478)

* create layout for routing/forms

* refactor

* refators

* fix

* clean up
This commit is contained in:
Benny Joo authored and GitHub committed 2025-05-24 22:44:05 +00:00
1 parent d43afe7dbd
commit 1c3ad9dad6
9 files changed
+58 -67

No files matched your search

@@ -1,7 +1,6 @@
export const routingFormsComponents = {
"form-edit": () => import("./form-edit/[...appPages]").then((mod) => mod.default),
"route-builder": () => import("./route-builder/[...appPages]").then((mod) => mod.default),
forms: () => import("./forms/[...appPages]").then((mod) => mod.default),
"routing-link": () => import("./routing-link/[...appPages]").then((mod) => mod.default),
reporting: () => import("./reporting/[...appPages]").then((mod) => mod.default),
"incomplete-booking": () => import("./incomplete-booking/[...appPages]").then((mod) => mod.default),
@@ -3,11 +3,9 @@ import "server-only";
import type { AppGetServerSideProps } from "@calcom/types/AppGetServerSideProps";
import { getServerSidePropsForSingleFormView as getServerSidePropsSingleForm } from "../components/getServerSidePropsSingleForm";
import { getServerSideProps as getServerSidePropsForms } from "./forms/getServerSideProps";
import { getServerSideProps as getServerSidePropsRoutingLink } from "./routing-link/getServerSideProps";
export const routingServerSidePropsConfig: Record<string, AppGetServerSideProps> = {
forms: getServerSidePropsForms,
"form-edit": getServerSidePropsSingleForm,
"route-builder": getServerSidePropsSingleForm,
"routing-link": getServerSidePropsRoutingLink,
@@ -26,13 +26,10 @@ import { Icon } from "@calcom/ui/components/icon";
import { List, ListLinkItem } from "@calcom/ui/components/list";
import { Tooltip } from "@calcom/ui/components/tooltip";
import type { inferSSRProps } from "@lib/types/inferSSRProps";
import type { SetNewFormDialogState, NewFormDialogState } from "../../components/FormActions";
import { FormAction, FormActionsDropdown, FormActionsProvider } from "../../components/FormActions";
import { isFallbackRoute } from "../../lib/isFallbackRoute";
import type { RoutingFormWithResponseCount } from "../../types/types";
import { getServerSideProps } from "./getServerSideProps";
function NewFormButton({ setNewFormDialogState }: { setNewFormDialogState: SetNewFormDialogState }) {
const { t } = useLocale();
@@ -47,11 +44,7 @@ function NewFormButton({ setNewFormDialogState }: { setNewFormDialogState: SetNe
);
}
export default function RoutingForms({
appUrl,
}: inferSSRProps<typeof getServerSideProps> & {
appUrl: string;
}) {
export default function RoutingForms({ appUrl }: { appUrl: string }) {
const { t } = useLocale();
const { hasPaidPlan } = useHasPaidPlan();
const routerQuery = useRouterQuery();
@@ -332,5 +325,3 @@ export default function RoutingForms({
</LicenseRequired>
);
}
export { getServerSideProps };
@@ -1,20 +0,0 @@
import type { AppGetServerSidePropsContext, AppPrisma, AppUser } from "@calcom/types/AppGetServerSideProps";
export const getServerSideProps = async function getServerSideProps(
context: AppGetServerSidePropsContext,
prisma: AppPrisma,
user: AppUser
) {
if (!user) {
return {
redirect: {
permanent: false,
destination: "/auth/login",
},
};
}
return {
props: {},
};
};