feat: error message for invalid variables in custom event name (#7426)

* feat: add custom validate name util

* refactor: separate custom event type modal into a
different component

* feat: add validation to zod

* chore: add i18n key

* feat: add dynamic imports

* fix: padding

* Omit cache-hit exit 1, assuming it'll fail regardless

---------

Co-authored-by: Alex van Andel <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-03-06 12:14:54 +00:00
1 parent 8a9b985760
commit 3d41c64d81
5 files changed
+188 -103

No files matched your search

+15 -1
View File
@@ -1,4 +1,4 @@
import { TFunction } from "next-i18next";
import type { TFunction } from "next-i18next";
import { guessEventLocationType } from "@calcom/app-store/locations";
@@ -43,3 +43,17 @@ export function getEventName(eventNameObj: EventNameObjectType, forAttendeeView
.replace("{HOST/ATTENDEE}", forAttendeeView ? eventNameObj.host : eventNameObj.attendeeName)
);
}
export const validateCustomEventName = (value: string, message: string) => {
const validVariables = ["{Event type title}", "{Organiser}", "{Scheduler}", "{Location}"];
const matches = value.match(/\{([^}]+)\}/g);
if (matches?.length) {
for (const item of matches) {
if (!validVariables.includes(item)) {
return message;
}
}
}
return true;
};