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
pull/8296/head^2
Nafees Nazik 2023-04-18 17:59:26 +05:30 committed by GitHub
parent 99f1524183
commit a716eda14c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import {
useIsBackgroundTransparent, useIsBackgroundTransparent,
useIsEmbed, useIsEmbed,
} from "@calcom/embed-core/embed-iframe"; } from "@calcom/embed-core/embed-iframe";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { import {
SystemField, SystemField,
getBookingFieldsWithSystemFields, getBookingFieldsWithSystemFields,
@ -105,10 +106,10 @@ export default function Success(props: SuccessProps) {
seatReferenceUid, seatReferenceUid,
} = querySchema.parse(router.query); } = querySchema.parse(router.query);
const tz = const attendeeTimeZone = props?.bookingInfo?.attendees.find(
(isSuccessBookingPage (attendee) => attendee.email === email
? props.bookingInfo.attendees.find((attendee) => attendee.email === email)?.timeZone )?.timeZone;
: props.bookingInfo.eventType?.timeZone || props.bookingInfo.user?.timeZone) || timeZone(); const tz = isSuccessBookingPage && attendeeTimeZone ? attendeeTimeZone : props.tz ? props.tz : timeZone();
const location = props.bookingInfo.location as ReturnType<typeof getEventLocationValue>; const location = props.bookingInfo.location as ReturnType<typeof getEventLocationValue>;
@ -917,7 +918,16 @@ const handleSeatsEventTypeOnBooking = (
export async function getServerSideProps(context: GetServerSidePropsContext) { export async function getServerSideProps(context: GetServerSidePropsContext) {
const ssr = await ssrInit(context); 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); const parsedQuery = querySchema.safeParse(context.query);
if (!parsedQuery.success) return { notFound: true }; if (!parsedQuery.success) return { notFound: true };
const { uid, email, eventTypeSlug, cancel, isSuccessBookingPage } = parsedQuery.data; const { uid, email, eventTypeSlug, cancel, isSuccessBookingPage } = parsedQuery.data;
@ -1049,6 +1059,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
dynamicEventName: bookingInfo?.eventType?.eventName || "", dynamicEventName: bookingInfo?.eventType?.eventName || "",
bookingInfo, bookingInfo,
paymentStatus: payment, paymentStatus: payment,
...(tz && { tz }),
}, },
}; };
} }