perf: duplicate getSchedule request (#17191)

* fix: duplicate getSchedule request

* fix: add event type id
This commit is contained in:
Udit Takkar authored and GitHub committed 2024-10-20 08:56:37 +00:00
1 parent f70e8c5189
commit c7f4f52efa
9 files changed
+15 -11

No files matched your search

@@ -32,6 +32,7 @@ export interface BookerProps {
teamSlug?: string | null;
name?: string | null;
logoUrl?: string | null;
eventTypeId?: number | null;
};
/**
@@ -72,6 +72,7 @@ export const useScheduleForEvent = ({
orgSlug,
teamMemberEmail,
fromRedirectOfNonOrgLink,
isTeamEvent,
}: {
prefetchNextMonth?: boolean;
username?: string | null;
@@ -85,9 +86,9 @@ export const useScheduleForEvent = ({
orgSlug?: string;
teamMemberEmail?: string | null;
fromRedirectOfNonOrgLink?: boolean;
isTeamEvent?: boolean;
} = {}) => {
const { timezone } = useTimePreferences();
const event = useEvent({ fromRedirectOfNonOrgLink });
const [usernameFromStore, eventSlugFromStore, monthFromStore, durationFromStore] = useBookerStore(
(state) => [state.username, state.eventSlug, state.month, state.selectedDuration],
shallow
@@ -98,12 +99,10 @@ export const useScheduleForEvent = ({
const pathname = usePathname();
const isTeam = !!event.data?.team?.parentId;
const schedule = useSchedule({
username: usernameFromStore ?? username,
eventSlug: eventSlugFromStore ?? eventSlug,
eventId: event.data?.id ?? eventId,
eventId,
timezone,
selectedDate,
prefetchNextMonth,
@@ -112,7 +111,7 @@ export const useScheduleForEvent = ({
rescheduleUid,
month: monthFromStore ?? month,
duration: durationFromStore ?? duration,
isTeamEvent: pathname?.indexOf("/team/") !== -1 || isTeam,
isTeamEvent,
orgSlug,
teamMemberEmail,
});
+1 -1
View File
@@ -172,7 +172,7 @@ const EmailEmbed = ({
shallow
);
const event = useEvent();
const schedule = useScheduleForEvent({ orgSlug });
const schedule = useScheduleForEvent({ orgSlug, eventId: eventType?.id, isTeamEvent });
const nonEmptyScheduleDays = useNonEmptyScheduleDays(schedule?.data?.slots);
const onTimeSelect = (time: string) => {
@@ -51,7 +51,7 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {
useInitializeBookerStore({
...props,
eventId: event?.data?.id,
eventId: props.entity.eventTypeId ?? event?.data?.id,
rescheduleUid,
rescheduledBy,
bookingUid: bookingUid,
@@ -123,6 +123,7 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {
* */
const schedule = useScheduleForEvent({
prefetchNextMonth,
eventId: props.entity.eventTypeId ?? event.data?.id,
username: props.username,
monthCount,
dayCount,
@@ -132,6 +133,7 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {
selectedDate,
teamMemberEmail: props.teamMemberEmail,
fromRedirectOfNonOrgLink: props.entity.fromRedirectOfNonOrgLink,
isTeamEvent: props.isTeamEvent ?? !!event.data?.team,
});
const bookings = useBookings({
event,