From 0df3e77ef1aa7f8dfcb660666be84d95c9916d3d Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Wed, 15 Feb 2023 12:28:07 +0530 Subject: [PATCH] Fix cancellation reason --- apps/web/pages/booking/[uid].tsx | 2 + .../features/bookings/lib/handleNewBooking.ts | 8 ++- packages/features/form-builder/Components.tsx | 56 ++++++++++--------- packages/prisma/zod-utils.ts | 3 +- packages/ui/form/PhoneInput.tsx | 2 +- 5 files changed, 41 insertions(+), 30 deletions(-) diff --git a/apps/web/pages/booking/[uid].tsx b/apps/web/pages/booking/[uid].tsx index 425f10f7a4..651c68a77f 100644 --- a/apps/web/pages/booking/[uid].tsx +++ b/apps/web/pages/booking/[uid].tsx @@ -539,6 +539,7 @@ export default function Success(props: SuccessProps) { // We show location in the "where" section // We show Booker Name, Emails and guests in Who section // We show notes in additional notes section + // We show rescheduleReason at the top if ( !field || ( @@ -548,6 +549,7 @@ export default function Success(props: SuccessProps) { SystemField.Enum.email, SystemField.Enum.guests, SystemField.Enum.notes, + SystemField.Enum.rescheduleReason, ] as string[] ).includes(field.name) ) { diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index eb7d20d157..c531961eb5 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -349,6 +349,7 @@ function getBookingData({ smsReminderNumber: responses.smsReminderNumber, notes: responses.notes || "", userFieldsResponses, + rescheduleReason: responses.rescheduleReason, }; } else { // Check if required custom inputs exist @@ -362,6 +363,7 @@ function getBookingData({ location: reqBody.location || "", smsReminderNumber: reqBody.smsReminderNumber, notes: reqBody.notes, + rescheduleReason: reqBody.rescheduleReason, }; } } @@ -434,6 +436,7 @@ async function handler( location, notes: additionalNotes, smsReminderNumber, + rescheduleReason, ...bookingData } = getBookingData({ req, @@ -1041,14 +1044,13 @@ async function handler( } let videoCallUrl; - if (originalRescheduledBooking?.uid) { // Use EventManager to conditionally use all needed integrations. const updateManager = await eventManager.reschedule( evt, originalRescheduledBooking.uid, booking?.id, - bookingData.rescheduleReason + rescheduleReason ); // This gets overridden when updating the event - to check if notes have been hidden or not. We just reset this back // to the default description when we are sending the emails. @@ -1084,7 +1086,7 @@ async function handler( ...evt, additionalInformation: metadata, additionalNotes, // Resets back to the additionalNote input and not the override value - cancellationReason: "$RCH$" + bookingData.rescheduleReason, // Removable code prefix to differentiate cancellation from rescheduling for email + cancellationReason: "$RCH$" + rescheduleReason, // Removable code prefix to differentiate cancellation from rescheduling for email }); } } diff --git a/packages/features/form-builder/Components.tsx b/packages/features/form-builder/Components.tsx index b8a406df83..e85f25c7ae 100644 --- a/packages/features/form-builder/Components.tsx +++ b/packages/features/form-builder/Components.tsx @@ -77,13 +77,14 @@ export const Components: Record = { }, phone: { propsType: "text", - factory: ({ setValue, ...props }) => { + factory: ({ setValue, readOnly, ...props }) => { if (!props) { return
; } return ( { setValue(val); }} @@ -117,7 +118,7 @@ export const Components: Record = { multiemail: { propsType: "textList", //TODO: Make it a ui component - factory: function MultiEmail({ value, label, setValue, ...props }) { + factory: function MultiEmail({ value, readOnly, label, setValue, ...props }) { const placeholder = props.placeholder; const { t } = useLocale(); value = value || []; @@ -136,6 +137,7 @@ export const Components: Record = { {value.map((field, index) => (
  • { value[index] = e.target.value; @@ -149,39 +151,43 @@ export const Components: Record = { label={<>} required addOnSuffix={ - - - + !readOnly ? ( + + + + ) : null } />
  • ))} - + {!readOnly && ( + + )}
    ) : ( <> )} - {!value.length && ( + {!value.length && !readOnly && (