Skip to content

Scheduling infrastructure for absolutely everyone.

chore: migrate /org team pages and team type pages and user type page (#18668)

Benny Joocce6e83578b9
diff --git a/apps/web/app/future/org/[orgSlug]/[user]/[type]/embed/page.tsx b/apps/web/app/future/org/[orgSlug]/[user]/[type]/embed/page.tsx
index 4cbd35891fd..b246540b8e8 100644
--- a/apps/web/app/future/org/[orgSlug]/[user]/[type]/embed/page.tsx
+++ b/apps/web/app/future/org/[orgSlug]/[user]/[type]/embed/page.tsx
@@ -1,10 +1,10 @@
-import { type PageProps } from "@pages/org/[orgSlug]/[user]/[type]";
import Page from "@pages/org/[orgSlug]/[user]/[type]/embed";
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import { WithLayout } from "app/layoutHOC";
+import type { OrgTypePageProps } from "app/org/[orgSlug]/[user]/[type]/page";
import { getServerSideProps } from "@lib/org/[orgSlug]/[user]/[type]/getServerSideProps";
-const getEmbedData = withEmbedSsrAppDir<PageProps>(getServerSideProps);
+const getEmbedData = withEmbedSsrAppDir<OrgTypePageProps>(getServerSideProps);
export default WithLayout({ getLayout: null, getData: getEmbedData, isBookingPage: true, Page });
diff --git a/apps/web/app/future/org/[orgSlug]/[user]/[type]/page.tsx b/apps/web/app/future/org/[orgSlug]/[user]/[type]/page.tsx
deleted file mode 100644
index b96a381cef1..00000000000
--- a/apps/web/app/future/org/[orgSlug]/[user]/[type]/page.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import Page, { type PageProps } from "@pages/org/[orgSlug]/[user]/[type]";
-import { withAppDirSsr } from "app/WithAppDirSsr";
-import { WithLayout } from "app/layoutHOC";
-
-import { getServerSideProps } from "@lib/org/[orgSlug]/[user]/[type]/getServerSideProps";
-
-const getData = withAppDirSsr<PageProps>(getServerSideProps);
-
-export default WithLayout({ getLayout: null, getData, Page });
diff --git a/apps/web/app/future/org/[orgSlug]/page.tsx b/apps/web/app/future/org/[orgSlug]/page.tsx
deleted file mode 100644
index 745d7e9547e..00000000000
--- a/apps/web/app/future/org/[orgSlug]/page.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { withAppDirSsr } from "app/WithAppDirSsr";
-import type { PageProps as _PageProps } from "app/_types";
-import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
-import { cookies, headers } from "next/headers";
-
-import { buildLegacyCtx } from "@lib/buildLegacyCtx";
-import { getServerSideProps } from "@lib/team/[slug]/getServerSideProps";
-
-import type { PageProps } from "~/team/team-view";
-import TeamPage from "~/team/team-view";
-
-export const generateMetadata = async ({ params, searchParams }: _PageProps) => {
- const props = await getData(buildLegacyCtx(headers(), cookies(), params, searchParams));
-
- return await _generateMetadata(
- (t) => props.team.name || t("nameless_team"),
- (t) => props.team.name || t("nameless_team")
- );
-};
-
-const getData = withAppDirSsr<PageProps>(getServerSideProps);
-
-export default WithLayout({
- Page: TeamPage,
- getData,
- getLayout: null,
- isBookingPage: true,
-})<"P">;
diff --git a/apps/web/app/future/org/[orgSlug]/team/[slug]/[type]/page.tsx b/apps/web/app/future/org/[orgSlug]/team/[slug]/[type]/page.tsx
deleted file mode 100644
index ea51f5cd9b7..00000000000
--- a/apps/web/app/future/org/[orgSlug]/team/[slug]/[type]/page.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { withAppDirSsr } from "app/WithAppDirSsr";
-import type { PageProps as _PageProps } from "app/_types";
-import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
-import { cookies, headers } from "next/headers";
-
-import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
-import { EventRepository } from "@calcom/lib/server/repository/event";
-
-import { buildLegacyCtx } from "@lib/buildLegacyCtx";
-import { getServerSideProps } from "@lib/team/[slug]/[type]/getServerSideProps";
-
-import type { PageProps } from "~/team/type-view";
-import TypePage from "~/team/type-view";
-
-export const generateMetadata = async ({ params, searchParams }: _PageProps) => {
- const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);
- const props = await getData(legacyCtx);
- const { user: username, slug: eventSlug, booking } = props;
- const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(legacyCtx.req, legacyCtx.params?.orgSlug);
-
- const event = await EventRepository.getPublicEvent({
- username,
- eventSlug,
- isTeamEvent: true,
- org: isValidOrgDomain ? currentOrgDomain : null,
- fromRedirectOfNonOrgLink: legacyCtx.query.orgRedirection === "true",
- });
-
- const profileName = event?.profile?.name ?? "";
- const title = event?.title ?? "";
-
- return await _generateMetadata(
- (t) => `${booking?.uid && !!booking ? t("reschedule") : ""} ${title} | ${profileName}`,
- (t) => `${booking?.uid ? t("reschedule") : ""} ${title}`
- );
-};
-const getData = withAppDirSsr<PageProps>(getServerSideProps);
-
-export default WithLayout({
- Page: TypePage,
- getData,
- getLayout: null,
- isBookingPage: true,
-})<"P">;
diff --git a/apps/web/app/future/org/[orgSlug]/team/[slug]/page.tsx b/apps/web/app/future/org/[orgSlug]/team/[slug]/page.tsx
deleted file mode 100644
index 745d7e9547e..00000000000
--- a/apps/web/app/future/org/[orgSlug]/team/[slug]/page.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { withAppDirSsr } from "app/WithAppDirSsr";
-import type { PageProps as _PageProps } from "app/_types";
-import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
-import { cookies, headers } from "next/headers";
-
-import { buildLegacyCtx } from "@lib/buildLegacyCtx";
-import { getServerSideProps } from "@lib/team/[slug]/getServerSideProps";
-
-import type { PageProps } from "~/team/team-view";
-import TeamPage from "~/team/team-view";
-
-export const generateMetadata = async ({ params, searchParams }: _PageProps) => {
- const props = await getData(buildLegacyCtx(headers(), cookies(), params, searchParams));
-
- return await _generateMetadata(
- (t) => props.team.name || t("nameless_team"),
- (t) => props.team.name || t("nameless_team")
- );
-};
-
-const getData = withAppDirSsr<PageProps>(getServerSideProps);
-
-export default WithLayout({
- Page: TeamPage,
- getData,
- getLayout: null,
- isBookingPage: true,
-})<"P">;
diff --git a/apps/web/app/org/[orgSlug]/[user]/[type]/page.tsx b/apps/web/app/org/[orgSlug]/[user]/[type]/page.tsx
new file mode 100644
index 00000000000..2576c97df83
--- /dev/null
+++ b/apps/web/app/org/[orgSlug]/[user]/[type]/page.tsx
@@ -0,0 +1,64 @@
+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 { buildLegacyCtx } from "@lib/buildLegacyCtx";
+import { getServerSideProps } from "@lib/org/[orgSlug]/[user]/[type]/getServerSideProps";
+
+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";
+
+export type OrgTypePageProps = UserTypePageProps | TeamTypePageProps;
+const getData = withAppDirSsr<OrgTypePageProps>(getServerSideProps);
+
+export const generateMetadata = async ({ params, searchParams }: PageProps) => {
+ const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);
+ const props = await getData(legacyCtx);
+
+ const { booking, isSEOIndexable, eventData, isBrandingHidden } = props;
+ const rescheduleUid = booking?.uid;
+
+ const profileName = eventData?.profile?.name ?? "";
+ const profileImage = eventData?.profile.image;
+ const title = eventData?.title ?? "";
+ const meeting = {
+ title,
+ profile: { name: profileName, image: profileImage },
+ users: [
+ ...(eventData?.users || []).map((user) => ({
+ name: `${user.name}`,
+ username: `${user.username}`,
+ })),
+ ],
+ };
+ const metadata = await generateMeetingMetadata(
+ meeting,
+ (t) => `${rescheduleUid && !!booking ? t("reschedule") : ""} ${title} | ${profileName}`,
+ (t) => `${rescheduleUid ? t("reschedule") : ""} ${title}`,
+ isBrandingHidden,
+ getOrgFullOrigin(eventData?.entity.orgSlug ?? null)
+ );
+
+ return {
+ ...metadata,
+ robots: {
+ follow: !(eventData?.hidden || !isSEOIndexable),
+ index: !(eventData?.hidden || !isSEOIndexable),
+ },
+ };
+};
+
+export const Page = async (props: OrgTypePageProps) => {
+ if ((props as TeamTypePageProps)?.teamId) {
+ return <TeamTypePage {...(props as TeamTypePageProps)} />;
+ }
+ return <UserTypePage {...(props as UserTypePageProps)} />;
+};
+
+export default WithLayout({ getLayout: null, getData, ServerPage: Page, isBookingPage: true });
diff --git a/apps/web/app/org/[orgSlug]/page.tsx b/apps/web/app/org/[orgSlug]/page.tsx
new file mode 100644
index 00000000000..99b51c0aa24
--- /dev/null
+++ b/apps/web/app/org/[orgSlug]/page.tsx
@@ -0,0 +1 @@
+export { default, generateMetadata } from "app/team/[slug]/page";
diff --git a/apps/web/app/org/[orgSlug]/team/[slug]/[type]/page.tsx b/apps/web/app/org/[orgSlug]/team/[slug]/[type]/page.tsx
new file mode 100644
index 00000000000..ebcf985632d
--- /dev/null
+++ b/apps/web/app/org/[orgSlug]/team/[slug]/[type]/page.tsx
@@ -0,0 +1 @@
+export { default, generateMetadata } from "app/team/[slug]/[type]/page";
diff --git a/apps/web/app/org/[orgSlug]/team/[slug]/page.tsx b/apps/web/app/org/[orgSlug]/team/[slug]/page.tsx
new file mode 100644
index 00000000000..99b51c0aa24
--- /dev/null
+++ b/apps/web/app/org/[orgSlug]/team/[slug]/page.tsx
@@ -0,0 +1 @@
+export { default, generateMetadata } from "app/team/[slug]/page";
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts
index 485f77355f5..e951ebe6dd9 100644
--- a/apps/web/middleware.ts
+++ b/apps/web/middleware.ts
@@ -187,6 +187,10 @@ 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]",
],
};
diff --git a/apps/web/pages/org/[orgSlug]/[user]/[type]/embed.tsx b/apps/web/pages/org/[orgSlug]/[user]/[type]/embed.tsx
index a3752b2a3b8..d8eb17df858 100644
--- a/apps/web/pages/org/[orgSlug]/[user]/[type]/embed.tsx
+++ b/apps/web/pages/org/[orgSlug]/[user]/[type]/embed.tsx
@@ -1,7 +1,20 @@
+import { getServerSideProps as _getServerSideProps } from "@lib/org/[orgSlug]/[user]/[type]/getServerSideProps";
import withEmbedSsr from "@lib/withEmbedSsr";
-import { getServerSideProps as _getServerSideProps } from ".";
+import PageWrapper from "@components/PageWrapper";
-export { default, type PageProps } from ".";
+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";
+
+export type PageProps = UserTypePageProps | TeamTypePageProps;
+
+export default function Page(props: PageProps) {
+ if ((props as TeamTypePageProps)?.teamId) return <TeamTypePage {...(props as TeamTypePageProps)} />;
+ return <UserTypePage {...(props as UserTypePageProps)} />;
+}
+
+Page.PageWrapper = PageWrapper;
export const getServerSideProps = withEmbedSsr(_getServerSideProps);
diff --git a/apps/web/pages/org/[orgSlug]/[user]/[type]/index.tsx b/apps/web/pages/org/[orgSlug]/[user]/[type]/index.tsx
deleted file mode 100644
index 1b876a36c1c..00000000000
--- a/apps/web/pages/org/[orgSlug]/[user]/[type]/index.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-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";
-
-export { getServerSideProps } from "@lib/org/[orgSlug]/[user]/[type]/getServerSideProps";
-
-export type PageProps = UserTypePageProps | TeamTypePageProps;
-
-export default function Page(props: PageProps) {
- if ((props as TeamTypePageProps)?.teamId) return <TeamTypePage {...(props as TeamTypePageProps)} />;
- return <UserTypePage {...(props as UserTypePageProps)} />;
-}
-
-Page.PageWrapper = PageWrapper;
diff --git a/apps/web/pages/org/[orgSlug]/embed.tsx b/apps/web/pages/org/[orgSlug]/embed.tsx
index 97a9a1c4e93..582eb8f7836 100644
--- a/apps/web/pages/org/[orgSlug]/embed.tsx
+++ b/apps/web/pages/org/[orgSlug]/embed.tsx
@@ -1,7 +1,14 @@
+import { getServerSideProps as _getServerSideProps } from "@lib/team/[slug]/getServerSideProps";
import withEmbedSsr from "@lib/withEmbedSsr";
-import { getServerSideProps as _getServerSideProps } from "./index";
+import PageWrapper from "@components/PageWrapper";
-export { default } from "./index";
+import TeamPage, { type PageProps } from "~/team/team-view";
+
+const Page = (props: PageProps) => <TeamPage {...props} />;
+
+Page.PageWrapper = PageWrapper;
+
+export default Page;
export const getServerSideProps = withEmbedSsr(_getServerSideProps);
diff --git a/apps/web/pages/org/[orgSlug]/index.tsx b/apps/web/pages/org/[orgSlug]/index.tsx
deleted file mode 100644
index 34386176f19..00000000000
--- a/apps/web/pages/org/[orgSlug]/index.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import PageWrapper from "@components/PageWrapper";
-
-import TeamPage, { type PageProps } from "~/team/team-view";
-
-const Page = (props: PageProps) => <TeamPage {...props} />;
-
-Page.PageWrapper = PageWrapper;
-
-export default Page;
-export { getServerSideProps } from "@lib/team/[slug]/getServerSideProps";
diff --git a/apps/web/pages/org/[orgSlug]/team/[slug]/[type].tsx b/apps/web/pages/org/[orgSlug]/team/[slug]/[type].tsx
deleted file mode 100644
index 160c0ec36c5..00000000000
--- a/apps/web/pages/org/[orgSlug]/team/[slug]/[type].tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { BookerSeo } from "@calcom/features/bookings/components/BookerSeo";
-
-import PageWrapper from "@components/PageWrapper";
-
-import type { PageProps } from "~/team/type-view";
-import TypePage from "~/team/type-view";
-
-const Page = (props: PageProps) => {
- const { eventData, slug, user, booking, isBrandingHidden, isSEOIndexable } = props;
- const { profile, users, hidden, title } = eventData;
-
- return (
- <>
- <BookerSeo
- username={user}
- eventSlug={slug}
- rescheduleUid={booking?.uid}
- hideBranding={isBrandingHidden}
- isTeamEvent
- eventData={
- profile && users && title && hidden !== undefined
- ? {
- profile,
- users,
- title,
- hidden,
- }
- : undefined
- }
- entity={eventData.entity}
- bookingData={booking}
- isSEOIndexable={isSEOIndexable}
- />
- <TypePage {...props} />
- </>
- );
-};
-Page.isBookingPage = true;
-Page.PageWrapper = PageWrapper;
-
-export { getServerSideProps } from "@lib/team/[slug]/[type]/getServerSideProps";
-export default Page;
diff --git a/apps/web/pages/org/[orgSlug]/team/[slug]/index.ts b/apps/web/pages/org/[orgSlug]/team/[slug]/index.ts
deleted file mode 100644
index 602e114448f..00000000000
--- a/apps/web/pages/org/[orgSlug]/team/[slug]/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { getServerSideProps, default } from "@pages/org/[orgSlug]/index";