fix: Booker atom default booking fields (#18275)

* refactor: rename transformBookingFieldsApiToInternal to transformBookingFieldsApiRequestToInternal

* refactor: default booking fields can required or not required

* fix: render system fields in booker

* fix: hidden property of booking fields

* fix: default field labels and placeholders

* chore: bump platform libraries

* fix: tests

* fix: e2e tests
This commit is contained in:
Lauris Skraucis authored and GitHub committed 2024-12-19 16:30:14 +00:00
1 parent 0b2f09ab7d
commit f0d7a757d4
16 files changed
+6944 -215

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@
"@axiomhq/winston": "^1.2.0",
"@calcom/platform-constants": "*",
"@calcom/platform-enums": "*",
"@calcom/platform-libraries": "npm:@calcom/[email protected]3",
"@calcom/platform-libraries": "npm:@calcom/[email protected]7",
"@calcom/platform-libraries-0.0.2": "npm:@calcom/[email protected]",
"@calcom/platform-types": "*",
"@calcom/platform-utils": "*",
@@ -291,6 +291,7 @@ describe("Event types Endpoints", () => {
placeholder: "select language",
options: ["javascript", "python", "cobol"],
disableOnPrefill: true,
hidden: false,
},
],
scheduleId: firstSchedule.id,
@@ -381,10 +382,24 @@ describe("Event types Endpoints", () => {
const requestBookingFields = body.bookingFields || [];
const expectedBookingFields = [
{ isDefault: true, required: true, slug: "name", ...nameBookingField },
{ isDefault: true, required: true, slug: "email", type: "email" },
{ isDefault: true, required: true, slug: "email", type: "email", disableOnPrefill: false },
// note(Lauris): location booking field is added if multiple locations are passed
{ isDefault: true, required: false, slug: "location", type: "radioInput" },
{ isDefault: true, required: false, slug: "rescheduleReason", type: "textarea" },
{
isDefault: true,
required: false,
slug: "location",
type: "radioInput",
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
required: false,
slug: "rescheduleReason",
type: "textarea",
disableOnPrefill: false,
hidden: false,
},
...requestBookingFields
.filter((field) => field.type !== "name" && field.type !== "email")
.map((field) => ({ isDefault: false, ...field })),
@@ -787,6 +802,7 @@ describe("Event types Endpoints", () => {
placeholder: "select language",
options: ["javascript", "python", "cobol"],
disableOnPrefill: false,
hidden: false,
},
],
bookingLimitsCount: {
@@ -853,8 +869,15 @@ describe("Event types Endpoints", () => {
const requestBookingFields = body.bookingFields || [];
const expectedBookingFields = [
{ isDefault: true, required: true, slug: "name", ...nameBookingField },
{ isDefault: true, required: true, slug: "email", type: "email" },
{ isDefault: true, required: false, slug: "rescheduleReason", type: "textarea" },
{ isDefault: true, required: true, slug: "email", type: "email", disableOnPrefill: false },
{
isDefault: true,
required: false,
slug: "rescheduleReason",
type: "textarea",
disableOnPrefill: false,
hidden: false,
},
...requestBookingFields
.filter((field) => field.type !== "name" && field.type !== "email")
.map((field) => ({ isDefault: false, ...field })),
@@ -1055,14 +1078,44 @@ describe("Event types Endpoints", () => {
let legacyEventTypeId2: number;
const expectedReturnSystemFields = [
{ isDefault: true, required: true, slug: "name", type: "name" },
{ isDefault: true, required: true, slug: "email", type: "email" },
{ isDefault: true, type: "radioInput", slug: "location", required: false },
{ isDefault: true, required: true, slug: "title", type: "text" },
{ isDefault: true, required: false, slug: "notes", type: "textarea" },
{ isDefault: true, required: false, slug: "guests", type: "multiemail" },
{ isDefault: true, required: false, slug: "rescheduleReason", type: "textarea" },
{ isDefault: true, type: "phone", slug: "attendeePhoneNumber", required: false },
{ isDefault: true, required: true, slug: "name", type: "name", disableOnPrefill: false },
{ isDefault: true, required: true, slug: "email", type: "email", disableOnPrefill: false },
{
isDefault: true,
type: "radioInput",
slug: "location",
required: false,
disableOnPrefill: false,
hidden: false,
label: "",
placeholder: "",
},
{ isDefault: true, required: true, slug: "title", type: "text", disableOnPrefill: false, hidden: true },
{
isDefault: true,
required: false,
slug: "notes",
type: "textarea",
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
required: false,
slug: "guests",
type: "multiemail",
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
required: false,
slug: "rescheduleReason",
type: "textarea",
disableOnPrefill: false,
hidden: false,
},
{ isDefault: true, type: "phone", slug: "attendeePhoneNumber", required: false, hidden: true },
];
beforeAll(async () => {
@@ -1382,6 +1435,8 @@ describe("Event types Endpoints", () => {
label: userDefinedBookingField.label,
required: userDefinedBookingField.required,
placeholder: userDefinedBookingField.placeholder,
disableOnPrefill: false,
hidden: false,
},
]);
});
@@ -1461,42 +1516,54 @@ describe("Event types Endpoints", () => {
type: "name",
slug: "name",
required: true,
disableOnPrefill: false,
},
{
isDefault: true,
type: "email",
slug: "email",
required: true,
disableOnPrefill: false,
},
{
isDefault: true,
type: "radioInput",
slug: "location",
required: false,
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
type: "text",
slug: "title",
required: true,
disableOnPrefill: false,
hidden: true,
},
{
isDefault: true,
type: "textarea",
slug: "notes",
required: false,
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
type: "multiemail",
slug: "guests",
required: false,
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
type: "textarea",
slug: "rescheduleReason",
required: false,
disableOnPrefill: false,
hidden: false,
},
]);
});
@@ -5,7 +5,7 @@ import { UserWithProfile } from "@/modules/users/users.repository";
import { Injectable, BadRequestException } from "@nestjs/common";
import {
transformBookingFieldsApiToInternal,
transformBookingFieldsApiRequestToInternal,
transformLocationsApiToInternal,
transformIntervalLimitsApiToInternal,
transformFutureBookingLimitsApiToInternal,
@@ -218,7 +218,7 @@ export class InputEventTypesService_2024_06_14 {
hasMultipleLocations: boolean
) {
const customFields: (SystemField | CustomField)[] = inputBookingFields
? transformBookingFieldsApiToInternal(inputBookingFields)
? transformBookingFieldsApiRequestToInternal(inputBookingFields)
: [];
const customFieldsWithoutNameEmail = customFields.filter(
(field) => field.type !== "name" && field.type !== "email"
@@ -682,48 +682,61 @@ describe("Organizations Event Types Endpoints", () => {
type: "name",
slug: "name",
required: true,
disableOnPrefill: false,
},
{
isDefault: true,
type: "email",
slug: "email",
required: true,
disableOnPrefill: false,
},
{
isDefault: true,
required: false,
slug: "attendeePhoneNumber",
type: "phone",
slug: "attendeePhoneNumber",
required: false,
hidden: true,
},
{
isDefault: true,
type: "radioInput",
slug: "location",
required: false,
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
type: "text",
slug: "title",
required: true,
disableOnPrefill: false,
hidden: true,
},
{
isDefault: true,
type: "textarea",
slug: "notes",
required: false,
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
type: "multiemail",
slug: "guests",
required: false,
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
type: "textarea",
slug: "rescheduleReason",
required: false,
disableOnPrefill: false,
hidden: false,
},
]);
});
+195 -16
View File
@@ -6998,6 +6998,10 @@
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `phone` and the URL contains query parameter `&phone=1234567890`, the phone field will be prefilled with this value and disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
@@ -7005,7 +7009,8 @@
"slug",
"label",
"required",
"placeholder"
"placeholder",
"hidden"
]
},
"AddressFieldInput_2024_06_14": {
@@ -7035,6 +7040,10 @@
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `address` and the URL contains query parameter `&address=1234 Main St, London`, the address field will be prefilled with this value and disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
@@ -7042,7 +7051,8 @@
"slug",
"label",
"required",
"placeholder"
"placeholder",
"hidden"
]
},
"TextFieldInput_2024_06_14": {
@@ -7072,6 +7082,10 @@
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `who-referred-you` and the URL contains query parameter `&who-referred-you=bob`, the text field will be prefilled with this value and disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
@@ -7079,7 +7093,8 @@
"slug",
"label",
"required",
"placeholder"
"placeholder",
"hidden"
]
},
"NumberFieldInput_2024_06_14": {
@@ -7109,6 +7124,10 @@
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `calories-per-day` and the URL contains query parameter `&calories-per-day=3000`, the number field will be prefilled with this value and disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
@@ -7116,7 +7135,8 @@
"slug",
"label",
"required",
"placeholder"
"placeholder",
"hidden"
]
},
"TextAreaFieldInput_2024_06_14": {
@@ -7146,6 +7166,10 @@
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `dear-diary` and the URL contains query parameter `&dear-diary=Today I shipped a feature`, the text area will be prefilled with this value and disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
@@ -7153,7 +7177,8 @@
"slug",
"label",
"required",
"placeholder"
"placeholder",
"hidden"
]
},
"SelectFieldInput_2024_06_14": {
@@ -7193,6 +7218,10 @@
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `language` and options of this select field are ['english', 'italian'] and the URL contains query parameter `&language=italian`, the 'italian' will be selected and the select field will be disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
@@ -7201,7 +7230,8 @@
"label",
"required",
"placeholder",
"options"
"options",
"hidden"
]
},
"MultiSelectFieldInput_2024_06_14": {
@@ -7237,6 +7267,10 @@
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `consultants` and the URL contains query parameter `&consultants=en&language=it`, the 'en' and 'it' will be selected and the select field will be disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
@@ -7244,7 +7278,8 @@
"slug",
"label",
"required",
"options"
"options",
"hidden"
]
},
"MultiEmailFieldInput_2024_06_14": {
@@ -7274,6 +7309,10 @@
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `consultants` and the URL contains query parameter `&[email protected]&[email protected]`, the these emails will be added and none more can be added."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
@@ -7281,7 +7320,8 @@
"slug",
"label",
"required",
"placeholder"
"placeholder",
"hidden"
]
},
"CheckboxGroupFieldInput_2024_06_14": {
@@ -7317,6 +7357,10 @@
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `notify-me` and the URL contains query parameter `&notify-me=true`, the checkbox will be selected and the checkbox field will be disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
@@ -7324,7 +7368,8 @@
"slug",
"label",
"required",
"options"
"options",
"hidden"
]
},
"RadioGroupFieldInput_2024_06_14": {
@@ -7360,6 +7405,10 @@
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `language` and options of this select field are ['english', 'italian'] and the URL contains query parameter `&language=italian`, the 'italian' radio buttom will be selected and the select field will be disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
@@ -7367,7 +7416,8 @@
"slug",
"label",
"required",
"options"
"options",
"hidden"
]
},
"BooleanFieldInput_2024_06_14": {
@@ -7392,13 +7442,18 @@
},
"disableOnPrefill": {
"type": "boolean"
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
"type",
"slug",
"label",
"required"
"required",
"hidden"
]
},
"BusinessDaysWindow_2024_06_14": {
@@ -8403,13 +8458,18 @@
},
"required": {
"type": "boolean"
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
}
},
"required": [
"isDefault",
"slug",
"type",
"required"
"required",
"hidden"
]
},
"RescheduleReasonDefaultFieldOutput_2024_06_14": {
@@ -8431,13 +8491,29 @@
},
"required": {
"type": "boolean"
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"label": {
"type": "string"
},
"placeholder": {
"type": "string"
},
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if URL contains query parameter `&rescheduleReason=busy`, the reschedule reason field will be prefilled with this value and disabled."
}
},
"required": [
"isDefault",
"slug",
"type",
"required"
"required",
"hidden",
"disableOnPrefill"
]
},
"TitleDefaultFieldOutput_2024_06_14": {
@@ -8459,13 +8535,29 @@
},
"required": {
"type": "boolean"
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"label": {
"type": "string"
},
"placeholder": {
"type": "string"
},
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if URL contains query parameter `&title=masterclass`, the title field will be prefilled with this value and disabled."
}
},
"required": [
"isDefault",
"slug",
"type",
"required"
"required",
"hidden",
"disableOnPrefill"
]
},
"NotesDefaultFieldOutput_2024_06_14": {
@@ -8487,13 +8579,29 @@
},
"required": {
"type": "boolean"
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"label": {
"type": "string"
},
"placeholder": {
"type": "string"
},
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if URL contains query parameter `&notes=hello`, the notes field will be prefilled with this value and disabled."
}
},
"required": [
"isDefault",
"slug",
"type",
"required"
"required",
"hidden",
"disableOnPrefill"
]
},
"GuestsDefaultFieldOutput_2024_06_14": {
@@ -8515,13 +8623,29 @@
},
"required": {
"type": "boolean"
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"label": {
"type": "string"
},
"placeholder": {
"type": "string"
},
"disableOnPrefill": {
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if URL contains query parameter `&[email protected]`, the guests field will be prefilled with this value and disabled."
}
},
"required": [
"isDefault",
"slug",
"type",
"required"
"required",
"hidden",
"disableOnPrefill"
]
},
"AddressFieldOutput_2024_06_14": {
@@ -8567,6 +8691,10 @@
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `address` and the URL contains query parameter `&address=1234 Main St, London`, the address field will be prefilled with this value and disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -8579,6 +8707,7 @@
"slug",
"label",
"required",
"hidden",
"isDefault"
]
},
@@ -8620,6 +8749,10 @@
"disableOnPrefill": {
"type": "boolean"
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -8632,6 +8765,7 @@
"slug",
"label",
"required",
"hidden",
"isDefault"
]
},
@@ -8684,6 +8818,10 @@
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `notify-me` and the URL contains query parameter `&notify-me=true`, the checkbox will be selected and the checkbox field will be disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -8697,6 +8835,7 @@
"label",
"required",
"options",
"hidden",
"isDefault"
]
},
@@ -8743,6 +8882,10 @@
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `consultants` and the URL contains query parameter `&[email protected]&[email protected]`, the these emails will be added and none more can be added."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -8755,6 +8898,7 @@
"slug",
"label",
"required",
"hidden",
"isDefault"
]
},
@@ -8807,6 +8951,10 @@
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `consultants` and the URL contains query parameter `&consultants=en&language=it`, the 'en' and 'it' will be selected and the select field will be disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -8820,6 +8968,7 @@
"label",
"required",
"options",
"hidden",
"isDefault"
]
},
@@ -8866,6 +9015,10 @@
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `calories-per-day` and the URL contains query parameter `&calories-per-day=3000`, the number field will be prefilled with this value and disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -8878,6 +9031,7 @@
"slug",
"label",
"required",
"hidden",
"isDefault"
]
},
@@ -8922,6 +9076,10 @@
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `phone` and the URL contains query parameter `&phone=1234567890`, the phone field will be prefilled with this value and disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -8934,6 +9092,7 @@
"slug",
"label",
"required",
"hidden",
"isDefault"
]
},
@@ -8986,6 +9145,10 @@
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `language` and options of this select field are ['english', 'italian'] and the URL contains query parameter `&language=italian`, the 'italian' radio buttom will be selected and the select field will be disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -8999,6 +9162,7 @@
"label",
"required",
"options",
"hidden",
"isDefault"
]
},
@@ -9055,6 +9219,10 @@
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `language` and options of this select field are ['english', 'italian'] and the URL contains query parameter `&language=italian`, the 'italian' will be selected and the select field will be disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -9068,6 +9236,7 @@
"label",
"required",
"options",
"hidden",
"isDefault"
]
},
@@ -9114,6 +9283,10 @@
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `dear-diary` and the URL contains query parameter `&dear-diary=Today I shipped a feature`, the text area will be prefilled with this value and disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -9126,6 +9299,7 @@
"slug",
"label",
"required",
"hidden",
"isDefault"
]
},
@@ -9172,6 +9346,10 @@
"type": "boolean",
"description": "Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value. For example, if the slug is `who-referred-you` and the URL contains query parameter `&who-referred-you=bob`, the text field will be prefilled with this value and disabled."
},
"hidden": {
"type": "boolean",
"description": "If true show under event type settings but don't show this booking field in the Booker. If false show in both."
},
"isDefault": {
"type": "object",
"default": false,
@@ -9184,6 +9362,7 @@
"slug",
"label",
"required",
"hidden",
"isDefault"
]
},