Redesign of the SMS automation page

This commit is contained in:
2026-09-14 16:49:43 +03:30
parent 8925c77ae0
commit f176fde1eb
15 changed files with 2089 additions and 226 deletions
@@ -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 {