From 389633394ba18e15cacb6d7817eaaeb8ad0c723a Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Tue, 21 Mar 2023 16:17:17 +0530 Subject: [PATCH] Fix/conflicts of custom input Name, with system field (#7856) * Dont conflict with system fields * Allow considering a field that has system fields name to be fully editable --- .../features/bookings/lib/getBookingFields.ts | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/packages/features/bookings/lib/getBookingFields.ts b/packages/features/bookings/lib/getBookingFields.ts index 3667fa64fa..42304c9ad7 100644 --- a/packages/features/bookings/lib/getBookingFields.ts +++ b/packages/features/bookings/lib/getBookingFields.ts @@ -55,16 +55,6 @@ export const SystemField = z.enum([ "smsReminderNumber", ]); -export const SystemFieldsEditability: Record, Fields[number]["editable"]> = { - name: "system", - email: "system", - location: "system", - notes: "system-but-optional", - guests: "system-but-optional", - rescheduleReason: "system-but-optional", - smsReminderNumber: "system", -}; - /** * This fn is the key to ensure on the fly mapping of customInputs to bookingFields and ensuring that all the systems fields are present and correctly ordered in bookingFields */ @@ -165,6 +155,7 @@ export const ensureBookingInputsHaveSystemFields = ({ defaultLabel: "your_name", type: "name", name: "name", + editable: "system", required: true, sources: [ { @@ -179,6 +170,7 @@ export const ensureBookingInputsHaveSystemFields = ({ type: "email", name: "email", required: true, + editable: "system", sources: [ { label: "Default", @@ -191,6 +183,7 @@ export const ensureBookingInputsHaveSystemFields = ({ defaultLabel: "location", type: "radioInput", name: "location", + editable: "system", required: false, // Populated on the fly from locations. I don't want to duplicate storing locations and instead would like to be able to refer to locations in eventType. // options: `eventType.locations` @@ -222,6 +215,7 @@ export const ensureBookingInputsHaveSystemFields = ({ defaultLabel: "additional_notes", type: "textarea", name: "notes", + editable: "system-but-optional", required: additionalNotesRequired, defaultPlaceholder: "share_additional_notes", sources: [ @@ -235,6 +229,7 @@ export const ensureBookingInputsHaveSystemFields = ({ { defaultLabel: "additional_guests", type: "multiemail", + editable: "system-but-optional", name: "guests", required: false, hidden: disableGuests, @@ -249,6 +244,7 @@ export const ensureBookingInputsHaveSystemFields = ({ { defaultLabel: "reschedule_reason", type: "textarea", + editable: "system-but-optional", name: "rescheduleReason", defaultPlaceholder: "reschedule_placeholder", required: false, @@ -338,17 +334,5 @@ export const ensureBookingInputsHaveSystemFields = ({ bookingFields = bookingFields.concat(missingSystemAfterFields); - bookingFields = bookingFields.map((field) => { - const foundEditableMap = SystemFieldsEditability[field.name as keyof typeof SystemFieldsEditability]; - if (!foundEditableMap) { - return field; - } - // Ensure that system fields editability, even if modified to something else in DB(accidentally), get's reset to what's in the code. - return { - ...field, - editable: foundEditableMap, - }; - }); - return eventTypeBookingFields.brand<"HAS_SYSTEM_FIELDS">().parse(bookingFields); };