From e949a4c529dc651f3bea4575511d4c5a09a21ef0 Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:57:39 +0100 Subject: [PATCH] fix: pass from org link to all instances of event.public (#17136) * pass from org link to all instances of event.public * fix type error * fix type error --- packages/features/bookings/Booker/types.ts | 1 + .../features/bookings/Booker/utils/event.ts | 19 +++++++++++++------ .../atoms/booker/BookerWebWrapper.tsx | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/features/bookings/Booker/types.ts b/packages/features/bookings/Booker/types.ts index e34f7da558..c10dd25c72 100644 --- a/packages/features/bookings/Booker/types.ts +++ b/packages/features/bookings/Booker/types.ts @@ -25,6 +25,7 @@ export interface BookerProps { * Whether is a team or org, we gather basic info from both */ entity: { + fromRedirectOfNonOrgLink?: boolean; considerUnpublished: boolean; isUnpublished?: boolean; orgSlug?: string | null; diff --git a/packages/features/bookings/Booker/utils/event.ts b/packages/features/bookings/Booker/utils/event.ts index 16b483e157..91fd8c1f21 100644 --- a/packages/features/bookings/Booker/utils/event.ts +++ b/packages/features/bookings/Booker/utils/event.ts @@ -19,10 +19,11 @@ export type useScheduleForEventReturnType = ReturnType { - const [username, eventSlug] = useBookerStore((state) => [state.username, state.eventSlug], shallow); - const isTeamEvent = useBookerStore((state) => state.isTeamEvent); - const org = useBookerStore((state) => state.org); +export const useEvent = (props?: { fromRedirectOfNonOrgLink?: boolean }) => { + const [username, eventSlug, isTeamEvent, org] = useBookerStore( + (state) => [state.username, state.eventSlug, state.isTeamEvent, state.org], + shallow + ); const event = trpc.viewer.public.event.useQuery( { @@ -30,8 +31,12 @@ export const useEvent = () => { eventSlug: eventSlug ?? "", isTeamEvent, org: org ?? null, + fromRedirectOfNonOrgLink: props?.fromRedirectOfNonOrgLink, }, - { refetchOnWindowFocus: false, enabled: Boolean(username) && Boolean(eventSlug) } + { + refetchOnWindowFocus: false, + enabled: Boolean(username) && Boolean(eventSlug), + } ); return { @@ -66,6 +71,7 @@ export const useScheduleForEvent = ({ selectedDate, orgSlug, teamMemberEmail, + fromRedirectOfNonOrgLink, }: { prefetchNextMonth?: boolean; username?: string | null; @@ -78,9 +84,10 @@ export const useScheduleForEvent = ({ selectedDate?: string | null; orgSlug?: string; teamMemberEmail?: string | null; + fromRedirectOfNonOrgLink?: boolean; } = {}) => { const { timezone } = useTimePreferences(); - const event = useEvent(); + const event = useEvent({ fromRedirectOfNonOrgLink }); const [usernameFromStore, eventSlugFromStore, monthFromStore, durationFromStore] = useBookerStore( (state) => [state.username, state.eventSlug, state.month, state.selectedDuration], shallow diff --git a/packages/platform/atoms/booker/BookerWebWrapper.tsx b/packages/platform/atoms/booker/BookerWebWrapper.tsx index e5948c2ff9..784e42dbb8 100644 --- a/packages/platform/atoms/booker/BookerWebWrapper.tsx +++ b/packages/platform/atoms/booker/BookerWebWrapper.tsx @@ -30,7 +30,7 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => { const router = useRouter(); const pathname = usePathname(); const searchParams = useSearchParams(); - const event = useEvent(); + const event = useEvent({ fromRedirectOfNonOrgLink: props.entity.fromRedirectOfNonOrgLink }); const bookerLayout = useBookerLayout(event.data); const selectedDate = searchParams?.get("date"); @@ -131,6 +131,7 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => { duration: props.duration, selectedDate, teamMemberEmail: props.teamMemberEmail, + fromRedirectOfNonOrgLink: props.entity.fromRedirectOfNonOrgLink, }); const bookings = useBookings({ event,