feat: Add full names in the description of dynamic events. (#10251)

* Add full names in the descripiton of dynamic events.

* Initialising dynamic event desc after the check.

* Revert "Initialising dynamic event desc after the check."

This reverts commit ddd89c4e252f439a5875bfc34b20050a29b68de8.

* Revert "Add full names in the descripiton of dynamic events."

This reverts commit ce232d6256b4fe03c5b0665133be6ea524349c5c.

* Added booking title for dynamic events.

* Update apps/web/public/static/locales/en/common.json

* Fix typo.

* Fix lint error.

* Fix redundant booking information.

* Fix type script lint.

* Addressed review suggestions.

---------

Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
This commit is contained in:
authored and GitHub committed 2023-07-27 08:52:46 +00:00
1 parent 8cdddfa1d0
commit 98a156311d
8 files changed
+40 -5

No files matched your search

+5 -1
View File
@@ -165,10 +165,14 @@ export default function Success(props: SuccessProps) {
);
}
let evtName = props.eventType.eventName;
if (eventType.isDynamic && bookingInfo.responses?.title) {
evtName = bookingInfo.responses.title as string;
}
const eventNameObject = {
attendeeName,
eventType: props.eventType.title,
eventName: (props.dynamicEventName as string) || props.eventType.eventName,
eventName: evtName,
host: props.profile.name || "Nameless",
location: location,
bookingFields: bookingInfo.responses,
@@ -1962,5 +1962,6 @@
"org_team_names_example_4": "e.g. Engineering Team",
"org_team_names_example_5": "e.g. Data Analytics Team",
"org_max_team_warnings": "You will be able to add more teams later on.",
"what_is_this_meeting_about": "What is this meeting about?",
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
}
@@ -172,11 +172,14 @@ export const BookEventForm = ({ onCancel }: BookEventFormProps) => {
return defaults;
}, [eventType?.bookingFields, formValues, isRescheduling, bookingData, rescheduleUid]);
const disableBookingTitle = !!event.data?.isDynamic;
const bookingFormSchema = z
.object({
responses: event?.data
? getBookingResponsesSchema({
eventType: { bookingFields: getBookingFieldsWithSystemFields(event.data) },
eventType: {
bookingFields: getBookingFieldsWithSystemFields({ ...event.data, disableBookingTitle }),
},
view: rescheduleUid ? "reschedule" : "booking",
})
: // Fallback until event is loaded.
@@ -4,6 +4,7 @@ export const SystemField = z.enum([
"name",
"email",
"location",
"title",
"notes",
"guests",
"rescheduleReason",
@@ -56,12 +56,14 @@ export const getSmsReminderNumberSource = ({
export const getBookingFieldsWithSystemFields = ({
bookingFields,
disableGuests,
disableBookingTitle,
customInputs,
metadata,
workflows,
}: {
bookingFields: Fields | EventType["bookingFields"];
disableGuests: boolean;
disableBookingTitle?: boolean;
customInputs: EventTypeCustomInput[] | z.infer<typeof customInputSchema>[];
metadata: EventType["metadata"] | z.infer<typeof EventTypeMetaDataSchema>;
workflows: Prisma.EventTypeGetPayload<{
@@ -86,6 +88,7 @@ export const getBookingFieldsWithSystemFields = ({
return ensureBookingInputsHaveSystemFields({
bookingFields: parsedBookingFields,
disableGuests,
disableBookingTitle,
additionalNotesRequired: parsedMetaData?.additionalNotesRequired || false,
customInputs: parsedCustomInputs,
workflows,
@@ -95,12 +98,14 @@ export const getBookingFieldsWithSystemFields = ({
export const ensureBookingInputsHaveSystemFields = ({
bookingFields,
disableGuests,
disableBookingTitle,
additionalNotesRequired,
customInputs,
workflows,
}: {
bookingFields: Fields;
disableGuests: boolean;
disableBookingTitle?: boolean;
additionalNotesRequired: boolean;
customInputs: z.infer<typeof customInputSchema>[];
workflows: Prisma.EventTypeGetPayload<{
@@ -119,6 +124,7 @@ export const ensureBookingInputsHaveSystemFields = ({
}>["workflows"];
}) => {
// If bookingFields is set already, the migration is done.
const hideBookingTitle = disableBookingTitle ?? true;
const handleMigration = !bookingFields.length;
const CustomInputTypeToFieldType = {
[EventTypeCustomInputType.TEXT]: BookingFieldTypeEnum.text,
@@ -208,6 +214,22 @@ export const ensureBookingInputsHaveSystemFields = ({
// These fields should be added after other user fields
const systemAfterFields: typeof bookingFields = [
{
defaultLabel: "what_is_this_meeting_about",
type: "text",
name: "title",
editable: "system-but-optional",
required: true,
hidden: hideBookingTitle,
defaultPlaceholder: "",
sources: [
{
label: "Default",
id: "default",
type: "default",
},
],
},
{
defaultLabel: "additional_notes",
type: "textarea",
@@ -386,6 +386,7 @@ const getEventTypesFromDB = async (eventTypeId: number) => {
customInputs: customInputSchema.array().parse(eventType?.customInputs || []),
locations: (eventType?.locations ?? []) as LocationObject[],
bookingFields: getBookingFieldsWithSystemFields(eventType || {}),
isDynamic: false,
};
};
@@ -973,11 +974,12 @@ async function handler(
const responses = "responses" in reqBody ? reqBody.responses : null;
const evtName = !eventType?.isDynamic ? eventType.eventName : responses?.title;
const eventNameObject = {
//TODO: Can we have an unnamed attendee? If not, I would really like to throw an error here.
attendeeName: fullName || "Nameless",
eventType: eventType.title,
eventName: eventType.eventName,
eventName: evtName,
// we send on behalf of team if >1 round robin attendee | collective
teamName: eventType.schedulingType === "COLLECTIVE" || users.length > 1 ? eventType.team?.name : null,
// TODO: Can we have an unnamed organizer? If not, I would really like to throw an error here.
@@ -131,10 +131,10 @@ export const getPublicEvent = async (
enabledLayouts: [...bookerLayoutOptions],
defaultLayout: BookerLayouts.MONTH_VIEW,
} as BookerLayoutSettings;
const disableBookingTitle = !defaultEvent.isDynamic;
return {
...defaultEvent,
bookingFields: getBookingFieldsWithSystemFields(defaultEvent),
bookingFields: getBookingFieldsWithSystemFields({ ...defaultEvent, disableBookingTitle }),
// Clears meta data since we don't want to send this in the public api.
users: users.map((user) => ({ ...user, metadata: undefined })),
locations: privacyFilteredLocations(locations),
@@ -201,6 +201,7 @@ export const getPublicEvent = async (
profile: getProfileFromEvent(event),
users,
orgDomain: org,
isDynamic: false,
};
};
+1
View File
@@ -101,6 +101,7 @@ const commons = {
customInputs: [],
// Default value of disableGuests from DB.
disableGuests: false,
disableBookingTitle: false,
metadata: {},
workflows: [],
}),