Skip to content

Commit

Permalink
move router to app dir
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-brydon committed Feb 25, 2025
1 parent a311360 commit 026cefa
Show file tree
Hide file tree
Showing 3 changed files with 8,858 additions and 99 deletions.
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);
});

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

0 comments on commit 026cefa

Please sign in to comment.