Scheduling infrastructure for absolutely everyone.
chore: migrate org domain /[user] page (#18715)
Benny Joo91225c03f3c7
diff --git a/apps/web/app/future/org/[orgSlug]/[user]/embed/page.tsx b/apps/web/app/future/org/[orgSlug]/[user]/embed/page.tsxindex 02c31c9929e..605dafa3331 100644--- a/apps/web/app/future/org/[orgSlug]/[user]/embed/page.tsx+++ b/apps/web/app/future/org/[orgSlug]/[user]/embed/page.tsx@@ -1,8 +1,21 @@-import { getServerSideProps, type PageProps } from "@pages/org/[orgSlug]/[user]";-import Page from "@pages/org/[orgSlug]/[user]/embed";import withEmbedSsrAppDir from "app/WithEmbedSSR";import { WithLayout } from "app/layoutHOC";+import type { OrgPageProps } from "app/org/[orgSlug]/[user]/page";-const getEmbedData = withEmbedSsrAppDir<PageProps>(getServerSideProps);+import { getServerSideProps } from "@lib/org/[orgSlug]/[user]/getServerSideProps";-export default WithLayout({ getLayout: null, getData: getEmbedData, isBookingPage: true, Page });+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 { PageProps as UserPageProps } from "~/users/views/users-public-view";++const getEmbedData = withEmbedSsrAppDir<OrgPageProps>(getServerSideProps);++const Page = async (props: OrgPageProps) => {+ if ((props as TeamPageProps)?.team) {+ return <TeamPage {...(props as TeamPageProps)} />;+ }+ return <UserPage {...(props as UserPageProps)} />;+};++export default WithLayout({ getLayout: null, getData: getEmbedData, isBookingPage: true, ServerPage: Page });diff --git a/apps/web/app/future/org/[orgSlug]/[user]/page.tsx b/apps/web/app/future/org/[orgSlug]/[user]/page.tsxdeleted file mode 100644index a783b6d61cf..00000000000--- a/apps/web/app/future/org/[orgSlug]/[user]/page.tsx+++ /dev/null@@ -1,7 +0,0 @@-import Page, { getServerSideProps, type PageProps } from "@pages/org/[orgSlug]/[user]";-import { withAppDirSsr } from "app/WithAppDirSsr";-import { WithLayout } from "app/layoutHOC";--const getData = withAppDirSsr<PageProps>(getServerSideProps);--export default WithLayout({ getLayout: null, getData, Page });diff --git a/apps/web/app/org/[orgSlug]/[user]/page.tsx b/apps/web/app/org/[orgSlug]/[user]/page.tsxnew file mode 100644index 00000000000..519b2c2aaa7--- /dev/null+++ b/apps/web/app/org/[orgSlug]/[user]/page.tsx@@ -0,0 +1,87 @@+import { withAppDirSsr } from "app/WithAppDirSsr";+import type { PageProps } from "app/_types";+import { generateMeetingMetadata } from "app/_utils";+import { WithLayout } from "app/layoutHOC";+import { cookies, headers } from "next/headers";++import { getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";+import { getOrgOrTeamAvatar } from "@calcom/lib/defaultAvatarImage";++import { buildLegacyCtx } from "@lib/buildLegacyCtx";+import { getServerSideProps } from "@lib/org/[orgSlug]/[user]/getServerSideProps";++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 { PageProps as UserPageProps } from "~/users/views/users-public-view";++export type OrgPageProps = UserPageProps | TeamPageProps;+const getData = withAppDirSsr<OrgPageProps>(getServerSideProps);++export const generateMetadata = async ({ params, searchParams }: PageProps) => {+ const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);+ const props = await getData(legacyCtx);++ if ((props as TeamPageProps)?.team) {+ const { team, markdownStrippedBio, isSEOIndexable, currentOrgDomain } = props as TeamPageProps;+ const meeting = {+ title: markdownStrippedBio ?? "",+ profile: {+ name: `${team.name}`,+ image: getOrgOrTeamAvatar(team),+ },+ };++ return {+ ...(await generateMeetingMetadata(+ meeting,+ (t) => team.name ?? t("nameless_team"),+ (t) => team.name ?? t("nameless_team"),+ false,+ getOrgFullOrigin(currentOrgDomain ?? null)+ )),+ robots: {+ index: isSEOIndexable,+ follow: isSEOIndexable,+ },+ };+ } else {+ const { profile, markdownStrippedBio, isOrgSEOIndexable, entity } = props as UserPageProps;++ const meeting = {+ title: markdownStrippedBio,+ profile: { name: `${profile.name}`, image: profile.image },+ users: [+ {+ username: `${profile.username ?? ""}`,+ name: `${profile.name ?? ""}`,+ },+ ],+ };+ const isOrg = !!profile?.organization;+ const allowSEOIndexing =+ (!isOrg && profile.allowSEOIndexing) || (isOrg && isOrgSEOIndexable && profile.allowSEOIndexing);+ return {+ ...(await generateMeetingMetadata(+ meeting,+ () => profile.name,+ () => markdownStrippedBio,+ false,+ getOrgFullOrigin(entity.orgSlug ?? null)+ )),+ robots: {+ index: allowSEOIndexing,+ follow: allowSEOIndexing,+ },+ };+ }+};++const Page = async (props: OrgPageProps) => {+ if ((props as TeamPageProps)?.team) {+ return <TeamPage {...(props as TeamPageProps)} />;+ }+ return <UserPage {...(props as UserPageProps)} />;+};++export default WithLayout({ getLayout: null, getData, ServerPage: Page, isBookingPage: true });diff --git a/apps/web/middleware.ts b/apps/web/middleware.tsindex 027ba5cc6bc..69b4dd4dfb2 100644--- a/apps/web/middleware.ts+++ b/apps/web/middleware.ts@@ -200,10 +200,7 @@ export const config = {"/booking/:path*","/routing-forms/:path*","/team/:path*",- "/org/[orgSlug]/[user]/[type]",- "/org/[orgSlug]/team/[slug]/[type]",- "/org/[orgSlug]/team/[slug]",- "/org/[orgSlug]",+ "/org/:path*",],};diff --git a/apps/web/pages/org/[orgSlug]/[user]/embed.tsx b/apps/web/pages/org/[orgSlug]/[user]/embed.tsxindex 6317514b2d6..d47b7aa5918 100644--- a/apps/web/pages/org/[orgSlug]/[user]/embed.tsx+++ b/apps/web/pages/org/[orgSlug]/[user]/embed.tsx@@ -1,9 +1,24 @@"use client";+import { getServerSideProps as _getServerSideProps } from "@lib/org/[orgSlug]/[user]/getServerSideProps";import withEmbedSsr from "@lib/withEmbedSsr";-import { getServerSideProps as _getServerSideProps } from "../[user]";+import PageWrapper from "@components/PageWrapper";-export { default } from "../[user]";+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 { PageProps as UserPageProps } from "~/users/views/users-public-view";export const getServerSideProps = withEmbedSsr(_getServerSideProps);++export type PageProps = UserPageProps | TeamPageProps;++function Page(props: PageProps) {+ if ((props as TeamPageProps)?.team) return <TeamPage {...(props as TeamPageProps)} />;+ return <UserPage {...(props as UserPageProps)} />;+}++Page.PageWrapper = PageWrapper;++export default Page;diff --git a/apps/web/pages/org/[orgSlug]/[user]/index.tsx b/apps/web/pages/org/[orgSlug]/[user]/index.tsxdeleted file mode 100644index 504830e7f62..00000000000--- a/apps/web/pages/org/[orgSlug]/[user]/index.tsx+++ /dev/null@@ -1,21 +0,0 @@-"use client";--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 { PageProps as UserPageProps } from "~/users/views/users-public-view";--export { getServerSideProps } from "@lib/org/[orgSlug]/[user]/getServerSideProps";--export type PageProps = UserPageProps | TeamPageProps;--function Page(props: PageProps) {- if ((props as TeamPageProps)?.team) return <TeamPage {...(props as TeamPageProps)} />;- return <UserPage {...(props as UserPageProps)} />;-}--Page.PageWrapper = PageWrapper;--export default Page;