updated event title message (#1132)

* updated event title message

* 4 arguments replaced by an object

* translations

* requested changes

* further requested changes

* test fix and other minor changes

* lint fix
This commit is contained in:
Syed Ali Shahbaz authored and GitHub committed 2021-11-08 16:34:12 +05:30
1 parent 0ef6d8b452
commit a404ca847c
5 files changed
+41 -10

No files matched your search

+18 -7
View File
@@ -1,8 +1,19 @@
export function getEventName(
name: string | string[] | undefined,
eventTitle: string,
eventNameTemplate: string | null
) {
if (!name || !(typeof name === "string")) name = ""; // If name is not set or is not of proper type
return eventNameTemplate ? eventNameTemplate.replace("{USER}", name) : eventTitle + " with " + name;
import { TFunction } from "next-i18next";
type EventNameObjectType = {
attendeeName: string;
eventType: string;
eventName?: string | null;
host: string;
t: TFunction;
};
export function getEventName(eventNameObj: EventNameObjectType) {
return eventNameObj.eventName
? eventNameObj.eventName.replace("{USER}", eventNameObj.attendeeName)
: eventNameObj.t("event_between_users", {
eventName: eventNameObj.eventType,
host: eventNameObj.host,
attendeeName: eventNameObj.attendeeName,
});
}