diff --git a/apps/web/lib/team/[slug]/[type]/getServerSideProps.tsx b/apps/web/lib/team/[slug]/[type]/getServerSideProps.tsx index 3da2c942ff..daf660146a 100644 --- a/apps/web/lib/team/[slug]/[type]/getServerSideProps.tsx +++ b/apps/web/lib/team/[slug]/[type]/getServerSideProps.tsx @@ -5,7 +5,11 @@ import { getServerSession } from "@calcom/features/auth/lib/getServerSession"; import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking"; import { getBookingForReschedule } from "@calcom/features/bookings/lib/get-booking"; import { getSlugOrRequestedSlug, orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains"; +import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage"; +import { getUsernameList } from "@calcom/lib/defaultEvents"; +import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client"; import { OrganizationRepository } from "@calcom/lib/server/repository/organization"; +import { UserRepository } from "@calcom/lib/server/repository/user"; import slugify from "@calcom/lib/slugify"; import prisma from "@calcom/prisma"; import { RedirectType } from "@calcom/prisma/client"; @@ -57,6 +61,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => slug: true, name: true, bannerUrl: true, + logoUrl: true, organizationSettings: { select: { allowSEOIndexing: true, @@ -64,6 +69,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => }, }, }, + logoUrl: true, name: true, slug: true, eventTypes: { @@ -72,10 +78,12 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => }, select: { id: true, + title: true, isInstantEvent: true, schedulingType: true, metadata: true, length: true, + hidden: true, }, }, isOrganization: true, @@ -93,6 +101,18 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => } as const; } + // INFO: This code was pulled from getPublicEvent and used here. + // Calling the tRPC fetch to get the public event data is incredibly slow + // for large teams and we don't want to add it back. Future refactors will happen + // to speed up this call. + const usernameList = getUsernameList(teamSlug); + const orgSlug = isValidOrgDomain ? currentOrgDomain : null; + const name = team.parent?.name ?? team.name ?? null; + const usersInOrgContext = await UserRepository.findUsersByUsername({ + usernameList, + orgSlug: team.parent?.slug || null, + }); + const eventData = team.eventTypes[0]; const eventTypeId = eventData.id; @@ -119,6 +139,12 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => const organizationSettings = OrganizationRepository.utils.getOrganizationSEOSettings(team); const allowSEOIndexing = organizationSettings?.allowSEOIndexing ?? false; + if (!eventData) { + return { + notFound: true, + } as const; + } + return { props: { eventData: { @@ -126,12 +152,26 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => entity: { fromRedirectOfNonOrgLink, considerUnpublished: isUnpublished && !fromRedirectOfNonOrgLink, - orgSlug: isValidOrgDomain ? currentOrgDomain : null, + orgSlug, teamSlug: team.slug ?? null, - name: team.parent?.name ?? team.name ?? null, + name, }, length: eventData.length, metadata: EventTypeMetaDataSchema.parse(eventData.metadata), + profile: { + image: team.parent + ? getPlaceholderAvatar(team.parent.logoUrl, team.parent.name) + : getPlaceholderAvatar(team.logoUrl, team.name), + name, + username: orgSlug ?? null, + }, + title: eventData.title, + users: usersInOrgContext.map((user) => ({ + ...user, + metadata: undefined, + bookerUrl: getBookerBaseUrlSync(user.profile?.organization?.slug ?? null), + })), + hidden: eventData.hidden, }, booking, user: teamSlug, diff --git a/apps/web/modules/team/type-view.tsx b/apps/web/modules/team/type-view.tsx index 4a7aa849f2..6e4c7278e5 100644 --- a/apps/web/modules/team/type-view.tsx +++ b/apps/web/modules/team/type-view.tsx @@ -37,6 +37,7 @@ function Type({ isSEOIndexable, }: PageProps) { const searchParams = useSearchParams(); + const { profile, users, hidden, title } = eventData; return (
@@ -46,6 +47,16 @@ function Type({ rescheduleUid={booking?.uid} hideBranding={isBrandingHidden} isTeamEvent + eventData={ + profile && users && title && hidden !== undefined + ? { + profile, + users, + title, + hidden, + } + : undefined + } entity={eventData.entity} bookingData={booking} isSEOIndexable={isSEOIndexable} 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 903e3dad4c..6ef31d5a69 100644 --- a/apps/web/modules/users/views/users-type-public-view.tsx +++ b/apps/web/modules/users/views/users-type-public-view.tsx @@ -35,7 +35,7 @@ function Type({ orgBannerUrl, }: PageProps) { const searchParams = useSearchParams(); - + const { profile, users, hidden, title } = eventData; return (