fix: Allow attendee first and last name from attendee name when name … (#11287)

chore/add-otel-new^2
Ujwal Kumar 2023-09-14 19:54:58 +05:30 committed by GitHub
parent 59c0a71db7
commit d65f0ee0e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 2 deletions

View File

@ -48,14 +48,27 @@ const customTemplate = (
const currentTimeFormat = timeFormat || TimeFormat.TWELVE_HOUR;
const attendeeNameWords = variables.attendeeName?.trim().split(" ");
const attendeeNameWordCount = attendeeNameWords?.length ?? 0;
const attendeeFirstName = variables.attendeeFirstName
? variables.attendeeFirstName
: attendeeNameWords?.[0] ?? "";
const attendeeLastName = variables.attendeeLastName
? variables.attendeeLastName
: attendeeNameWordCount > 1
? attendeeNameWords![attendeeNameWordCount - 1]
: "";
let dynamicText = text
.replaceAll("{EVENT_NAME}", variables.eventName || "")
.replaceAll("{ORGANIZER}", variables.organizerName || "")
.replaceAll("{ATTENDEE}", variables.attendeeName || "")
.replaceAll("{ORGANIZER_NAME}", variables.organizerName || "") //old variable names
.replaceAll("{ATTENDEE_NAME}", variables.attendeeName || "") //old variable names
.replaceAll("{ATTENDEE_FIRST_NAME}", variables.attendeeFirstName || "")
.replaceAll("{ATTENDEE_LAST_NAME}", variables.attendeeLastName || "")
.replaceAll("{ATTENDEE_FIRST_NAME}", attendeeFirstName)
.replaceAll("{ATTENDEE_LAST_NAME}", attendeeLastName)
.replaceAll("{EVENT_DATE}", translatedDate)
.replaceAll("{EVENT_TIME}", variables.eventDate?.format(currentTimeFormat) || "")
.replaceAll("{START_TIME}", variables.eventDate?.format(currentTimeFormat) || "")