Scheduling infrastructure for absolutely everyone.
chore: Add scheduler first name to event title (#17309)
Anik Dhabal Babu377cae9fd8dc
diff --git a/packages/core/event.test.ts b/packages/core/event.test.tsindex 02c8a9cb0fc..6d1168a5af1 100644--- a/packages/core/event.test.ts+++ b/packages/core/event.test.ts@@ -72,7 +72,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("example event name");});@@ -88,7 +87,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("event type: example event type");});@@ -104,7 +102,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("scheduler: example attendee");});@@ -120,7 +117,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("organiser: example host");});@@ -136,7 +132,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("user: example attendee");});@@ -152,7 +147,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("attendee: example attendee");});@@ -168,7 +162,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("host: example host");});@@ -184,7 +177,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("host or attendee: example attendee");});@@ -203,7 +195,6 @@ describe("event tests", () => {true);- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("host or attendee: example host");});@@ -221,7 +212,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("custom field: example custom field");});@@ -242,7 +232,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("custom field: example custom field");});@@ -263,7 +252,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("custom field: 808");});@@ -284,7 +272,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("custom field: ");});@@ -301,7 +288,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("location: in_person_attendee_address");});@@ -318,7 +304,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("location: in_person_attendee_address");});@@ -334,7 +319,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("location: ");});@@ -351,7 +335,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("location: ");});@@ -368,7 +351,6 @@ describe("event tests", () => {t: tFunc as TFunction,});- expect(tFunc).not.toHaveBeenCalled();expect(result).toBe("location: unknownNonsense");});});@@ -387,6 +369,22 @@ describe("event tests", () => {expect(result).toBe("event duration: 15 mins");});+ it("should support templating of Scheduler first name", () => {+ const tFunc = vi.fn(() => "foo");++ const result = event.getEventName({+ attendeeName: "example attendee",+ eventType: "example event type",+ host: "example host",+ location: "attendeeInPerson",+ eventName: "Scheduler first name: {Scheduler first name}",+ eventDuration: 15,+ t: tFunc as TFunction,+ });++ expect(result).toBe("Scheduler first name: example");+ });+describe("fn: validateCustomEventName", () => {it("should be valid when no variables used", () => {expect(event.validateCustomEventName("foo")).toBe(true);diff --git a/packages/core/event.ts b/packages/core/event.tsindex 6dc9653c5a8..aea32029ccb 100644--- a/packages/core/event.ts+++ b/packages/core/event.ts@@ -63,15 +63,15 @@ export function getEventName(eventNameObj: EventNameObjectType, forAttendeeView.replaceAll("{ATTENDEE}", attendeeName).replaceAll("{HOST}", eventNameObj.host).replaceAll("{HOST/ATTENDEE}", forAttendeeView ? eventNameObj.host : attendeeName)- .replaceAll("{Event duration}", `${String(eventNameObj.eventDuration)} mins`);+ .replaceAll("{Event duration}", `${String(eventNameObj.eventDuration)} mins`)+ .replaceAll(+ "{Scheduler first name}",+ attendeeName === eventNameObj.t("scheduler") ? "{Scheduler first name}" : attendeeName.split(" ")[0]+ );const { bookingFields } = eventNameObj || {};const { name } = bookingFields || {};- if (name && typeof name === "object" && !Array.isArray(name) && typeof name.firstName === "string") {- dynamicEventName = dynamicEventName.replaceAll("{Scheduler first name}", name.firstName.toString());- }-if (name && typeof name === "object" && !Array.isArray(name) && typeof name.lastName === "string") {dynamicEventName = dynamicEventName.replaceAll("{Scheduler last name}", name.lastName.toString());}diff --git a/packages/features/eventtypes/components/tabs/advanced/CustomEventTypeModal.tsx b/packages/features/eventtypes/components/tabs/advanced/CustomEventTypeModal.tsxindex 94cbc338363..05efd116717 100644--- a/packages/features/eventtypes/components/tabs/advanced/CustomEventTypeModal.tsx+++ b/packages/features/eventtypes/components/tabs/advanced/CustomEventTypeModal.tsx@@ -86,12 +86,12 @@ const CustomEventTypeModalForm: FC<CustomEventTypeModalFormProps> = (props) => {<p className="text-subtle ml-1 mr-5 w-32">{`{Scheduler}`}</p><p className="text-emphasis">{t("scheduler_full_name")}</p></div>- {isNameFieldSplit && (- <div className="mb-2.5 flex font-normal">- <p className="text-subtle ml-1 mr-5 w-32">{`{Scheduler first name}`}</p>- <p className="text-emphasis">{t("scheduler_first_name")}</p>- </div>- )}++ <div className="mb-2.5 flex font-normal">+ <p className="text-subtle ml-1 mr-5 w-32">{`{Scheduler first name}`}</p>+ <p className="text-emphasis">{t("scheduler_first_name")}</p>+ </div>+{isNameFieldSplit && (<div className="mb-2.5 flex font-normal"><p className="text-subtle ml-1 mr-5 w-32">{`{Scheduler last name}`}</p>