From a716eda14c3a4b5ab588086f2a3e473240be6d4a Mon Sep 17 00:00:00 2001 From: Nafees Nazik <84864519+G3root@users.noreply.github.com> Date: Tue, 18 Apr 2023 17:59:26 +0530 Subject: [PATCH] fix: use the correct timezone of the user in booking detail page (#7915) * fix: send timezone in query * fiz: timezone * fix: remove tz from createPayment * fix: send timezone in query * fiz: timezone * fix: remove tz * fix: remove tz * fix: remove timezone query * fix: timezone --- apps/web/pages/booking/[uid].tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/web/pages/booking/[uid].tsx b/apps/web/pages/booking/[uid].tsx index 7dcfba24a7..b4f9ebba4f 100644 --- a/apps/web/pages/booking/[uid].tsx +++ b/apps/web/pages/booking/[uid].tsx @@ -23,6 +23,7 @@ import { useIsBackgroundTransparent, useIsEmbed, } from "@calcom/embed-core/embed-iframe"; +import { getServerSession } from "@calcom/features/auth/lib/getServerSession"; import { SystemField, getBookingFieldsWithSystemFields, @@ -105,10 +106,10 @@ export default function Success(props: SuccessProps) { seatReferenceUid, } = querySchema.parse(router.query); - const tz = - (isSuccessBookingPage - ? props.bookingInfo.attendees.find((attendee) => attendee.email === email)?.timeZone - : props.bookingInfo.eventType?.timeZone || props.bookingInfo.user?.timeZone) || timeZone(); + const attendeeTimeZone = props?.bookingInfo?.attendees.find( + (attendee) => attendee.email === email + )?.timeZone; + const tz = isSuccessBookingPage && attendeeTimeZone ? attendeeTimeZone : props.tz ? props.tz : timeZone(); const location = props.bookingInfo.location as ReturnType; @@ -917,7 +918,16 @@ const handleSeatsEventTypeOnBooking = ( export async function getServerSideProps(context: GetServerSidePropsContext) { const ssr = await ssrInit(context); + const session = await getServerSession(context); + let tz: string | null = null; + + if (session) { + const user = await ssr.viewer.me.fetch(); + tz = user.timeZone; + } + const parsedQuery = querySchema.safeParse(context.query); + if (!parsedQuery.success) return { notFound: true }; const { uid, email, eventTypeSlug, cancel, isSuccessBookingPage } = parsedQuery.data; @@ -1049,6 +1059,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { dynamicEventName: bookingInfo?.eventType?.eventName || "", bookingInfo, paymentStatus: payment, + ...(tz && { tz }), }, }; }