fix: Unable to modify the location of a booking when rescheduling (#11651)

This commit is contained in:
kremedev 2023-10-20 10:00:00 +03:00 committed by GitHub
parent e2414b174a
commit 19eced00f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 11 deletions

View File

@ -115,6 +115,13 @@ export default function Success(props: SuccessProps) {
const tz = props.tz ? props.tz : isSuccessBookingPage && attendeeTimeZone ? attendeeTimeZone : timeZone(); const tz = props.tz ? props.tz : isSuccessBookingPage && attendeeTimeZone ? attendeeTimeZone : timeZone();
const location = props.bookingInfo.location as ReturnType<typeof getEventLocationValue>; const location = props.bookingInfo.location as ReturnType<typeof getEventLocationValue>;
let rescheduleLocation: string | undefined;
if (
typeof props.bookingInfo.responses.location === "object" &&
"optionValue" in props.bookingInfo.responses.location
) {
rescheduleLocation = props.bookingInfo.responses.location.optionValue;
}
const locationVideoCallUrl: string | undefined = bookingMetadataSchema.parse( const locationVideoCallUrl: string | undefined = bookingMetadataSchema.parse(
props?.bookingInfo?.metadata || {} props?.bookingInfo?.metadata || {}
@ -295,7 +302,14 @@ export default function Success(props: SuccessProps) {
bookingInfo.status bookingInfo.status
); );
const rescheduleLocationToDisplay = getSuccessPageLocationMessage(
rescheduleLocation ?? "",
t,
bookingInfo.status
);
const providerName = guessEventLocationType(location)?.label; const providerName = guessEventLocationType(location)?.label;
const rescheduleProviderName = guessEventLocationType(rescheduleLocation)?.label;
return ( return (
<div className={isEmbed ? "" : "h-screen"} data-testid="success-page"> <div className={isEmbed ? "" : "h-screen"} data-testid="success-page">
@ -467,18 +481,50 @@ export default function Success(props: SuccessProps) {
<> <>
<div className="mt-3 font-medium">{t("where")}</div> <div className="mt-3 font-medium">{t("where")}</div>
<div className="col-span-2 mt-3" data-testid="where"> <div className="col-span-2 mt-3" data-testid="where">
{locationToDisplay.startsWith("http") ? ( {!rescheduleLocation || locationToDisplay === rescheduleLocationToDisplay ? (
<a locationToDisplay.startsWith("http") ? (
href={locationToDisplay} <a
target="_blank" href={locationToDisplay}
title={locationToDisplay} target="_blank"
className="text-default flex items-center gap-2 underline" title={locationToDisplay}
rel="noreferrer"> className="text-default flex items-center gap-2"
{providerName || "Link"} rel="noreferrer">
<ExternalLink className="text-default inline h-4 w-4" /> {providerName || "Link"}
</a> <ExternalLink className="text-default inline h-4 w-4" />
</a>
) : (
locationToDisplay
)
) : ( ) : (
locationToDisplay <>
{!!formerTime &&
(locationToDisplay.startsWith("http") ? (
<a
href={locationToDisplay}
target="_blank"
title={locationToDisplay}
className="text-default flex items-center gap-2 line-through"
rel="noreferrer">
{providerName || "Link"}
<ExternalLink className="text-default inline h-4 w-4" />
</a>
) : (
<p className="line-through">{locationToDisplay}</p>
))}
{rescheduleLocationToDisplay.startsWith("http") ? (
<a
href={rescheduleLocationToDisplay}
target="_blank"
title={rescheduleLocationToDisplay}
className="text-default flex items-center gap-2"
rel="noreferrer">
{rescheduleProviderName || "Link"}
<ExternalLink className="text-default inline h-4 w-4" />
</a>
) : (
rescheduleLocationToDisplay
)}
</>
)} )}
</div> </div>
</> </>

View File

@ -77,6 +77,13 @@ export const BookingFields = ({
return null; return null;
} }
// Attendee location field can be edited during reschedule
if (field.name === SystemField.Enum.location) {
if (locationResponse?.value === "attendeeInPerson" || "phone") {
readOnly = false;
}
}
// Dynamically populate location field options // Dynamically populate location field options
if (field.name === SystemField.Enum.location && field.type === "radioInput") { if (field.name === SystemField.Enum.location && field.type === "radioInput") {
if (!field.optionsInputs) { if (!field.optionsInputs) {