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:
5 files changed
+188
-103
No files matched your search
+15
-1
@@ -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;
|
||||
};
|
||||
Reference in new issue
Block a user