From 9e3e1418c264b53a24835ffc46e66ec97570ecbb Mon Sep 17 00:00:00 2001 From: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Date: Mon, 17 Oct 2022 15:47:11 +0200 Subject: [PATCH] Fix disabled locations when rescheduling (#5046) * fix phone number input when attendee phone number is default checked * add selected location for rescheduling and remove default checked * don't show locations when rescheduling on availability page * fix type error Co-authored-by: CarinaWolli Co-authored-by: Hariom Balhara --- .../components/booking/BookingDescription.tsx | 3 +- .../booking/pages/AvailabilityPage.tsx | 2 +- .../components/booking/pages/BookingPage.tsx | 70 +++++++++++-------- apps/web/lib/getBooking.tsx | 1 + 4 files changed, 44 insertions(+), 32 deletions(-) diff --git a/apps/web/components/booking/BookingDescription.tsx b/apps/web/components/booking/BookingDescription.tsx index 50f875ac8c..c8e429c519 100644 --- a/apps/web/components/booking/BookingDescription.tsx +++ b/apps/web/components/booking/BookingDescription.tsx @@ -34,6 +34,7 @@ interface Props { isBookingPage?: boolean; children: ReactNode; isMobile?: boolean; + rescheduleUid?: string; } const BookingDescription: FC = (props) => { @@ -84,7 +85,7 @@ const BookingDescription: FC = (props) => { {t("requires_confirmation")} )} - {!isBookingPage ? ( + {!isBookingPage && !props.rescheduleUid ? ( diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsx index 9b6247b0a6..592df1c0ee 100644 --- a/apps/web/components/booking/pages/AvailabilityPage.tsx +++ b/apps/web/components/booking/pages/AvailabilityPage.tsx @@ -419,7 +419,7 @@ const AvailabilityPage = ({ profile, eventType }: Props) => { "min-w-full md:w-[280px] md:min-w-[280px]", recurringEventCount && "xl:w-[380px] xl:min-w-[380px]" )}> - + {!rescheduleUid && eventType.recurringEvent && (
diff --git a/apps/web/components/booking/pages/BookingPage.tsx b/apps/web/components/booking/pages/BookingPage.tsx index f44bc7e3f2..1e24c77e6c 100644 --- a/apps/web/components/booking/pages/BookingPage.tsx +++ b/apps/web/components/booking/pages/BookingPage.tsx @@ -19,6 +19,7 @@ import { getEventLocationValue, getEventLocationType, EventLocationType, + getHumanReadableLocationValue, } from "@calcom/app-store/locations"; import { createPaymentLink } from "@calcom/app-store/stripepayment/lib/client"; import { getEventTypeAppData } from "@calcom/app-store/utils"; @@ -53,8 +54,6 @@ import slugify from "@lib/slugify"; import Gates, { Gate, GateState } from "@components/Gates"; import BookingDescription from "@components/booking/BookingDescription"; -import { UserAvatars } from "@components/booking/UserAvatars"; -import EventTypeDescriptionSafeHTML from "@components/eventtype/EventTypeDescriptionSafeHTML"; import { BookPageProps } from "../../../pages/[user]/book"; import { HashLinkPageProps } from "../../../pages/d/[link]/book"; @@ -578,37 +577,48 @@ const BookingPage = ({ )}
- {locations.length > 1 && ( -
+
+ <> {t("location")} - {locations.map((location, i) => { - const locationString = locationKeyToString(location); - // TODO: Right now selectedLocationType isn't send by getSSP. Once that's available defaultChecked should work and show the location in the original booking - const defaultChecked = rescheduleUid ? selectedLocationType === location.type : i === 0; - if (typeof locationString !== "string") { - // It's possible that location app got uninstalled - return null; - } - return ( - - ); - })} -
- )} + {rescheduleUid ? ( +

+ {getHumanReadableLocationValue(booking?.location, t)} +

+ ) : ( + locations.length > 1 && ( + <> + {locations.map((location, i) => { + const locationString = locationKeyToString(location); + if (!selectedLocationType) { + bookingForm.setValue("locationType", locations[0].type); + } + if (typeof locationString !== "string") { + // It's possible that location app got uninstalled + return null; + } + return ( + + ); + })} + + ) + )} + +
{/* TODO: Change name and id ="phone" to something generic */} {AttendeeInput && (
diff --git a/apps/web/lib/getBooking.tsx b/apps/web/lib/getBooking.tsx index 406354ce70..4d76da72ed 100644 --- a/apps/web/lib/getBooking.tsx +++ b/apps/web/lib/getBooking.tsx @@ -10,6 +10,7 @@ async function getBooking(prisma: PrismaClient, uid: string) { description: true, customInputs: true, smsReminderNumber: true, + location: true, attendees: { select: { email: true,