2 lines
23 KiB
JavaScript
2 lines
23 KiB
JavaScript
import{_ as ge,v as ae,t as le,a as be}from"./AudienceSegmentPicker.vue_vue_type_script_setup_true_lang-19680dbf.js";import{_ as re,u as ie}from"./useBaseTable-e4bbf0da.js";import{_ as ye}from"./button.vue_vue_type_style_index_0_lang-99dfcd06.js";import{g as he,a as xe,p as ke,s as we,b as $e,c as Se,d as Ie,e as Pe,f as oe,r as Re}from"./pushNotification-b05193da.js";import{t as X}from"./useDataTime-5442c624.js";import{M as ne}from"./index-609e9a96.js";import{I as Q}from"./index-49e2e544.js";import{P as Ce}from"./index-60d2bcc6.js";import{d as Y,g as h,h as P,v as Te,J as De,o as p,c as y,a as e,b as i,j as L,w as d,e as g,t as n,p as ue,k as $,H as de,D as b,K as Be,i as W,F as je}from"./index-bc4edd51.js";import{_ as Le}from"./BasicModal.vue_vue_type_style_index_0_lang-7803828f.js";import{I as Ae}from"./Icon-c9ad16b9.js";import{B as qe}from"./index-9df7eaa1.js";import{D as Ue,_ as Ne}from"./index-d79a436e.js";import{S as Me}from"./index-d4870df7.js";import{T as Oe}from"./isSymbol-f9834f4f.js";import{_ as Ke,T as Ve}from"./index-627337a8.js";import"./dayjs-26457b5b.js";import"./index-4e41e7b6.js";import"./styleChecker-bc667521.js";import"./index-393b875d.js";import"./index-47b6ba8f.js";import"./vnode-f2307909.js";import"./shallowequal-cad00b6e.js";import"./index-1d49b36b.js";import"./_plugin-vue_export-helper-c8347567.js";import"./DialogWrap-f12e49af.js";import"./omit-6f60253b.js";import"./pickAttrs-1c46cfba.js";import"./css-aae66f86.js";import"./useState-47ff4833.js";import"./index-727535d5.js";import"./toArray-b01cb1f9.js";import"./SearchOutlined-4504ec77.js";import"./isMobile-e2e89480.js";import"./useMemo-8275a234.js";import"./FormItemContext-4e017a44.js";import"./updateLocale-7b0be7e3.js";import"./index-bc659f42.js";import"./lodash-3efc1909.js";import"./BaseSwitch.vue_vue_type_script_setup_true_lang-9775c8a5.js";import"./index-5ea3cefd.js";import"./Badge-627fd6d3.js";import"./isNumeric-3f69e2aa.js";import"./index-34768277.js";import"./index-ae018072.js";import"./index-3aafac3f.js";import"./isPlainObject-ed8996b4.js";import"./useRefs-225197bd.js";import"./_flatRest-9adb1e9a.js";const Fe=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,customRender:s=>{var D;const r=((D=s==null?void 0:s.record)==null?void 0:D.record)??(s==null?void 0:s.record)??s;return(typeof(r==null?void 0:r.index)=="number"?r.index:0)+1}},{title:"نام",dataIndex:"first_name",key:"first_name",filterable:!0},{title:"نام خانوادگی",dataIndex:"last_name",key:"last_name",filterable:!0},{title:"شماره همراه",dataIndex:"phone",key:"phone",filterable:!0},{title:"اعلان فعال",dataIndex:"has_push",key:"has_push",filterField:"has_push",type:"Select",filterable:!0,filterComponentProps:{options:[{label:"فعال",value:"1"},{label:"غیرفعال",value:"0"}]},customRender:s=>{var k;const r=((k=s==null?void 0:s.record)==null?void 0:k.record)??(s==null?void 0:s.record)??s;return r!=null&&r.has_push?"✓ فعال":"—"}},{title:"زمان ثبتنام",dataIndex:"created_at",key:"created_at",type:"Date",filterable:!0,customRender:s=>{var k;const r=((k=s==null?void 0:s.record)==null?void 0:k.record)??(s==null?void 0:s.record)??s;return r!=null&&r.created_at?X(r.created_at):"-"}}],Je={class:"space-y-4"},ze={class:"grid grid-cols-1 xl:grid-cols-3 gap-4"},Ee={class:"xl:col-span-2 space-y-4"},He=e("div",{class:"mb-1 text-sm text-gray-600"},"عنوان نوتیفیکیشن *",-1),Ge=e("div",{class:"mb-1 text-sm text-gray-600"},"متن نوتیفیکیشن *",-1),Qe=e("div",{class:"mb-1 text-sm text-gray-600"},"لینک (اختیاری)",-1),We={class:"flex flex-wrap gap-2"},Xe={key:0,class:"rounded-lg border border-blue-200 bg-blue-50/60 p-4 space-y-3"},Ye={class:"flex items-center justify-between gap-2"},Ze=e("div",{class:"font-semibold text-gray-800"},"روند ارسال نوتیفیکیشن",-1),et={class:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-sm"},tt={class:"bg-white rounded-md border border-gray-100 px-3 py-2"},st=e("div",{class:"text-gray-500 text-xs"},"پیشرفت",-1),at={class:"font-semibold"},lt={class:"bg-white rounded-md border border-gray-100 px-3 py-2"},ot=e("div",{class:"text-gray-500 text-xs"},"موفق",-1),nt={class:"font-semibold text-green-700"},rt={class:"bg-white rounded-md border border-gray-100 px-3 py-2"},it=e("div",{class:"text-gray-500 text-xs"},"ناموفق",-1),ut={class:"font-semibold text-red-600"},dt={class:"bg-white rounded-md border border-gray-100 px-3 py-2"},ct=e("div",{class:"text-gray-500 text-xs"},"درصد",-1),vt={class:"font-semibold"},mt={key:0,class:"text-sm text-gray-600 m-0"},_t={key:1,class:"text-sm text-red-600 m-0"},pt={class:"bg-gray-50 rounded-lg p-4 border border-gray-200 space-y-2 text-sm"},ft=e("div",{class:"font-semibold text-gray-700 mb-2"},"آمار اعلانها",-1),gt={class:"grid grid-cols-1 gap-2"},bt={class:"flex justify-between items-center bg-white rounded-md px-3 py-2 border border-gray-100"},yt=e("span",{class:"text-gray-600"},"کاربران با اعلان فعال",-1),ht={class:"text-green-700"},xt={class:"flex justify-between items-center bg-white rounded-md px-3 py-2 border border-gray-100"},kt=e("span",{class:"text-gray-600"},"کل اشتراک push",-1),wt=e("div",{class:"font-semibold text-gray-700 mb-2 pt-2"},"راهنما",-1),$t=e("p",{class:"text-gray-600 leading-6 m-0"}," فقط کاربرانی که اعلان را در اپ فعال کردهاند، نوتیف دریافت میکنند. ",-1),St=e("p",{class:"text-gray-600 leading-6 m-0"}," از فیلتر «اعلان فعال» میتوانید فقط کاربران با اعلان روشن یا خاموش را ببینید. ",-1),It=e("p",{class:"text-gray-600 leading-6 m-0"}," برای ارسال محدود، کاربران را از جدول پایین انتخاب کنید. ",-1),Pt={key:0,class:"pt-2 border-t border-gray-200"},Rt=e("div",{class:"font-medium mb-1"},"آخرین ارسال:",-1),Ct={key:0,class:"text-amber-700 mb-1"},Tt={key:1,class:"text-amber-700 mb-1"},Dt={key:2},Bt={key:3},jt={key:4},Lt={key:5},At={key:6},qt={key:7},Ut={class:"border-t border-gray-200 pt-4"},Nt=e("div",{class:"mb-2 text-sm text-gray-600"}," کاربران را جستجو کنید و برای ارسال محدود، آنها را انتخاب کنید. ",-1),Mt=Y({__name:"PushSendPanel",emits:["sent"],setup(s,{emit:r}){const{TextArea:k}=Q,[D]=ie(),c=h({title:"ماچارتا",body:"",url:"/"}),_=h(!1),v=h([]),t=h(null),l=h(null),C=h({uniqueUsers:0,totalSubscriptions:0}),N=h(!1),B=h({segments:[],inactiveDays:7,subscriberInactiveDays:3}),V=h(!1),F=h("");let M=null;const J=P(()=>({selectedRowKeys:v.value,onChange:a=>{v.value=a.map(String)},preserveSelectedRowKeys:!0})),A=P(()=>{var o;const a=(o=l.value)==null?void 0:o.status;return a==="queued"||a==="running"}),H=P(()=>l.value?Math.max(l.value.total,l.value.processed):0),S=P(()=>{var a;switch((a=l.value)==null?void 0:a.status){case"queued":return"در صف";case"running":return"در حال ارسال";case"completed":return"تمام شد";case"failed":return"ناموفق";default:return""}}),U=P(()=>{var a;switch((a=l.value)==null?void 0:a.status){case"queued":return"bg-amber-100 text-amber-800";case"running":return"bg-blue-100 text-blue-800";case"completed":return"bg-green-100 text-green-800";case"failed":return"bg-red-100 text-red-700";default:return"bg-gray-100 text-gray-600"}}),O=P(()=>{var a,o;return((a=l.value)==null?void 0:a.status)==="failed"?"exception":((o=l.value)==null?void 0:o.status)==="completed"?"success":"active"}),R=P(()=>{var a,o;return((a=l.value)==null?void 0:a.status)==="failed"?"#ef4444":((o=l.value)==null?void 0:o.status)==="completed"?"#16a34a":"#2563eb"});function m(a){return Number(a||0).toLocaleString("fa-IR")}function K(){M&&(clearInterval(M),M=null)}async function z(a){var o,w;try{const u=await Ie(a);l.value=u,(u.status==="completed"||u.status==="failed")&&(K(),_.value=!1,t.value&&(t.value={...t.value,queued:!1,sent:u.sent,failed:u.failed,subscribed:u.total}),u.status==="completed"?(b.success(`ارسال تمام شد (${m(u.sent)} موفق، ${m(u.failed)} ناموفق)`),r("sent"),q()):b.error(u.error||"ارسال نوتیفیکیشن ناموفق بود"))}catch(u){K(),_.value=!1,b.error(((w=(o=u==null?void 0:u.response)==null?void 0:o.data)==null?void 0:w.error)||u.message||"خطا در دریافت وضعیت ارسال")}}function E(a){K(),z(a),M=setInterval(()=>{z(a)},1e3)}async function q(){N.value=!0;try{C.value=await xe()}finally{N.value=!1}}Te(()=>{q()}),De(()=>{K()});const Z=h({columns:Fe,api:he,defaultPageLimit:20,height:"45vh"}),G=P(()=>{var a,o;return!!((a=c.value.title)!=null&&a.trim()&&((o=c.value.body)!=null&&o.trim()))});function ee(){var a,o;return(a=c.value.title)!=null&&a.trim()?(o=c.value.body)!=null&&o.trim()?!0:(b.error("لطفاً متن نوتیفیکیشن را وارد کنید"),!1):(b.error("لطفاً عنوان نوتیفیکیشن را وارد کنید"),!1)}async function te(a){if(!ee())return;if(a==="selected"&&!v.value.length){b.warning("حداقل یک کاربر انتخاب کنید");return}if(A.value){b.warning("یک ارسال در حال انجام است. لطفاً صبر کنید.");return}const o=a==="selected"?`آیا از ارسال نوتیفیکیشن به ${v.value.length} کاربر انتخابشده مطمئن هستید؟`:"آیا از ارسال نوتیفیکیشن به همه کاربران مطمئن هستید؟";ne.confirm({title:"تأیید ارسال نوتیفیکیشن",content:o,okText:"بله، ارسال کن",cancelText:"انصراف",centered:!0,onOk:async()=>{var w,u,f;_.value=!0;try{const x={title:c.value.title.trim(),body:c.value.body.trim(),url:((w=c.value.url)==null?void 0:w.trim())||"/"},I=a==="selected"?await $e(x.title,x.body,v.value,x.url):await Se(x.title,x.body,x.url);if(t.value=I,I.queued&&I.jobId){l.value={jobId:I.jobId,status:"queued",kind:a==="selected"?"selected":"broadcast",title:x.title,total:I.subscribed??0,sent:0,failed:0,processed:0,percent:0,message:I.message||"در صف ارسال",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},b.success(I.message||"نوتیفیکیشن در صف ارسال قرار گرفت؛ در صورت قطع از همان نقطه ادامه مییابد"),E(I.jobId),a==="all"&&(c.value.body="");return}b.success(`نوتیفیکیشن ارسال شد (${I.sent} موفق، ${I.failed} ناموفق)`),r("sent"),q(),_.value=!1}catch(x){_.value=!1,b.error(((f=(u=x==null?void 0:x.response)==null?void 0:u.data)==null?void 0:f.error)||x.message||"خطا در ارسال نوتیفیکیشن")}}})}function me(){return te("all")}function _e(){return te("selected")}async function pe(){var w,u;const a={...B.value,includeUserIds:v.value},o=ae(a);if(o){b.warning(o);return}V.value=!0,F.value="";try{const f=await ke(le(a)),x=v.value.length>0?` (شامل ${m(v.value.length)} کاربر اضافه از جدول)`:"";F.value=`کاربران دسته: ${m(f.userCount)} — اشتراک push: ${m(f.pushSubscriptions)}${x}`}catch(f){b.error(((u=(w=f==null?void 0:f.response)==null?void 0:w.data)==null?void 0:u.error)||f.message||"خطا در پیشنمایش")}finally{V.value=!1}}async function fe(){if(!ee())return;const a={...B.value,includeUserIds:v.value},o=ae(a);if(o){b.warning(o);return}if(A.value){b.warning("یک ارسال در حال انجام است. لطفاً صبر کنید.");return}const w=B.value.segments.length,u=v.value.length,f=u>0?`ارسال به ${w} دسته (OR) بهعلاوه ${u} کاربر انتخابشده؟`:`ارسال به ${w} دسته مخاطب (اتحاد / OR)؟`;ne.confirm({title:"تأیید ارسال نوتیفیکیشن",content:f,okText:"بله، ارسال کن",cancelText:"انصراف",centered:!0,onOk:async()=>{var x,I,se;_.value=!0;try{const j={title:c.value.title.trim(),body:c.value.body.trim(),url:((x=c.value.url)==null?void 0:x.trim())||"/"},T=await we(j.title,j.body,le(a),j.url);if(t.value=T,T.queued&&T.jobId){l.value={jobId:T.jobId,status:"queued",kind:"segment",title:j.title,total:T.subscribed??0,sent:0,failed:0,processed:0,percent:0,message:T.message||"در صف ارسال",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},b.success(T.message||"نوتیفیکیشن در صف ارسال قرار گرفت؛ در صورت قطع از همان نقطه ادامه مییابد"),E(T.jobId);return}b.success(`نوتیفیکیشن ارسال شد (${T.sent} موفق، ${T.failed} ناموفق)`),r("sent"),q(),_.value=!1}catch(j){_.value=!1,b.error(((se=(I=j==null?void 0:j.response)==null?void 0:I.data)==null?void 0:se.error)||j.message||"خطا در ارسال نوتیفیکیشن")}}})}return(a,o)=>{const w=ye,u=re;return p(),y("div",Je,[e("div",ze,[e("div",Ee,[e("div",null,[He,i(L(Q),{value:c.value.title,"onUpdate:value":o[0]||(o[0]=f=>c.value.title=f),placeholder:"مثلاً: اطلاعیه مهم"},null,8,["value"])]),e("div",null,[Ge,i(L(k),{value:c.value.body,"onUpdate:value":o[1]||(o[1]=f=>c.value.body=f),placeholder:"متن دلخواه برای کاربران",rows:4,maxlength:500,"show-count":""},null,8,["value"])]),e("div",null,[Qe,i(L(Q),{value:c.value.url,"onUpdate:value":o[2]||(o[2]=f=>c.value.url=f),placeholder:"/shop یا /matches"},null,8,["value"])]),e("div",We,[i(w,{type:"primary",loading:_.value,disabled:!G.value||A.value,onClick:me},{default:d(()=>[g(" ارسال به همه کاربران ")]),_:1},8,["loading","disabled"]),i(w,{type:"primary",ghost:"",loading:_.value,disabled:!G.value||!v.value.length||A.value,onClick:_e},{default:d(()=>[g(" ارسال به انتخابشدهها ("+n(v.value.length)+") ",1)]),_:1},8,["loading","disabled"])]),i(ge,{modelValue:B.value,"onUpdate:modelValue":o[3]||(o[3]=f=>B.value=f),"include-user-count":v.value.length,"preview-loading":V.value,sending:_.value,disabled:!G.value||A.value,"preview-text":F.value,onPreview:pe,onSend:fe},null,8,["modelValue","include-user-count","preview-loading","sending","disabled","preview-text"]),l.value?(p(),y("div",Xe,[e("div",Ye,[Ze,e("span",{class:ue(["text-xs px-2 py-1 rounded-full",U.value])},n(S.value),3)]),i(L(Ce),{percent:l.value.percent,status:O.value,"stroke-color":R.value},null,8,["percent","status","stroke-color"]),e("div",et,[e("div",tt,[st,e("div",at,n(m(l.value.processed))+" / "+n(m(H.value)),1)]),e("div",lt,[ot,e("div",nt,n(m(l.value.sent)),1)]),e("div",rt,[it,e("div",ut,n(m(l.value.failed)),1)]),e("div",dt,[ct,e("div",vt,n(l.value.percent)+"٪",1)])]),l.value.message?(p(),y("p",mt,n(l.value.message),1)):$("",!0),l.value.error?(p(),y("p",_t,n(l.value.error),1)):$("",!0)])):$("",!0)]),e("div",pt,[ft,e("div",gt,[e("div",bt,[yt,e("strong",ht,n(C.value.uniqueUsers)+" نفر",1)]),e("div",xt,[kt,e("strong",null,n(C.value.totalSubscriptions),1)])]),wt,$t,St,It,t.value?(p(),y("div",Pt,[Rt,l.value&&A.value?(p(),y("div",Ct,"در حال ارسال…")):t.value.queued&&!l.value?(p(),y("div",Tt," در صف ارسال (دستهای) ")):$("",!0),l.value?(p(),y("div",Dt,[g(" موفق: "),e("strong",null,n(m(l.value.sent)),1)])):$("",!0),l.value?(p(),y("div",Bt,[g(" ناموفق: "),e("strong",null,n(m(l.value.failed)),1)])):t.value.queued?$("",!0):(p(),y("div",jt,[g(" موفق: "),e("strong",null,n(t.value.sent),1)])),!l.value&&!t.value.queued?(p(),y("div",Lt,[g(" ناموفق: "),e("strong",null,n(t.value.failed),1)])):$("",!0),t.value.targeted!=null?(p(),y("div",At,[g(" انتخابشده: "),e("strong",null,n(t.value.targeted),1)])):$("",!0),t.value.subscribed!=null?(p(),y("div",qt,[g(" دارای اشتراک push: "),e("strong",null,n(t.value.subscribed),1)])):$("",!0)])):$("",!0)])]),e("div",Ut,[Nt,i(u,de(Z.value,{"row-selection":J.value,onRegister:L(D)}),null,16,["row-selection","onRegister"])])])}}}),ce={custom:"همه کاربران",custom_selected:"کاربران انتخابشده",story:"قصه جدید",book:"کتاب صوتی",product:"محصول جدید",match:"مسابقه جدید"},ve={pending:"در صف",sending:"در حال ارسال",completed:"تمام شده",failed:"متوقف / شکست"},Ot={pending:"text-amber-700",sending:"text-blue-700",completed:"text-green-700",failed:"text-red-600"},Kt=[{title:"ردیف",dataIndex:"id",key:"row_index",filterable:!1,customRender:s=>s.index+1},{title:"شناسه",dataIndex:"id",key:"id",filterable:!1},{title:"عنوان",dataIndex:"title",key:"title",filterable:!1,customRender:s=>{const r=s.record.title||"";return r.length>40?`${r.slice(0,40)}...`:r}},{title:"نوع ارسال",dataIndex:"type",key:"type",filterable:!1,customRender:s=>ce[s.record.type]||s.record.type},{title:"وضعیت",dataIndex:"status",key:"status",filterable:!1,customRender:s=>{const r=s.record.status||"completed";return Be("span",{class:Ot[r]||"text-gray-700"},ve[r]||r)}},{title:"موفق",dataIndex:"sent_count",key:"sent_count",filterable:!1,customRender:s=>s.record.sent_count??0},{title:"ناموفق",dataIndex:"failed_count",key:"failed_count",filterable:!1,customRender:s=>s.record.failed_count??0},{title:"تاریخ",dataIndex:"created_at",key:"created_at",filterable:!1,customRender:s=>s.record.created_at?X(s.record.created_at):"-"},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"}];function Vt(s){return ce[s]||s}function Ft(s){return ve[s]||s}const Jt={class:"gap-2 flex justify-center"},zt=e("span",null,"جزئیات ارسال",-1),Et={class:"flex justify-end gap-2 w-full"},Ht={class:"whitespace-pre-wrap text-sm"},Gt={class:"text-red-600"},Qt={class:"grid grid-cols-1 sm:grid-cols-3 gap-3 mb-4"},Wt={class:"rounded-lg border border-green-200 bg-green-50 p-4 text-center"},Xt={class:"text-2xl font-bold text-green-600"},Yt=e("div",{class:"text-sm text-gray-600 mt-1"},"ارسال موفق",-1),Zt={class:"rounded-lg border border-red-200 bg-red-50 p-4 text-center"},es={class:"text-2xl font-bold text-red-600"},ts=e("div",{class:"text-sm text-gray-600 mt-1"},"ارسال ناموفق",-1),ss={class:"rounded-lg border border-gray-200 bg-gray-50 p-4 text-center"},as={class:"text-2xl font-bold text-gray-700"},ls=e("div",{class:"text-sm text-gray-600 mt-1"},"مجموع تلاشها",-1),os={key:0,class:"mb-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800"},ns={key:1,class:"text-sm text-gray-600"},rs={class:"text-green-600"},is={class:"text-green-600"},us={class:"text-red-600"},ds={key:2,class:"text-sm text-gray-500"},cs=Y({__name:"PushHistoryPanel",setup(s,{expose:r}){const[k,D]=ie(),c=h(!1),_=h(!1),v=h(!1),t=h(null),l=h({columns:Kt,api:Pe,defaultPageLimit:20,height:"55vh"}),C=P(()=>t.value?(t.value.sent_count||0)+(t.value.failed_count||0):0),N=P(()=>!C.value||!t.value?0:Math.round(t.value.sent_count/C.value*100)),B=P(()=>!t.value||t.value.status==="completed"?!1:t.value.can_resume!==!1),V=P(()=>{var S;switch((S=t.value)==null?void 0:S.status){case"failed":return"text-red-600 font-medium";case"sending":return"text-blue-700 font-medium";case"pending":return"text-amber-700 font-medium";case"completed":return"text-green-700 font-medium";default:return"text-gray-700"}});function F(S){return S?X(S):"-"}async function M(S){c.value=!0,_.value=!0,t.value=null;try{t.value=await oe(S.id)}finally{_.value=!1}}function J(){c.value=!1,t.value=null}async function A(){var S,U,O;if(!(!((S=t.value)!=null&&S.id)||!B.value)){v.value=!0;try{const R=await Re(t.value.id);b.success(R.message||"ارسال از همان نقطه ادامه یافت"),t.value=await oe(t.value.id),D()}catch(R){b.error(((O=(U=R==null?void 0:R.response)==null?void 0:U.data)==null?void 0:O.error)||R.message||"خطا در ادامه ارسال")}finally{v.value=!1}}}function H(){D()}return r({reload:H}),(S,U)=>{const O=re,R=qe,m=Ue,K=Ne,z=Me,E=Le;return p(),y("div",null,[i(O,de(l.value,{onRegister:L(k)}),{action:d(({record:q})=>[e("div",Jt,[i(L(Oe),{class:"cursor-pointer"},{title:d(()=>[zt]),default:d(()=>[i(Ae,{icon:"vuesax-linear:eye",color:"#1D4ED8",onClick:Z=>M(q)},null,8,["onClick"])]),_:2},1024)])]),_:1},16,["onRegister"]),i(E,{visible:c.value,"onUpdate:visible":U[0]||(U[0]=q=>c.value=q),title:"جزئیات نوتیفیکیشن ارسالی","custom-footer":"",width:"720px",onClose:J},{footer:d(()=>[e("div",Et,[B.value?(p(),W(R,{key:0,type:"primary",loading:v.value,onClick:A},{default:d(()=>[g(" ادامه ارسال از همین نقطه ")]),_:1},8,["loading"])):$("",!0),i(R,{onClick:J},{default:d(()=>[g("بستن")]),_:1})])]),default:d(()=>[i(z,{spinning:_.value},{default:d(()=>[t.value?(p(),y(je,{key:0},[i(K,{bordered:"",column:2,size:"small",class:"mb-4"},{default:d(()=>[i(m,{label:"شناسه"},{default:d(()=>[g("#"+n(t.value.id),1)]),_:1}),i(m,{label:"نوع ارسال"},{default:d(()=>[g(n(L(Vt)(t.value.type)),1)]),_:1}),i(m,{label:"وضعیت"},{default:d(()=>[e("span",{class:ue(V.value)},n(L(Ft)(t.value.status||"completed")),3)]),_:1}),i(m,{label:"تاریخ ارسال"},{default:d(()=>[g(n(F(t.value.created_at)),1)]),_:1}),i(m,{label:"ارسالکننده"},{default:d(()=>[g(n(t.value.admin_name||"-"),1)]),_:1}),i(m,{label:"کل هدف"},{default:d(()=>[g(n(t.value.total_subscriptions??"-"),1)]),_:1}),i(m,{label:"عنوان",span:2},{default:d(()=>[g(n(t.value.title),1)]),_:1}),i(m,{label:"متن",span:2},{default:d(()=>[e("div",Ht,n(t.value.body),1)]),_:1}),i(m,{label:"لینک",span:2},{default:d(()=>[g(n(t.value.url||"/"),1)]),_:1}),t.value.error_message?(p(),W(m,{key:0,label:"آخرین خطا",span:2},{default:d(()=>[e("span",Gt,n(t.value.error_message),1)]),_:1})):$("",!0)]),_:1}),e("div",Qt,[e("div",Wt,[e("div",Xt,n(t.value.sent_count),1),Yt]),e("div",Zt,[e("div",es,n(t.value.failed_count),1),ts]),e("div",ss,[e("div",as,n(C.value),1),ls])]),B.value?(p(),y("div",os," این کمپین کامل نشده است. با زدن دکمه «ادامه ارسال» از همان نقطه قبلی ادامه مییابد و از اول شروع نمیشود. ")):$("",!0),C.value>0?(p(),y("div",ns,[g(" نرخ موفقیت: "),e("strong",rs,n(N.value)+"%",1),g(" — "),e("span",is,n(t.value.sent_count)+" موفق",1),g(" / "),e("span",us,n(t.value.failed_count)+" ناموفق",1)])):(p(),y("div",ds," هنوز ارسالی برای این کمپین ثبت نشده است. "))],64)):$("",!0)]),_:1},8,["spinning"])]),_:1},8,["visible"])])}}}),vs=e("div",{class:"flex justify-between items-center mb-4"},[e("h2",null,"نوتیفیکیشن Push")],-1),ia=Y({__name:"index",setup(s){const r=h("send"),k=h(null);function D(){var _;(_=k.value)==null||_.reload()}function c(_){var v;_==="history"&&((v=k.value)==null||v.reload())}return(_,v)=>{const t=Ke,l=Ve,C=be;return p(),W(C,null,{default:d(()=>[vs,i(l,{activeKey:r.value,"onUpdate:activeKey":v[0]||(v[0]=N=>r.value=N),onChange:c},{default:d(()=>[i(t,{key:"send",tab:"ارسال نوتیفیکیشن"},{default:d(()=>[i(Mt,{onSent:D})]),_:1}),i(t,{key:"history",tab:"سوابق ارسالی"},{default:d(()=>[i(cs,{ref_key:"historyPanelRef",ref:k},null,512)]),_:1})]),_:1},8,["activeKey"])]),_:1})}}});export{ia as default};
|