fix: timezone display on booking page to reflect event availability timezone (#14127)
* fix timezone display on booking page to reflect event availability timezone * migrate fetching event owner's schedule to server side * migrate fetching event owner's schedule to server side * fix e2e test errors --------- Co-authored-by: Shaik-Sirajuddin <sirajuddinshaik30gmail.com> Co-authored-by: Shaik-Sirajuddin <sirajudddinshaik30@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
This commit is contained in:
co-authored by
Shaik-Sirajuddin
Shaik-Sirajuddin
Joe Au-Yeung
parent
86addf3793
commit
a55ffca013
@@ -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";
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ const userSelect = Prisma.validator<Prisma.UserSelect>()({
|
||||
bannerUrl: true,
|
||||
},
|
||||
},
|
||||
defaultScheduleId: true,
|
||||
});
|
||||
|
||||
const publicEventSelect = Prisma.validator<Prisma.EventTypeSelect>()({
|
||||
@@ -107,6 +108,12 @@ const publicEventSelect = Prisma.validator<Prisma.EventTypeSelect>()({
|
||||
owner: {
|
||||
select: userSelect,
|
||||
},
|
||||
schedule: {
|
||||
select: {
|
||||
id: true,
|
||||
timeZone: true,
|
||||
},
|
||||
},
|
||||
hidden: true,
|
||||
assignAllTeamMembers: true,
|
||||
});
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user