forked from calcom/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve import type Finalize support isBookingPage finalize fix Fix build error fix type errors
- Loading branch information
Showing
19 changed files
with
369 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getServerSideProps } from "@pages/team/[slug]/[type]"; | ||
import { withAppDir } from "app/AppDirSSRHOC"; | ||
import type { PageProps } from "app/_types"; | ||
import type { GetServerSidePropsContext } from "next"; | ||
import { cookies, headers } from "next/headers"; | ||
|
||
import { buildLegacyCtx } from "@lib/buildLegacyCtx"; | ||
import withEmbedSsr from "@lib/withEmbedSsr"; | ||
|
||
const Page = async ({ params }: PageProps) => { | ||
const legacyCtx = buildLegacyCtx(headers(), cookies(), params); | ||
|
||
await withAppDir(withEmbedSsr(getServerSideProps))(legacyCtx as unknown as GetServerSidePropsContext); | ||
|
||
return null; | ||
}; | ||
|
||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import LegacyPage, { | ||
type PageProps, | ||
getServerSideProps as _getServerSideProps, | ||
} from "@pages/team/[slug]/[type]"; | ||
import { withAppDir } from "app/AppDirSSRHOC"; | ||
import { _generateMetadata } from "app/_utils"; | ||
import { WithLayout } from "app/layoutHOC"; | ||
|
||
export const generateMetadata = async () => | ||
await _generateMetadata( | ||
() => "", | ||
() => "" | ||
); | ||
const getData = withAppDir<PageProps>(_getServerSideProps); | ||
|
||
export default WithLayout({ | ||
Page: LegacyPage, | ||
getData, | ||
getLayout: null, | ||
isBookingPage: true, | ||
})<"P">; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getServerSideProps } from "@pages/team/[slug]"; | ||
import { withAppDir } from "app/AppDirSSRHOC"; | ||
import type { PageProps } from "app/_types"; | ||
import type { GetServerSidePropsContext } from "next"; | ||
import { cookies, headers } from "next/headers"; | ||
|
||
import { buildLegacyCtx } from "@lib/buildLegacyCtx"; | ||
import withEmbedSsr from "@lib/withEmbedSsr"; | ||
|
||
const Page = async ({ params }: PageProps) => { | ||
const legacyCtx = buildLegacyCtx(headers(), cookies(), params); | ||
|
||
await withAppDir(withEmbedSsr(getServerSideProps))(legacyCtx as unknown as GetServerSidePropsContext); | ||
|
||
return null; | ||
}; | ||
|
||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import LegacyPage, { type PageProps, getServerSideProps as _getServerSideProps } from "@pages/team/[slug]"; | ||
import { withAppDir } from "app/AppDirSSRHOC"; | ||
import { _generateMetadata } from "app/_utils"; | ||
import { WithLayout } from "app/layoutHOC"; | ||
import { type GetServerSidePropsContext } from "next"; | ||
import { cookies, headers } from "next/headers"; | ||
|
||
import { buildLegacyCtx } from "@lib/buildLegacyCtx"; | ||
|
||
export const generateMetadata = async ({ params }: { params: Record<string, string | string[]> }) => { | ||
const props = await getData( | ||
buildLegacyCtx(headers(), cookies(), params) as unknown as GetServerSidePropsContext | ||
); | ||
const teamName = props.team.name || "Nameless Team"; | ||
|
||
return await _generateMetadata( | ||
() => teamName, | ||
() => teamName | ||
); | ||
}; | ||
|
||
const getData = withAppDir<PageProps>(_getServerSideProps); | ||
|
||
export default WithLayout({ | ||
Page: LegacyPage, | ||
getData, | ||
getLayout: null, | ||
isBookingPage: true, | ||
})<"P">; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import type { GetServerSidePropsContext } from "next"; | ||
import { z } from "zod"; | ||
|
||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession"; | ||
import { getBookingForReschedule, getMultipleDurationValue } from "@calcom/features/bookings/lib/get-booking"; | ||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking"; | ||
import { getSlugOrRequestedSlug } from "@calcom/features/ee/organizations/lib/orgDomains"; | ||
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains"; | ||
import slugify from "@calcom/lib/slugify"; | ||
import prisma from "@calcom/prisma"; | ||
import { RedirectType } from "@calcom/prisma/client"; | ||
|
||
import { getTemporaryOrgRedirect } from "@lib/getTemporaryOrgRedirect"; | ||
|
||
const paramsSchema = z.object({ | ||
type: z.string().transform((s) => slugify(s)), | ||
slug: z.string().transform((s) => slugify(s)), | ||
}); | ||
|
||
// Booker page fetches a tiny bit of data server side: | ||
// 1. Check if team exists, to show 404 | ||
// 2. If rescheduling, get the booking details | ||
export const getServerSideProps = async (context: GetServerSidePropsContext) => { | ||
const session = await getServerSession(context); | ||
const { slug: teamSlug, type: meetingSlug } = paramsSchema.parse(context.params); | ||
const { rescheduleUid, duration: queryDuration, isInstantMeeting: queryIsInstantMeeting } = context.query; | ||
const { ssrInit } = await import("@server/lib/ssr"); | ||
const ssr = await ssrInit(context); | ||
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req, context.params?.orgSlug); | ||
const isOrgContext = currentOrgDomain && isValidOrgDomain; | ||
|
||
if (!isOrgContext) { | ||
const redirect = await getTemporaryOrgRedirect({ | ||
slug: teamSlug, | ||
redirectType: RedirectType.Team, | ||
eventTypeSlug: meetingSlug, | ||
currentQuery: context.query, | ||
}); | ||
|
||
if (redirect) { | ||
return redirect; | ||
} | ||
} | ||
|
||
const team = await prisma.team.findFirst({ | ||
where: { | ||
...getSlugOrRequestedSlug(teamSlug), | ||
parent: isValidOrgDomain && currentOrgDomain ? getSlugOrRequestedSlug(currentOrgDomain) : null, | ||
}, | ||
select: { | ||
id: true, | ||
hideBranding: true, | ||
}, | ||
}); | ||
|
||
if (!team) { | ||
return { | ||
notFound: true, | ||
} as const; | ||
} | ||
|
||
let booking: GetBookingType | null = null; | ||
if (rescheduleUid) { | ||
booking = await getBookingForReschedule(`${rescheduleUid}`, session?.user?.id); | ||
} | ||
|
||
const org = isValidOrgDomain ? currentOrgDomain : null; | ||
// We use this to both prefetch the query on the server, | ||
// as well as to check if the event exist, so we c an show a 404 otherwise. | ||
const eventData = await ssr.viewer.public.event.fetch({ | ||
username: teamSlug, | ||
eventSlug: meetingSlug, | ||
isTeamEvent: true, | ||
org, | ||
}); | ||
|
||
if (!eventData) { | ||
return { | ||
notFound: true, | ||
} as const; | ||
} | ||
|
||
return { | ||
props: { | ||
entity: eventData.entity, | ||
duration: getMultipleDurationValue( | ||
eventData.metadata?.multipleDuration, | ||
queryDuration, | ||
eventData.length | ||
), | ||
booking, | ||
away: false, | ||
user: teamSlug, | ||
teamId: team.id, | ||
slug: meetingSlug, | ||
trpcState: ssr.dehydrate(), | ||
isBrandingHidden: team?.hideBranding, | ||
isInstantMeeting: eventData.isInstantEvent && queryIsInstantMeeting ? true : false, | ||
themeBasis: null, | ||
}, | ||
}; | ||
}; |
Oops, something went wrong.