Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move router to app dir #19536

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions apps/web/app/(use-page-wrapper)/router/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { PageProps as _PageProps } from "app/_types";
import type { GetServerSidePropsContext } from "next";
import { cookies, headers } from "next/headers";
import { redirect } from "next/navigation";
import { cache } from "react";

import { getRoutedUrl } from "@calcom/lib/server";

import { buildLegacyCtx } from "@lib/buildLegacyCtx";

const getCachedRoutingFormData = cache(async (legacyCtx: GetServerSidePropsContext) => {
return await getRoutedUrl(legacyCtx);
});
Comment on lines +11 to +13
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache this call so we dont need to refetch this data in the title and loading the page


export default async function RouterPage({ params, searchParams }: _PageProps) {
const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);

const result = await getCachedRoutingFormData(legacyCtx);

if (result.redirect) {
redirect(result.redirect.destination);
}

return (
<div className="mx-auto my-0 max-w-3xl md:my-24">
<div className="w-full max-w-4xl ltr:mr-2 rtl:ml-2">
<div className="text-default bg-default -mx-4 rounded-sm border border-neutral-200 p-4 py-6 sm:mx-0 sm:px-8">
<div>{result.props?.message}</div>
</div>
</div>
</div>
);
}

export async function generateMetadata({ params, searchParams }: _PageProps) {
const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);

const result = await getCachedRoutingFormData(legacyCtx);

return {
title: `${result.props?.form?.name} | Cal.com Forms`,
};
}
30 changes: 0 additions & 30 deletions apps/web/pages/router/index.tsx

This file was deleted.

Loading
Loading