fix: placeholder in custom event name (#7247)

* fix: replace placeholder

* refactor: replace placeholder into a separate function
pull/7260/head^2
Nafees Nazik 2023-02-23 21:16:36 +05:30 committed by GitHub
parent 17345f9326
commit b018ee34a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 8 deletions

View File

@ -82,13 +82,14 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
setCustomInputs([...customInputs]); setCustomInputs([...customInputs]);
}; };
const replaceEventNamePlaceholder = (eventNameObject: EventNameObjectType, previewEventName: string) =>
previewEventName
.replace("{Event type title}", eventNameObject.eventType)
.replace("{Scheduler}", eventNameObject.attendeeName)
.replace("{Organiser}", eventNameObject.host);
const changePreviewText = (eventNameObject: EventNameObjectType, previewEventName: string) => { const changePreviewText = (eventNameObject: EventNameObjectType, previewEventName: string) => {
setPreviewText( setPreviewText(replaceEventNamePlaceholder(eventNameObject, previewEventName));
previewEventName
.replace("{Event type title}", eventNameObject.eventType)
.replace("{Scheduler}", eventNameObject.attendeeName)
.replace("{Organiser}", eventNameObject.host)
);
}; };
useEffect(() => { useEffect(() => {
@ -101,6 +102,8 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
} }
}, [eventType.customInputs]); }, [eventType.customInputs]);
const eventNamePlaceholder = replaceEventNamePlaceholder(eventNameObject, t("meeting_with_user"));
return ( return (
<div className="flex flex-col space-y-8"> <div className="flex flex-col space-y-8">
{/** {/**
@ -141,7 +144,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
<TextField <TextField
label={t("event_name_in_calendar")} label={t("event_name_in_calendar")}
type="text" type="text"
placeholder={t("meeting_with_user")} placeholder={eventNamePlaceholder}
defaultValue={eventType.eventName || ""} defaultValue={eventType.eventName || ""}
{...formMethods.register("eventName", { {...formMethods.register("eventName", {
onChange: (e) => { onChange: (e) => {
@ -413,7 +416,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
<TextField <TextField
label={t("event_name_in_calendar")} label={t("event_name_in_calendar")}
type="text" type="text"
placeholder={t("meeting_with_user")} placeholder={eventNamePlaceholder}
defaultValue={eventType.eventName || ""} defaultValue={eventType.eventName || ""}
{...formMethods.register("eventName", { {...formMethods.register("eventName", {
onChange: (e) => { onChange: (e) => {