fix: create event type with output of another create event type (#21273)
* feat: accept location booking field with label customization * feat: return location label * chore: bump libraries * test * fix: tests
This commit is contained in:
1 parent
1ccfc65766
commit
80fad2aab9
16 files changed
+3720
-157
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import type {
|
||||
InputBookingField_2024_06_14,
|
||||
LocationDefaultFieldOutput_2024_06_14,
|
||||
PhoneDefaultFieldOutput_2024_06_14,
|
||||
MultiSelectFieldInput_2024_06_14,
|
||||
CheckboxGroupFieldInput_2024_06_14,
|
||||
@@ -8,6 +7,7 @@ import type {
|
||||
NameDefaultFieldInput_2024_06_14,
|
||||
EmailDefaultFieldInput_2024_06_14,
|
||||
TitleDefaultFieldInput_2024_06_14,
|
||||
LocationDefaultFieldInput_2024_06_14,
|
||||
NotesDefaultFieldInput_2024_06_14,
|
||||
GuestsDefaultFieldInput_2024_06_14,
|
||||
RescheduleReasonDefaultFieldInput_2024_06_14,
|
||||
@@ -28,10 +28,7 @@ import {
|
||||
systemBeforeFieldNameSplit,
|
||||
} from "../internal-to-api";
|
||||
|
||||
type InputBookingField =
|
||||
| InputBookingField_2024_06_14
|
||||
| LocationDefaultFieldOutput_2024_06_14
|
||||
| PhoneDefaultFieldOutput_2024_06_14;
|
||||
type InputBookingField = InputBookingField_2024_06_14 | PhoneDefaultFieldOutput_2024_06_14;
|
||||
|
||||
export function transformBookingFieldsApiToInternal(bookingFields: InputBookingField[]) {
|
||||
const customBookingFields = bookingFields.map((field) => {
|
||||
@@ -77,8 +74,7 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
|
||||
if (fieldIsDefaultSystemLocation(field)) {
|
||||
return {
|
||||
...systemBeforeFieldLocation,
|
||||
required: field.required,
|
||||
hidden: field.hidden,
|
||||
label: field.label,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -157,7 +153,7 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
|
||||
required: !!field.required,
|
||||
hidden: !!field.hidden,
|
||||
label: field.label,
|
||||
placeholder: "placeholder" in field ? field.placeholder : "",
|
||||
placeholder: "placeholder" in field ? field.placeholder : undefined,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
}
|
||||
@@ -168,7 +164,7 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
|
||||
required: !!field.required,
|
||||
hidden: !!field.hidden,
|
||||
label: field.label,
|
||||
placeholder: "placeholder" in field ? field.placeholder : "",
|
||||
placeholder: "placeholder" in field ? field.placeholder : undefined,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
}
|
||||
@@ -179,7 +175,7 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
|
||||
required: !!field.required,
|
||||
hidden: !!field.hidden,
|
||||
label: field.label,
|
||||
placeholder: "placeholder" in field ? field.placeholder : "",
|
||||
placeholder: "placeholder" in field ? field.placeholder : undefined,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
}
|
||||
@@ -190,7 +186,7 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
|
||||
required: !!field.required,
|
||||
hidden: !!field.hidden,
|
||||
label: field.label,
|
||||
placeholder: "placeholder" in field ? field.placeholder : "",
|
||||
placeholder: "placeholder" in field ? field.placeholder : undefined,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
}
|
||||
@@ -298,7 +294,7 @@ function fieldIsDefaultAttendeePhone(field: InputBookingField): field is PhoneDe
|
||||
|
||||
function fieldIsDefaultSystemLocation(
|
||||
field: InputBookingField
|
||||
): field is LocationDefaultFieldOutput_2024_06_14 {
|
||||
): field is LocationDefaultFieldInput_2024_06_14 {
|
||||
return "slug" in field && field.slug === "location";
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ export function transformBookingFieldsInternalToApi(
|
||||
slug: "location",
|
||||
required: !!field.required,
|
||||
hidden: !!field.hidden,
|
||||
label: field.label,
|
||||
} satisfies LocationDefaultFieldOutput_2024_06_14;
|
||||
case "rescheduleReason":
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user