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
This commit is contained in:
1 parent
64b321ac9c
commit
e949a4c529
3 files changed
+16
-7
No files matched your search
@@ -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;
|
||||
|
||||
@@ -19,10 +19,11 @@ export type useScheduleForEventReturnType = ReturnType<typeof useScheduleForEven
|
||||
* Using this hook means you only need to use one hook, instead
|
||||
* of combining multiple conditional hooks.
|
||||
*/
|
||||
export const useEvent = () => {
|
||||
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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user