fix: Broken SSR for event booking pages (#14497)

* fix: Broken SSR for event type pages

* Add test

* Consider requestedSlug as well for instances that require payment

* Add a todo test
This commit is contained in:
Hariom Balhara authored and GitHub committed 2024-04-11 10:57:15 +01:00
1 parent 621067acd8
commit aa2808d621
9 files changed
+83 -8

No files matched your search

@@ -25,7 +25,12 @@ export const useEvent = () => {
const org = useBookerStore((state) => state.org);
const event = trpc.viewer.public.event.useQuery(
{ username: username ?? "", eventSlug: eventSlug ?? "", isTeamEvent, org: org ?? null },
{
username: username ?? "",
eventSlug: eventSlug ?? "",
isTeamEvent,
org: org ?? null,
},
{ refetchOnWindowFocus: false, enabled: Boolean(username) && Boolean(eventSlug) }
);
@@ -11,6 +11,7 @@ interface BookerSeoProps {
isSEOIndexable?: boolean;
isTeamEvent?: boolean;
entity: {
fromRedirectOfNonOrgLink: boolean;
orgSlug?: string | null;
teamSlug?: string | null;
name?: string | null;
@@ -31,7 +32,13 @@ export const BookerSeo = (props: BookerSeoProps) => {
} = props;
const { t } = useLocale();
const { data: event } = trpc.viewer.public.event.useQuery(
{ username, eventSlug, isTeamEvent, org: entity.orgSlug ?? null },
{
username,
eventSlug,
isTeamEvent,
org: entity.orgSlug ?? null,
fromRedirectOfNonOrgLink: entity.fromRedirectOfNonOrgLink,
},
{ refetchOnWindowFocus: false }
);
@@ -189,6 +189,7 @@ export const getPublicEvent = async (
},
entity: {
considerUnpublished: !fromRedirectOfNonOrgLink && unPublishedOrgUser !== undefined,
fromRedirectOfNonOrgLink,
orgSlug: org,
name: unPublishedOrgUser?.profile?.organization?.name ?? null,
},
@@ -291,6 +292,7 @@ export const getPublicEvent = async (
profile: getProfileFromEvent(eventWithUserProfiles),
users,
entity: {
fromRedirectOfNonOrgLink,
considerUnpublished:
!fromRedirectOfNonOrgLink &&
(eventWithUserProfiles.team?.slug === null ||
@@ -1,3 +1,5 @@
import type { Prisma } from "@prisma/client";
import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
@@ -172,10 +174,10 @@ async function moveTeam({
org: {
id: number;
slug: string | null;
metadata: Prisma.JsonValue;
};
ctx: CreateTeamsOptions["ctx"];
}) {
log.debug("Moving team", safeStringify({ teamId, newSlug, org }));
const team = await prisma.team.findUnique({
where: {
id: teamId,
@@ -203,7 +205,10 @@ async function moveTeam({
});
}
log.debug("Moving team", safeStringify({ teamId, newSlug, org, oldSlug: team.slug }));
newSlug = newSlug ?? team.slug;
const orgMetadata = teamMetadataSchema.parse(org.metadata);
await prisma.team.update({
where: {
id: teamId,
@@ -234,7 +239,7 @@ async function moveTeam({
await addTeamRedirect({
oldTeamSlug: team.slug,
teamSlug: newSlug,
orgSlug: org.slug,
orgSlug: org.slug || (orgMetadata?.requestedSlug ?? null),
});
}