Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: timezone display on booking page to reflect event availability timezone #14127

Merged
merged 8 commits into from Mar 19, 2024
8 changes: 8 additions & 0 deletions packages/features/bookings/Booker/components/EventMeta.tsx
@@ -1,5 +1,6 @@
import { m } from "framer-motion";
import dynamic from "next/dynamic";
import { useEffect } from "react";
import { shallow } from "zustand/shallow";

import { useEmbedUiConfig, useIsEmbed } from "@calcom/embed-core/embed-iframe";
Expand Down Expand Up @@ -44,6 +45,13 @@ export const EventMeta = ({
const isEmbed = useIsEmbed();
const hideEventTypeDetails = isEmbed ? embedUiConfig.hideEventTypeDetails : false;

useEffect(() => {
//In case the event has lockTimeZone enabled ,set the timezone to event's attached availability timezone
if (event && event?.lockTimeZoneToggleOnBookingPage && event?.schedule?.timeZone) {
setTimezone(event.schedule?.timeZone);
}
}, [event, setTimezone]);

if (hideEventTypeDetails) {
return null;
}
Expand Down
21 changes: 20 additions & 1 deletion packages/features/eventtypes/lib/getPublicEvent.ts
Expand Up @@ -44,6 +44,7 @@ const userSelect = Prisma.validator<Prisma.UserSelect>()({
bannerUrl: true,
},
},
defaultScheduleId: true,
});

const publicEventSelect = Prisma.validator<Prisma.EventTypeSelect>()({
Expand Down Expand Up @@ -107,6 +108,12 @@ const publicEventSelect = Prisma.validator<Prisma.EventTypeSelect>()({
owner: {
select: userSelect,
},
schedule: {
select: {
id: true,
timeZone: true,
},
},
hidden: true,
assignAllTeamMembers: true,
});
Expand Down Expand Up @@ -253,7 +260,19 @@ export const getPublicEvent = async (
if (users === null) {
throw new Error("Event has no owner");
}

//In case the event schedule is not defined ,use the event owner's default schedule
if (!eventWithUserProfiles.schedule && eventWithUserProfiles.owner?.defaultScheduleId) {
const eventOwnerDefaultSchedule = await prisma.schedule.findUnique({
where: {
id: eventWithUserProfiles.owner?.defaultScheduleId,
},
select: {
id: true,
timeZone: true,
},
});
eventWithUserProfiles.schedule = eventOwnerDefaultSchedule;
}
return {
...eventWithUserProfiles,
bookerLayouts: bookerLayoutsSchema.parse(eventMetaData?.bookerLayouts || null),
Expand Down