Add org-scoped reusable SMS templates in the compose modal.

Users can save, pick, and delete prepared messages shared across the organization.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-14 14:15:42 +03:30
co-authored by Cursor
parent 3c27fae626
commit e04aa14b84
8 changed files with 450 additions and 6 deletions
+33
View File
@@ -5407,6 +5407,39 @@ export interface OutboundSmsHistoryResponse {
items: OutboundSmsLogDto[];
}
/* ——— قالب‌های آمادهٔ پیامک دستی (سازمانی) ——— */
export type SmsTemplateDto = {
id: string;
name: string;
body: string;
};
export const SMS_TEMPLATE_MAX = 40;
export const SMS_TEMPLATE_NAME_MAX = 80;
export const SMS_TEMPLATE_BODY_MAX = 500;
/** نرمال‌سازی لیست ذخیره‌شده؛ آیتم‌های ناقص حذف می‌شوند */
export function parseSmsTemplates(raw: unknown): SmsTemplateDto[] {
if (!Array.isArray(raw)) return [];
const out: SmsTemplateDto[] = [];
for (const row of raw) {
if (!row || typeof row !== "object") continue;
const rec = row as Record<string, unknown>;
const id = typeof rec.id === "string" ? rec.id.trim() : "";
const name = typeof rec.name === "string" ? rec.name.trim() : "";
const body = typeof rec.body === "string" ? rec.body.trim() : "";
if (!id || !name || body.length < 2) continue;
out.push({
id,
name: name.slice(0, SMS_TEMPLATE_NAME_MAX),
body: body.slice(0, SMS_TEMPLATE_BODY_MAX),
});
if (out.length >= SMS_TEMPLATE_MAX) break;
}
return out;
}
/* ——— پیامک گروهی ——— */
export type SmsCampaignStatus =