perf: duplicate getSchedule request (#17191)
* fix: duplicate getSchedule request * fix: add event type id
This commit is contained in:
@@ -56,6 +56,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
return {
|
||||
props: {
|
||||
entity: eventData.entity,
|
||||
eventTypeId: eventData.id,
|
||||
duration: getMultipleDurationValue(
|
||||
eventData.metadata?.multipleDuration,
|
||||
queryDuration,
|
||||
|
||||
@@ -88,6 +88,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
return {
|
||||
props: {
|
||||
eventData: {
|
||||
eventTypeId: eventData.id,
|
||||
entity: eventData.entity,
|
||||
length: eventData.length,
|
||||
metadata: eventData.metadata,
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import type { EmbedProps } from "@lib/withEmbedSsr";
|
||||
|
||||
export type PageProps = inferSSRProps<typeof getServerSideProps> & EmbedProps;
|
||||
|
||||
function Type({ slug, user, booking, isEmbed, isBrandingHidden, entity, duration }: PageProps) {
|
||||
function Type({ slug, user, booking, isEmbed, isBrandingHidden, entity, eventTypeId, duration }: PageProps) {
|
||||
return (
|
||||
<main className={getBookerWrapperClasses({ isEmbed: !!isEmbed })}>
|
||||
<BookerSeo
|
||||
@@ -29,7 +29,7 @@ function Type({ slug, user, booking, isEmbed, isBrandingHidden, entity, duration
|
||||
hideBranding={isBrandingHidden}
|
||||
isTeamEvent
|
||||
isInstantMeeting
|
||||
entity={entity}
|
||||
entity={{ ...entity, eventTypeId: eventTypeId }}
|
||||
duration={duration}
|
||||
/>
|
||||
</main>
|
||||
|
||||
@@ -53,7 +53,7 @@ function Type({
|
||||
isInstantMeeting={isInstantMeeting}
|
||||
hideBranding={isBrandingHidden}
|
||||
isTeamEvent
|
||||
entity={eventData.entity}
|
||||
entity={{ ...eventData.entity, eventTypeId: eventData?.eventTypeId }}
|
||||
durationConfig={eventData.metadata?.multipleDuration}
|
||||
/* TODO: Currently unused, evaluate it is needed-
|
||||
* Possible alternative approach is to have onDurationChange.
|
||||
|
||||
@@ -52,7 +52,7 @@ function Type({
|
||||
eventSlug={slug}
|
||||
bookingData={booking}
|
||||
hideBranding={isBrandingHidden}
|
||||
entity={eventData.entity}
|
||||
entity={{ ...eventData.entity, eventTypeId: eventData?.id }}
|
||||
durationConfig={eventData.metadata?.multipleDuration}
|
||||
orgBannerUrl={orgBannerUrl}
|
||||
/* TODO: Currently unused, evaluate it is needed-
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user