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:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user