Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Booking atom phone booking field and booking fields order #18678

Merged
merged 16 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@axiomhq/winston": "^1.2.0",
"@calcom/platform-constants": "*",
"@calcom/platform-enums": "*",
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.82",
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.84",
"@calcom/platform-libraries-0.0.2": "npm:@calcom/platform-libraries@0.0.2",
"@calcom/platform-types": "*",
"@calcom/platform-utils": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,6 @@ describe("Event types Endpoints", () => {
{ ...defaultResponseBookingFieldName, ...nameBookingField },
{ ...defaultResponseBookingFieldEmail },
{ ...defaultResponseBookingFieldLocation },
{ ...defaultResponseBookingFieldTitle },
{ ...defaultResponseBookingFieldGuests },
{ ...defaultResponseBookingFieldRescheduleReason },
{
type: "select",
label: "select which language you want to learn",
Expand All @@ -466,7 +463,10 @@ describe("Event types Endpoints", () => {
hidden: false,
isDefault: false,
},
{ ...defaultResponseBookingFieldTitle },
{ ...defaultResponseBookingFieldNotes },
{ ...defaultResponseBookingFieldGuests },
{ ...defaultResponseBookingFieldRescheduleReason },
];

expect(createdEventType.bookingFields).toEqual(expectedBookingFields);
Expand Down Expand Up @@ -942,9 +942,6 @@ describe("Event types Endpoints", () => {
{ ...defaultResponseBookingFieldName, ...nameBookingField },
{ ...defaultResponseBookingFieldEmail },
{ ...defaultResponseBookingFieldLocation },
{ ...defaultResponseBookingFieldTitle },
{ ...defaultResponseBookingFieldGuests },
{ ...defaultResponseBookingFieldRescheduleReason },
{
type: "select",
label: "select which language you want to learn",
Expand All @@ -956,7 +953,10 @@ describe("Event types Endpoints", () => {
hidden: false,
isDefault: false,
},
{ ...defaultResponseBookingFieldTitle },
{ ...defaultResponseBookingFieldNotes, ...notesBookingField },
{ ...defaultResponseBookingFieldGuests },
{ ...defaultResponseBookingFieldRescheduleReason },
];

expect(updatedEventType.bookingFields).toEqual(expectedBookingFields);
Expand Down Expand Up @@ -1185,7 +1185,14 @@ describe("Event types Endpoints", () => {
disableOnPrefill: false,
hidden: false,
},
{ isDefault: true, type: "phone", slug: "attendeePhoneNumber", required: false, hidden: true },
{
disableOnPrefill: false,
isDefault: true,
type: "phone",
slug: "attendeePhoneNumber",
required: false,
hidden: true,
},
{
isDefault: true,
required: false,
Expand Down Expand Up @@ -1623,24 +1630,24 @@ describe("Event types Endpoints", () => {
},
{
isDefault: true,
type: "multiemail",
slug: "guests",
type: "textarea",
slug: "notes",
required: false,
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
type: "textarea",
slug: "rescheduleReason",
type: "multiemail",
slug: "guests",
required: false,
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
type: "textarea",
slug: "notes",
slug: "rescheduleReason",
required: false,
disableOnPrefill: false,
hidden: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ export class OutputEventTypesService_2024_06_14 {
if (result.success) {
knownBookingFields.push(result.data);
} else {
console.log("transformBookingFields - failed to parse a field", bookingField);
console.log("transformBookingFields - parsing error", result.error);
supalarry marked this conversation as resolved.
Show resolved Hide resolved
unknownBookingFields.push({
type: "unknown",
slug: "unknown",
Expand All @@ -243,19 +245,7 @@ export class OutputEventTypesService_2024_06_14 {
}
}

const fields = [...transformBookingFieldsInternalToApi(knownBookingFields), ...unknownBookingFields];

// ensure additional notes are always at the end
return fields.sort((a, b) => {
if (!a?.slug || !b?.slug) return 0;
if (a.slug === "notes" && b.slug !== "notes") {
return 1;
}
if (b.slug === "notes" && a.slug !== "notes") {
return -1;
}
return 0;
});
return [...transformBookingFieldsInternalToApi(knownBookingFields), ...unknownBookingFields];
}

getDefaultBookingFields(isOrgTeamEvent: boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ describe("Organizations Event Types Endpoints", () => {
slug: "attendeePhoneNumber",
required: true,
label: "Phone number",
hidden: true,
},
],
};
Expand Down Expand Up @@ -632,6 +633,8 @@ describe("Organizations Event Types Endpoints", () => {
slug: "attendeePhoneNumber",
required: true,
hidden: true,
label: "Phone number",
disableOnPrefill: false,
},
{
isDefault: true,
Expand All @@ -643,24 +646,24 @@ describe("Organizations Event Types Endpoints", () => {
},
{
isDefault: true,
type: "multiemail",
slug: "guests",
type: "textarea",
slug: "notes",
required: false,
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
type: "textarea",
slug: "rescheduleReason",
type: "multiemail",
slug: "guests",
required: false,
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
type: "textarea",
slug: "notes",
slug: "rescheduleReason",
required: false,
disableOnPrefill: false,
hidden: false,
Expand Down Expand Up @@ -771,7 +774,14 @@ describe("Organizations Event Types Endpoints", () => {
expect(fetchedEventType.bookingFields).toEqual([
{ isDefault: true, required: true, slug: "name", type: "name", disableOnPrefill: false },
{ isDefault: true, required: true, slug: "email", type: "email", disableOnPrefill: false },
{ isDefault: true, type: "phone", slug: "attendeePhoneNumber", required: false, hidden: true },
{
disableOnPrefill: false,
isDefault: true,
type: "phone",
slug: "attendeePhoneNumber",
required: false,
hidden: true,
},
{
isDefault: true,
type: "radioInput",
Expand All @@ -791,23 +801,23 @@ describe("Organizations Event Types Endpoints", () => {
{
isDefault: true,
required: false,
slug: "guests",
type: "multiemail",
slug: "notes",
type: "textarea",
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
required: false,
slug: "rescheduleReason",
type: "textarea",
slug: "guests",
type: "multiemail",
disableOnPrefill: false,
hidden: false,
},
{
isDefault: true,
required: false,
slug: "notes",
slug: "rescheduleReason",
type: "textarea",
disableOnPrefill: false,
hidden: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
return {
...systemBeforeFieldPhone,
required: field.required,
hidden: field.hidden,
label: field.label,
placeholder: field.placeholder,
disableOnPrefill: !!field.disableOnPrefill,
};
}

Expand Down
Loading
Loading