Add switch button on SMS template cards to enable or disable individual SMS types

This commit is contained in:
2026-08-21 11:04:32 +03:30
parent 0aed0d7eae
commit ee3bc2b856
+41 -6
View File
@@ -182,17 +182,50 @@
<div
v-for="template in smsTemplates"
:key="template.key"
class="p-4 border-round-lg surface-ground border-1 border-color flex flex-column gap-3"
class="p-4 border-round-lg surface-ground border-1 border-color flex flex-column gap-3 transition-all transition-duration-200"
:class="{ 'opacity-80': templateForm[template.key] && !templateForm[template.key].enabled }"
>
<template v-if="templateForm[template.key]">
<div class="flex flex-column sm:flex-row sm:align-items-center justify-content-between gap-2 border-bottom-1 border-color pb-2">
<div class="flex align-items-center gap-2">
<i class="pi pi-bookmark text-primary"></i>
<label class="font-bold text-base text-color" :for="`sms-template-${template.key}`">
<div class="flex flex-column sm:flex-row sm:align-items-center justify-content-between gap-3 border-bottom-1 border-color pb-3">
<div class="flex align-items-center gap-3">
<div
class="w-2rem h-2rem border-round-lg flex align-items-center justify-content-center flex-shrink-0"
:class="templateForm[template.key].enabled ? 'bg-primary-light text-primary' : 'surface-200 text-muted'"
>
<i class="pi pi-bookmark"></i>
</div>
<div>
<div class="flex align-items-center gap-2 flex-wrap">
<label class="font-bold text-base text-color cursor-pointer" :for="`sms-toggle-${template.key}`">
{{ template.label }}
</label>
<Tag
:value="templateForm[template.key].enabled ? 'ارسال پیامک: فعال' : 'ارسال پیامک: غیرفعال'"
:severity="templateForm[template.key].enabled ? 'success' : 'secondary'"
class="text-xs font-semibold"
/>
</div>
<span class="text-xs text-muted font-mono">{{ template.key }}</span>
<span class="text-xs text-muted font-mono block mt-1">{{ template.key }}</span>
</div>
</div>
<div class="flex align-items-center gap-3 flex-shrink-0">
<span class="text-xs font-semibold text-color">
{{ templateForm[template.key].enabled ? 'فعال' : 'غیرفعال' }}
</span>
<InputSwitch
:inputId="`sms-toggle-${template.key}`"
v-model="templateForm[template.key].enabled"
/>
</div>
</div>
<div
v-if="!templateForm[template.key].enabled"
class="p-2 px-3 border-round surface-card border-1 border-dashed border-color text-xs text-muted flex align-items-center gap-2"
>
<i class="pi pi-info-circle text-orange-500 flex-shrink-0"></i>
<span>ارسال این نوع پیامک غیرفعال است و با وقوع رویداد مربوطه پیامکی ارسال نخواهد شد.</span>
</div>
<div class="flex flex-column sm:flex-row sm:align-items-center gap-2">
@@ -761,6 +794,7 @@ const emptyFormEntry = (template) => {
}
return {
enabled: template?.enabled !== false,
templateId: template?.templateId || '',
variables: vars
};
@@ -881,6 +915,7 @@ const saveSmsTemplates = async () => {
? entry.variables
: Object.values(entry.variables || {});
smsTemplatesPayload[template.key] = {
enabled: Boolean(entry.enabled),
templateId: String(entry.templateId || '').trim(),
variables: rawVariables
.filter((v) => v && v.slot)