Skip to content

Commit

Permalink
fix: placeholder in custom event name (#7247)
Browse files Browse the repository at this point in the history
* fix: replace placeholder

* refactor: replace placeholder into a separate function
  • Loading branch information
G3root authored Feb 23, 2023
1 parent 17345f9 commit b018ee3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions apps/web/components/eventtype/EventAdvancedTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
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) => {
setPreviewText(
previewEventName
.replace("{Event type title}", eventNameObject.eventType)
.replace("{Scheduler}", eventNameObject.attendeeName)
.replace("{Organiser}", eventNameObject.host)
);
setPreviewText(replaceEventNamePlaceholder(eventNameObject, previewEventName));
};

useEffect(() => {
Expand All @@ -101,6 +102,8 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
}
}, [eventType.customInputs]);

const eventNamePlaceholder = replaceEventNamePlaceholder(eventNameObject, t("meeting_with_user"));

return (
<div className="flex flex-col space-y-8">
{/**
Expand Down Expand Up @@ -141,7 +144,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
<TextField
label={t("event_name_in_calendar")}
type="text"
placeholder={t("meeting_with_user")}
placeholder={eventNamePlaceholder}
defaultValue={eventType.eventName || ""}
{...formMethods.register("eventName", {
onChange: (e) => {
Expand Down Expand Up @@ -413,7 +416,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
<TextField
label={t("event_name_in_calendar")}
type="text"
placeholder={t("meeting_with_user")}
placeholder={eventNamePlaceholder}
defaultValue={eventType.eventName || ""}
{...formMethods.register("eventName", {
onChange: (e) => {
Expand Down

0 comments on commit b018ee3

Please sign in to comment.