+
{
+ setValue={(val: unknown) => {
onChange(val);
}}
/>
@@ -620,7 +666,6 @@ export const FormBuilderField = ({
if (name !== field.name) {
return null;
}
- // console.error(name, field.name, message, "ErrorMesg");
message = message.replace(/\{[^}]+\}(.*)/, "$1");
return (
diff --git a/packages/lib/defaultEvents.ts b/packages/lib/defaultEvents.ts
index e60c7fca8f..7534ae7c71 100644
--- a/packages/lib/defaultEvents.ts
+++ b/packages/lib/defaultEvents.ts
@@ -2,7 +2,14 @@ import { PeriodType, Prisma, SchedulingType } from "@prisma/client";
import { DailyLocationType } from "@calcom/app-store/locations";
import { userSelect } from "@calcom/prisma/selects";
-import { CustomInputSchema, EventTypeMetaDataSchema, eventTypeBookingFields } from "@calcom/prisma/zod-utils";
+import {
+ CustomInputSchema,
+ EventTypeMetaDataSchema,
+ customInputSchema,
+ eventTypeBookingFields,
+} from "@calcom/prisma/zod-utils";
+
+import { ensureBookingInputsHaveSystemFields } from "./getEventTypeById";
type User = Prisma.UserGetPayload;
@@ -87,7 +94,12 @@ const commons = {
users: [user],
hosts: [],
metadata: EventTypeMetaDataSchema.parse({}),
- bookingFields: eventTypeBookingFields.parse([]),
+ bookingFields: ensureBookingInputsHaveSystemFields({
+ bookingFields: eventTypeBookingFields.parse([]),
+ disableGuests: true,
+ additionalNotesRequired: false,
+ customInputs: customInputSchema.array().parse([]),
+ }),
};
const min15Event = {
diff --git a/packages/lib/getEventTypeById.ts b/packages/lib/getEventTypeById.ts
index 2d88475c73..fd0db78df7 100644
--- a/packages/lib/getEventTypeById.ts
+++ b/packages/lib/getEventTypeById.ts
@@ -49,9 +49,10 @@ export const ensureBookingInputsHaveSystemFields = ({
[EventTypeCustomInputType.PHONE]: BookingFieldType.phone,
};
- const systemFields: typeof bookingFields = [
+ // These fields should be added before other user fields
+ const systemBeforeFields: typeof bookingFields = [
{
- label: "Your name",
+ label: "your_name",
type: "name",
name: "name",
required: true,
@@ -65,7 +66,7 @@ export const ensureBookingInputsHaveSystemFields = ({
],
},
{
- label: "Your email",
+ label: "email_address",
type: "email",
name: "email",
required: true,
@@ -79,7 +80,7 @@ export const ensureBookingInputsHaveSystemFields = ({
],
},
{
- label: "Location",
+ label: "location",
type: "radioInput",
name: "location",
editable: "system",
@@ -106,8 +107,12 @@ export const ensureBookingInputsHaveSystemFields = ({
},
],
},
+ ];
+
+ // These fields should be added after other user fields
+ const systemAfterFields: typeof bookingFields = [
{
- label: "Additional Notes",
+ label: "additional_notes",
type: "textarea",
name: "notes",
editable: "system-but-optional",
@@ -121,7 +126,7 @@ export const ensureBookingInputsHaveSystemFields = ({
],
},
{
- label: "Add guests",
+ label: "additional_guests",
type: "multiemail",
name: "guests",
editable: "system-but-optional",
@@ -137,7 +142,7 @@ export const ensureBookingInputsHaveSystemFields = ({
},
{
//TODO: How to translate in user language?
- label: "Reschedule Reason",
+ label: "reschedule_reason",
type: "textarea",
name: "rescheduleReason",
editable: "system",
@@ -154,16 +159,16 @@ export const ensureBookingInputsHaveSystemFields = ({
},
];
- const missingSystemFields = [];
- // Push system fields first if any of them don't exist. We can't simply live without system fields
- for (const field of systemFields) {
+ const missingSystemBeforeFields = [];
+ for (const field of systemBeforeFields) {
// Only do a push, we must not update existing system fields as user could have modified any property in it,
if (!bookingFields.find((f) => f.name === field.name)) {
- missingSystemFields.push(field);
+ missingSystemBeforeFields.push(field);
}
}
- bookingFields = missingSystemFields.concat(bookingFields);
+ bookingFields = missingSystemBeforeFields.concat(bookingFields);
+
// If we are migrating from old system, we need to add custom inputs to the end of the list
if (handleMigration) {
customInputs.forEach((input) => {
@@ -188,6 +193,16 @@ export const ensureBookingInputsHaveSystemFields = ({
});
}
+ const missingSystemAfterFields = [];
+ for (const field of systemAfterFields) {
+ // Only do a push, we must not update existing system fields as user could have modified any property in it,
+ if (!bookingFields.find((f) => f.name === field.name)) {
+ missingSystemAfterFields.push(field);
+ }
+ }
+
+ bookingFields = bookingFields.concat(missingSystemAfterFields);
+
return eventTypeBookingFields.brand<"HAS_SYSTEM_FIELDS">().parse(bookingFields);
};
diff --git a/packages/prisma/zod-utils.ts b/packages/prisma/zod-utils.ts
index dfc8f43521..6263ca709f 100644
--- a/packages/prisma/zod-utils.ts
+++ b/packages/prisma/zod-utils.ts
@@ -55,11 +55,11 @@ export const EventTypeMetaDataSchema = z
export const eventTypeBookingFields = formBuilderFieldsSchema;
-// Real validation happens using getBookingResponsesSchema which requires eventType. Is there a better way to do it?
+// Validation of user added bookingFields's responses happen using getBookingResponsesSchema which requires eventType.
export const bookingResponses = z.object({
email: z.string(),
name: z.string(),
- guests: z.string().optional(),
+ guests: z.array(z.string()).optional(),
notes: z.string().optional(),
location: z
.object({