Redesign of the SMS automation page
This commit is contained in:
@@ -63,8 +63,32 @@ export function buildSendAts(
|
||||
return times;
|
||||
}
|
||||
|
||||
export function applyMessageTemplate(text: string, title: string): string {
|
||||
return text.replace(/\{title\}/g, title).replace(/\{عنوان\}/g, title);
|
||||
export function applyMessageTemplate(
|
||||
text: string,
|
||||
vars: {
|
||||
title?: string;
|
||||
name?: string;
|
||||
phone?: string;
|
||||
date?: string;
|
||||
company?: string;
|
||||
},
|
||||
): string {
|
||||
const map: Record<string, string> = {
|
||||
title: vars.title ?? '',
|
||||
عنوان: vars.title ?? '',
|
||||
نام: vars.name ?? '',
|
||||
name: vars.name ?? '',
|
||||
شماره: vars.phone ?? '',
|
||||
phone: vars.phone ?? '',
|
||||
تاریخ: vars.date ?? '',
|
||||
date: vars.date ?? '',
|
||||
شرکت: vars.company ?? '',
|
||||
company: vars.company ?? '',
|
||||
};
|
||||
return text.replace(/\{([^}]+)\}/g, (full, key: string) => {
|
||||
const next = map[key.trim()];
|
||||
return next === undefined ? full : next;
|
||||
});
|
||||
}
|
||||
|
||||
export function clipSms(text: string): string {
|
||||
|
||||
Reference in New Issue
Block a user