From aa3c91ebd686b73110082844d1d4f9c48332bcd3 Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Mon, 16 Sep 2024 10:42:00 -0400 Subject: [PATCH] chore: App router - add missing metadata for `/[user]` pages (#16516) --- apps/web/app/future/[user]/[type]/embed/page.tsx | 7 +++++-- apps/web/app/future/[user]/[type]/page.tsx | 7 +++---- apps/web/app/future/[user]/embed/page.tsx | 6 +++++- apps/web/app/future/[user]/page.tsx | 6 ++++-- .../[orgSlug]/[user]/[type]/getServerSideProps.tsx | 2 +- apps/web/modules/users/views/users-public-view.tsx | 2 +- .../modules/users/views/users-type-public-view.tsx | 7 ++++++- apps/web/pages/[user]/[type]/embed.tsx | 12 ++---------- apps/web/pages/[user]/[type]/index.tsx | 4 ++-- apps/web/pages/[user]/embed.tsx | 12 ++---------- apps/web/pages/[user]/index.tsx | 2 +- apps/web/pages/org/[orgSlug]/[user]/[type]/index.tsx | 2 +- apps/web/pages/org/[orgSlug]/[user]/index.tsx | 2 +- apps/web/scripts/vercel-app-router-deploy.sh | 1 - .../lib/[user]/[type]/getServerSideProps.ts} | 4 ---- .../lib/[user]/getServerSideProps.ts} | 2 +- 16 files changed, 35 insertions(+), 43 deletions(-) rename apps/web/{modules/users/views/users-type-public-view.getServerSideProps.tsx => server/lib/[user]/[type]/getServerSideProps.ts} (97%) rename apps/web/{modules/users/views/users-public-view.getServerSideProps.tsx => server/lib/[user]/getServerSideProps.ts} (99%) diff --git a/apps/web/app/future/[user]/[type]/embed/page.tsx b/apps/web/app/future/[user]/[type]/embed/page.tsx index 22db0557c9..3986b0b9ae 100644 --- a/apps/web/app/future/[user]/[type]/embed/page.tsx +++ b/apps/web/app/future/[user]/[type]/embed/page.tsx @@ -2,8 +2,11 @@ import { withAppDirSsr } from "app/WithAppDirSsr"; import withEmbedSsrAppDir from "app/WithEmbedSSR"; import { WithLayout } from "app/layoutHOC"; -import LegacyPage from "~/users/views/users-type-public-view"; -import { getServerSideProps, type PageProps } from "~/users/views/users-type-public-view.getServerSideProps"; +import { getServerSideProps } from "@server/lib/[user]/[type]/getServerSideProps"; + +import LegacyPage, { type PageProps } from "~/users/views/users-type-public-view"; + +export { generateMetadata } from "../page"; const getData = withAppDirSsr(getServerSideProps); diff --git a/apps/web/app/future/[user]/[type]/page.tsx b/apps/web/app/future/[user]/[type]/page.tsx index 024c56c91b..3a61c20e5b 100644 --- a/apps/web/app/future/[user]/[type]/page.tsx +++ b/apps/web/app/future/[user]/[type]/page.tsx @@ -9,11 +9,10 @@ import { EventRepository } from "@calcom/lib/server/repository/event"; import { buildLegacyCtx } from "@lib/buildLegacyCtx"; +import { getServerSideProps } from "@server/lib/[user]/[type]/getServerSideProps"; + +import type { PageProps as LegacyPageProps } from "~/users/views/users-type-public-view"; import LegacyPage from "~/users/views/users-type-public-view"; -import { - getServerSideProps, - type PageProps as LegacyPageProps, -} from "~/users/views/users-type-public-view.getServerSideProps"; export const generateMetadata = async ({ params, searchParams }: PageProps) => { const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams); diff --git a/apps/web/app/future/[user]/embed/page.tsx b/apps/web/app/future/[user]/embed/page.tsx index cb67b98397..5aae7be434 100644 --- a/apps/web/app/future/[user]/embed/page.tsx +++ b/apps/web/app/future/[user]/embed/page.tsx @@ -2,8 +2,12 @@ import { withAppDirSsr } from "app/WithAppDirSsr"; import withEmbedSsrAppDir from "app/WithEmbedSSR"; import { WithLayout } from "app/layoutHOC"; +import { getServerSideProps } from "@server/lib/[user]/getServerSideProps"; + +import type { PageProps as UserPageProps } from "~/users/views/users-public-view"; import LegacyPage from "~/users/views/users-public-view"; -import { getServerSideProps, type UserPageProps } from "~/users/views/users-public-view.getServerSideProps"; + +export { generateMetadata } from "../page"; const getData = withAppDirSsr(getServerSideProps); diff --git a/apps/web/app/future/[user]/page.tsx b/apps/web/app/future/[user]/page.tsx index 76871c3848..e26286d1d5 100644 --- a/apps/web/app/future/[user]/page.tsx +++ b/apps/web/app/future/[user]/page.tsx @@ -8,8 +8,10 @@ import { getLayout } from "@calcom/features/MainLayoutAppDir"; import { buildLegacyCtx } from "@lib/buildLegacyCtx"; +import { getServerSideProps } from "@server/lib/[user]/getServerSideProps"; + +import type { PageProps as LegacyPageProps } from "~/users/views/users-public-view"; import LegacyPage from "~/users/views/users-public-view"; -import { getServerSideProps, type UserPageProps } from "~/users/views/users-public-view.getServerSideProps"; export const generateMetadata = async ({ params, searchParams }: PageProps) => { const props = await getData(buildLegacyCtx(headers(), cookies(), params, searchParams)); @@ -21,5 +23,5 @@ export const generateMetadata = async ({ params, searchParams }: PageProps) => { ); }; -const getData = withAppDirSsr(getServerSideProps); +const getData = withAppDirSsr(getServerSideProps); export default WithLayout({ getLayout, getData, Page: LegacyPage })<"P">; diff --git a/apps/web/lib/org/[orgSlug]/[user]/[type]/getServerSideProps.tsx b/apps/web/lib/org/[orgSlug]/[user]/[type]/getServerSideProps.tsx index 452f5bef6c..0fe7c10c0c 100644 --- a/apps/web/lib/org/[orgSlug]/[user]/[type]/getServerSideProps.tsx +++ b/apps/web/lib/org/[orgSlug]/[user]/[type]/getServerSideProps.tsx @@ -7,7 +7,7 @@ import prisma from "@calcom/prisma"; import { getServerSideProps as GSSTeamTypePage } from "@lib/team/[slug]/[type]/getServerSideProps"; -import { getServerSideProps as GSSUserTypePage } from "~/users/views/users-type-public-view.getServerSideProps"; +import { getServerSideProps as GSSUserTypePage } from "@server/lib/[user]/[type]/getServerSideProps"; const paramsSchema = z.object({ orgSlug: z.string().transform((s) => slugify(s)), diff --git a/apps/web/modules/users/views/users-public-view.tsx b/apps/web/modules/users/views/users-public-view.tsx index f42ae41d5e..fe31046a93 100644 --- a/apps/web/modules/users/views/users-public-view.tsx +++ b/apps/web/modules/users/views/users-public-view.tsx @@ -18,7 +18,7 @@ import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery"; import useTheme from "@calcom/lib/hooks/useTheme"; import { HeadSeo, Icon, UnpublishedEntity, UserAvatar } from "@calcom/ui"; -import { type getServerSideProps } from "./users-public-view.getServerSideProps"; +import type { getServerSideProps } from "@server/lib/[user]/getServerSideProps"; export type PageProps = InferGetServerSidePropsType; export function UserPage(props: PageProps) { diff --git a/apps/web/modules/users/views/users-type-public-view.tsx b/apps/web/modules/users/views/users-type-public-view.tsx index e071569be9..5099ea9dda 100644 --- a/apps/web/modules/users/views/users-type-public-view.tsx +++ b/apps/web/modules/users/views/users-type-public-view.tsx @@ -6,7 +6,12 @@ import { Booker } from "@calcom/atoms/monorepo"; import { getBookerWrapperClasses } from "@calcom/features/bookings/Booker/utils/getBookerWrapperClasses"; import { BookerSeo } from "@calcom/features/bookings/components/BookerSeo"; -import { type PageProps } from "./users-type-public-view.getServerSideProps"; +import type { inferSSRProps } from "@lib/types/inferSSRProps"; +import type { EmbedProps } from "@lib/withEmbedSsr"; + +import type { getServerSideProps } from "@server/lib/[user]/[type]/getServerSideProps"; + +export type PageProps = inferSSRProps & EmbedProps; export const getMultipleDurationValue = ( multipleDurationConfig: number[] | undefined, diff --git a/apps/web/pages/[user]/[type]/embed.tsx b/apps/web/pages/[user]/[type]/embed.tsx index 4b8882841d..5fa5747255 100644 --- a/apps/web/pages/[user]/[type]/embed.tsx +++ b/apps/web/pages/[user]/[type]/embed.tsx @@ -1,15 +1,7 @@ import withEmbedSsr from "@lib/withEmbedSsr"; -import PageWrapper from "@components/PageWrapper"; - -import TypePage from "~/users/views/users-type-public-view"; -import type { PageProps } from "~/users/views/users-type-public-view.getServerSideProps"; -import { getServerSideProps as _getServerSideProps } from "~/users/views/users-type-public-view.getServerSideProps"; +import { getServerSideProps as _getServerSideProps } from "@server/lib/[user]/[type]/getServerSideProps"; export const getServerSideProps = withEmbedSsr(_getServerSideProps); -const Type = (props: PageProps) => ; - -Type.PageWrapper = PageWrapper; - -export default Type; +export { default } from "./index"; diff --git a/apps/web/pages/[user]/[type]/index.tsx b/apps/web/pages/[user]/[type]/index.tsx index 6b92d18f05..4e98c0bc99 100644 --- a/apps/web/pages/[user]/[type]/index.tsx +++ b/apps/web/pages/[user]/[type]/index.tsx @@ -1,9 +1,9 @@ import PageWrapper from "@components/PageWrapper"; +import type { PageProps } from "~/users/views/users-type-public-view"; import TypePage from "~/users/views/users-type-public-view"; -import type { PageProps } from "~/users/views/users-type-public-view.getServerSideProps"; -export { getServerSideProps } from "~/users/views/users-type-public-view.getServerSideProps"; +export { getServerSideProps } from "@server/lib/[user]/[type]/getServerSideProps"; const Type = (props: PageProps) => ; diff --git a/apps/web/pages/[user]/embed.tsx b/apps/web/pages/[user]/embed.tsx index 5c0a3bb1c3..066b82b7fb 100644 --- a/apps/web/pages/[user]/embed.tsx +++ b/apps/web/pages/[user]/embed.tsx @@ -1,14 +1,6 @@ import withEmbedSsr from "@lib/withEmbedSsr"; -import PageWrapper from "@components/PageWrapper"; - -import User, { type PageProps } from "~/users/views/users-public-view"; -import { getServerSideProps as _getServerSideProps } from "~/users/views/users-public-view.getServerSideProps"; - -const UserPage = (props: PageProps) => ; - -UserPage.PageWrapper = PageWrapper; - -export default UserPage; +import { getServerSideProps as _getServerSideProps } from "@server/lib/[user]/getServerSideProps"; +export { default } from "./index"; export const getServerSideProps = withEmbedSsr(_getServerSideProps); diff --git a/apps/web/pages/[user]/index.tsx b/apps/web/pages/[user]/index.tsx index ba62763f77..e01386f25f 100644 --- a/apps/web/pages/[user]/index.tsx +++ b/apps/web/pages/[user]/index.tsx @@ -2,7 +2,7 @@ import PageWrapper from "@components/PageWrapper"; import User, { type PageProps } from "~/users/views/users-public-view"; -export { getServerSideProps } from "~/users/views/users-public-view.getServerSideProps"; +export { getServerSideProps } from "@server/lib/[user]/getServerSideProps"; const UserPage = (props: PageProps) => ; diff --git a/apps/web/pages/org/[orgSlug]/[user]/[type]/index.tsx b/apps/web/pages/org/[orgSlug]/[user]/[type]/index.tsx index 152e5c7aad..67bf2539d0 100644 --- a/apps/web/pages/org/[orgSlug]/[user]/[type]/index.tsx +++ b/apps/web/pages/org/[orgSlug]/[user]/[type]/index.tsx @@ -5,7 +5,7 @@ import PageWrapper from "@components/PageWrapper"; import type { PageProps as TeamTypePageProps } from "~/team/type-view"; import TeamTypePage from "~/team/type-view"; import UserTypePage from "~/users/views/users-type-public-view"; -import type { PageProps as UserTypePageProps } from "~/users/views/users-type-public-view.getServerSideProps"; +import type { PageProps as UserTypePageProps } from "~/users/views/users-type-public-view"; export { getServerSideProps } from "@lib/org/[orgSlug]/[user]/[type]/getServerSideProps"; diff --git a/apps/web/pages/org/[orgSlug]/[user]/index.tsx b/apps/web/pages/org/[orgSlug]/[user]/index.tsx index 001514be6c..504830e7f6 100644 --- a/apps/web/pages/org/[orgSlug]/[user]/index.tsx +++ b/apps/web/pages/org/[orgSlug]/[user]/index.tsx @@ -5,7 +5,7 @@ import PageWrapper from "@components/PageWrapper"; import type { PageProps as TeamPageProps } from "~/team/team-view"; import TeamPage from "~/team/team-view"; import UserPage from "~/users/views/users-public-view"; -import { type UserPageProps } from "~/users/views/users-public-view.getServerSideProps"; +import type { PageProps as UserPageProps } from "~/users/views/users-public-view"; export { getServerSideProps } from "@lib/org/[orgSlug]/[user]/getServerSideProps"; diff --git a/apps/web/scripts/vercel-app-router-deploy.sh b/apps/web/scripts/vercel-app-router-deploy.sh index f8d4ceb863..ebe3402fca 100755 --- a/apps/web/scripts/vercel-app-router-deploy.sh +++ b/apps/web/scripts/vercel-app-router-deploy.sh @@ -39,7 +39,6 @@ checkRoute "$APP_ROUTER_CONNECT_AND_JOIN_ENABLED" app/future/connect-and-join # These are routes that don't have and environment variable to enable or disable them # Will stop removing gradually as we test and confirm that they are working rm -rf \ - app/future/[user]\ app/future/booking\ app/future/d\ app/future/enterprise\ diff --git a/apps/web/modules/users/views/users-type-public-view.getServerSideProps.tsx b/apps/web/server/lib/[user]/[type]/getServerSideProps.ts similarity index 97% rename from apps/web/modules/users/views/users-type-public-view.getServerSideProps.tsx rename to apps/web/server/lib/[user]/[type]/getServerSideProps.ts index 1e0e6fffa8..e041660d87 100644 --- a/apps/web/modules/users/views/users-type-public-view.getServerSideProps.tsx +++ b/apps/web/server/lib/[user]/[type]/getServerSideProps.ts @@ -15,10 +15,6 @@ import prisma from "@calcom/prisma"; import { RedirectType } from "@calcom/prisma/client"; import { getTemporaryOrgRedirect } from "@lib/getTemporaryOrgRedirect"; -import { type inferSSRProps } from "@lib/types/inferSSRProps"; -import { type EmbedProps } from "@lib/withEmbedSsr"; - -export type PageProps = inferSSRProps & EmbedProps; type Props = { eventData: Pick< diff --git a/apps/web/modules/users/views/users-public-view.getServerSideProps.tsx b/apps/web/server/lib/[user]/getServerSideProps.ts similarity index 99% rename from apps/web/modules/users/views/users-public-view.getServerSideProps.tsx rename to apps/web/server/lib/[user]/getServerSideProps.ts index 830834897d..534e3011e4 100644 --- a/apps/web/modules/users/views/users-public-view.getServerSideProps.tsx +++ b/apps/web/server/lib/[user]/getServerSideProps.ts @@ -23,7 +23,7 @@ import type { EmbedProps } from "@lib/withEmbedSsr"; import { ssrInit } from "@server/lib/ssr"; const log = logger.getSubLogger({ prefix: ["[[pages/[user]]]"] }); -export type UserPageProps = { +type UserPageProps = { trpcState: DehydratedState; profile: { name: string;