fix: ui and ux improvements in booking questions (#7734)
This commit is contained in:
1 parent
7b5e2c8bab
commit
a363b1e903
16 files changed
+183
-100
No files matched your search
@@ -11,7 +11,6 @@ import { z } from "zod";
|
||||
|
||||
import BookingPageTagManager from "@calcom/app-store/BookingPageTagManager";
|
||||
import type { EventLocationType } from "@calcom/app-store/locations";
|
||||
import { getEventLocationType, locationKeyToString } from "@calcom/app-store/locations";
|
||||
import { createPaymentLink } from "@calcom/app-store/stripepayment/lib/client";
|
||||
import { getEventTypeAppData } from "@calcom/app-store/utils";
|
||||
import type { LocationObject } from "@calcom/core/location";
|
||||
@@ -29,6 +28,7 @@ import {
|
||||
import getBookingResponsesSchema, {
|
||||
getBookingResponsesPartialSchema,
|
||||
} from "@calcom/features/bookings/lib/getBookingResponsesSchema";
|
||||
import getLocationOptionsForSelect from "@calcom/features/bookings/lib/getLocationOptionsForSelect";
|
||||
import { FormBuilderField } from "@calcom/features/form-builder/FormBuilder";
|
||||
import classNames from "@calcom/lib/classNames";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
@@ -143,26 +143,14 @@ const BookingFields = ({
|
||||
}
|
||||
const optionsInputs = field.optionsInputs;
|
||||
|
||||
const options = locations.map((location) => {
|
||||
const eventLocation = getEventLocationType(location.type);
|
||||
const locationString = locationKeyToString(location);
|
||||
|
||||
if (typeof locationString !== "string" || !eventLocation) {
|
||||
// It's possible that location app got uninstalled
|
||||
return null;
|
||||
}
|
||||
const type = eventLocation.type;
|
||||
const optionInput = optionsInputs[type as keyof typeof optionsInputs];
|
||||
// TODO: Instead of `getLocationOptionsForSelect` options should be retrieved from dataStore[field.getOptionsAt]. It would make it agnostic of the `name` of the field.
|
||||
const options = getLocationOptionsForSelect(locations, t);
|
||||
options.forEach((option) => {
|
||||
const optionInput = optionsInputs[option.value as keyof typeof optionsInputs];
|
||||
if (optionInput) {
|
||||
optionInput.placeholder = t(eventLocation?.attendeeInputPlaceholder || "");
|
||||
optionInput.placeholder = option.inputPlaceholder;
|
||||
}
|
||||
|
||||
return {
|
||||
label: t(locationString),
|
||||
value: type,
|
||||
};
|
||||
});
|
||||
|
||||
field.options = options.filter(
|
||||
(location): location is NonNullable<(typeof options)[number]> => !!location
|
||||
);
|
||||
|
||||
@@ -8,6 +8,7 @@ import { v5 as uuidv5 } from "uuid";
|
||||
|
||||
import type { EventNameObjectType } from "@calcom/core/event";
|
||||
import { getEventName } from "@calcom/core/event";
|
||||
import getLocationsOptionsForSelect from "@calcom/features/bookings/lib/getLocationOptionsForSelect";
|
||||
import DestinationCalendarSelector from "@calcom/features/calendars/DestinationCalendarSelector";
|
||||
import { FormBuilder } from "@calcom/features/form-builder/FormBuilder";
|
||||
import { classNames } from "@calcom/lib";
|
||||
@@ -148,6 +149,11 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
|
||||
description={t("booking_questions_description")}
|
||||
addFieldLabel={t("add_a_booking_question")}
|
||||
formProp="bookingFields"
|
||||
dataStore={{
|
||||
options: {
|
||||
locations: getLocationsOptionsForSelect(eventType?.locations ?? [], t),
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<hr className="border-subtle" />
|
||||
<RequiresConfirmationController
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Page, PlaywrightTestArgs } from "@playwright/test";
|
||||
import type { Locator, Page, PlaywrightTestArgs } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
import { WebhookTriggerEvents } from "@prisma/client";
|
||||
import type { createUsersFixture } from "playwright/fixtures/users";
|
||||
@@ -9,6 +9,10 @@ import prisma from "@calcom/prisma";
|
||||
import { test } from "./lib/fixtures";
|
||||
import { createHttpServer, waitFor, selectFirstAvailableTimeSlotNextMonth } from "./lib/testUtils";
|
||||
|
||||
async function getLabelText(field: Locator) {
|
||||
return await field.locator("label").first().locator("span").first().innerText();
|
||||
}
|
||||
|
||||
test.describe("Manage Booking Questions", () => {
|
||||
test.afterEach(async ({ users }) => {
|
||||
await users.deleteAll();
|
||||
@@ -91,7 +95,7 @@ async function runTestStepsCommonForTeamAndUserEventType(
|
||||
|
||||
await expect(userFieldLocator.locator('[name="how_are_you"]')).toBeVisible();
|
||||
// There are 2 labels right now. Will be one in future. The second one is hidden
|
||||
expect(await userFieldLocator.locator("label").nth(0).innerText()).toBe("How are you?");
|
||||
expect(await getLabelText(userFieldLocator)).toBe("How are you?");
|
||||
await expect(userFieldLocator.locator("input[type=text]")).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -140,7 +144,7 @@ async function runTestStepsCommonForTeamAndUserEventType(
|
||||
expect(
|
||||
await formBuilderFieldLocator.locator('[name="how_are_you"]').getAttribute("placeholder")
|
||||
).toBe("I'm fine, thanks");
|
||||
expect(await formBuilderFieldLocator.locator("label").nth(0).innerText()).toBe("How are you?");
|
||||
expect(await getLabelText(formBuilderFieldLocator)).toBe("How are you?");
|
||||
await formBuilderFieldLocator.locator('[name="how_are_you"]').fill("I am great!");
|
||||
await bookTimeSlot({ page, name: "Booker", email: "[email protected]" });
|
||||
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
||||
|
||||
@@ -1625,8 +1625,7 @@
|
||||
"not_enough_seats": "Not enough seats",
|
||||
"form_builder_field_already_exists": "A field with this name already exists",
|
||||
"form_builder_field_add_subtitle": "Customize the questions asked on the booking page",
|
||||
"form_builder_system_field_cant_delete": "This system field can't be removed.",
|
||||
"form_builder_system_field_cant_toggle": "This system field can't be toggled.",
|
||||
"show_on_booking_page":"Show on booking page",
|
||||
"get_started_zapier_templates": "Get started with Zapier templates",
|
||||
"team_is_unpublished": "{{team}} is unpublished",
|
||||
"team_is_unpublished_description": "This team link is currently not available. Please contact the team owner or ask them publish it.",
|
||||
|
||||
@@ -1614,8 +1614,6 @@
|
||||
"booking_confirmation_failed": "Échec de la confirmation de la réservation",
|
||||
"form_builder_field_already_exists": "Un champ avec ce nom existe déjà",
|
||||
"form_builder_field_add_subtitle": "Personnalisez les questions posées sur la page de réservation.",
|
||||
"form_builder_system_field_cant_delete": "Ce champ système ne peut pas être supprimé.",
|
||||
"form_builder_system_field_cant_toggle": "Ce champ système ne peut pas être activé.",
|
||||
"get_started_zapier_templates": "Démarrer avec les modèles Zapier",
|
||||
"team_member": "Membre d'équipe",
|
||||
"a_routing_form": "Un formulaire de routage",
|
||||
|
||||
@@ -1614,8 +1614,6 @@
|
||||
"booking_confirmation_failed": "אישור ההזמנה נכשל",
|
||||
"form_builder_field_already_exists": "שדה עם שם זה כבר קיים",
|
||||
"form_builder_field_add_subtitle": "התאמת השאלות שנשאלות בדף התזמון",
|
||||
"form_builder_system_field_cant_delete": "שדה מערכת זה לא ניתן להסרה.",
|
||||
"form_builder_system_field_cant_toggle": "שדה מערכת זה לא ניתן לשינוי.",
|
||||
"get_started_zapier_templates": "התחל עם תבניות Zapier",
|
||||
"team_is_unpublished": "צוות {{team}} אינו מפורסם",
|
||||
"team_is_unpublished_description": "קישור הצוות הזה אינו זמין כעת. אנא צור קשר עם הבעלים של הצוות או בקש מהם לפרסם אותו.",
|
||||
|
||||
@@ -1614,8 +1614,6 @@
|
||||
"booking_confirmation_failed": "Не удалось подтвердить бронирование",
|
||||
"form_builder_field_already_exists": "Поле с таким именем уже существует",
|
||||
"form_builder_field_add_subtitle": "Настроить вопросы, задаваемые на странице бронирования",
|
||||
"form_builder_system_field_cant_delete": "Это системное поле нельзя удалить.",
|
||||
"form_builder_system_field_cant_toggle": "Это системное поле нельзя переключить.",
|
||||
"get_started_zapier_templates": "Начать работу с шаблонами Zapier",
|
||||
"team_member": "Участник команды",
|
||||
"a_routing_form": "Форма маршрутизации",
|
||||
|
||||
Reference in new issue
Block a user