diff --git a/apps/web/app/future/org/[orgSlug]/[user]/embed/page.tsx b/apps/web/app/future/org/[orgSlug]/[user]/embed/page.tsx index 02c31c9929..605dafa333 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(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(getServerSideProps); + +const Page = async (props: OrgPageProps) => { + if ((props as TeamPageProps)?.team) { + return ; + } + return ; +}; + +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.tsx deleted file mode 100644 index a783b6d61c..0000000000 --- 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(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.tsx new file mode 100644 index 0000000000..519b2c2aaa --- /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(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 ; + } + return ; +}; + +export default WithLayout({ getLayout: null, getData, ServerPage: Page, isBookingPage: true }); diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index 027ba5cc6b..69b4dd4dfb 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.tsx index 6317514b2d..d47b7aa591 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 ; + return ; +} + +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.tsx deleted file mode 100644 index 504830e7f6..0000000000 --- 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 ; - return ; -} - -Page.PageWrapper = PageWrapper; - -export default Page;