From 7fc884912e0cd746166d4e827bdca51906297cf0 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Wed, 22 Mar 2023 10:10:49 +0530 Subject: [PATCH] Make sure that label is also set (#7874) --- packages/features/bookings/lib/getBookingFields.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/features/bookings/lib/getBookingFields.ts b/packages/features/bookings/lib/getBookingFields.ts index 9bfd75e6dc..932807c9b8 100644 --- a/packages/features/bookings/lib/getBookingFields.ts +++ b/packages/features/bookings/lib/getBookingFields.ts @@ -11,6 +11,13 @@ import { export const SMS_REMINDER_NUMBER_FIELD = "smsReminderNumber"; +/** + * PHONE -> Phone + */ +function upperCaseToCamelCase(upperCaseString: string) { + return upperCaseString[0].toUpperCase() + upperCaseString.slice(1).toLowerCase(); +} + export const getSmsReminderNumberField = () => ({ name: SMS_REMINDER_NUMBER_FIELD, @@ -296,8 +303,9 @@ export const ensureBookingInputsHaveSystemFields = ({ // Backward Compatibility: If we are migrating from old system, we need to map `customInputs` to `bookingFields` if (handleMigration) { customInputs.forEach((input, index) => { + const label = input.label || `${upperCaseToCamelCase(input.type)}`; bookingFields.push({ - label: input.label, + label: label, editable: "user", // Custom Input's slugified label was being used as query param for prefilling. So, make that the name of the field // Also Custom Input's label could have been empty string as well. But it's not possible to have empty name. So generate a name automatically.