Files
gustavoo-me/wp-content/plugins/fluent-crm/assets/admin/Modules/Email/AllEmails.js
T
2026-07-23 22:56:30 -03:00

2 lines
12 KiB
JavaScript

import{aI as e,aB as t,aC as a,aH as i,c as l,aJ as s,k as n,ay as r,aK as o,aL as c,e as d,E as m,n as h}from"../../../vendor-element-plus.js?ver=3.1.8";import{W as p,Y as u,a5 as _,ab as f,Z as g,aQ as v,X as b,a9 as y,aa as w,a8 as x,ay as $,a6 as C,J as E,az as S,b2 as k}from"../../../vendor.js?ver=3.1.8";import{P as T}from"../../../PaginationBar.js?ver=3.1.8";import F from"./Campaigns/_components/EmailPreview.js?ver=3.1.8";import{T as A}from"../../../TopNav.js?ver=3.1.8";import{_ as j,I as B,a as P,T as D}from"../../../fc-bits-ui.js?ver=3.1.8";import{P as V}from"../../../PageHeader.js?ver=3.1.8";import{D as z}from"../../../DataTable.js?ver=3.1.8";import{F as I}from"../../../FloatingBulkActionShell.js?ver=3.1.8";import L from"../../../v3app/src/Modules/Contacts/Filter/FilterPopover.js?ver=3.1.8";import R from"../../../v3app/src/Modules/Contacts/Filter/ActiveFiltersBar.js?ver=3.1.8";import{B as H}from"../../../Badge.js?ver=3.1.8";import"../../../PreviewIframeBuilder.js?ver=3.1.8";const K={class:"fcrm_contact_cell"},M={class:"fcrm_contact_info"},N={class:"fcrm_contact_name fcrm_mb_4"},U={class:"fcrm_contact_email"},J={style:{display:"flex","align-items":"center",gap:"6px"}};const Y={class:"fcrm_all_email_activities_page"},Q={class:"fcrm_page_header_top_nav_wrapper"},W={class:"fcrm_page_header_top_nav"},X={class:"fcrm-layout-width"},Z={key:0},q={class:"icon"},G={class:"fcrm_empty_state"},O={class:"fcrm_empty_state_text"},ee=["title","src","alt"],te={class:"fcrm_contact_info"},ae={class:"fcrm_contact_name"},ie={class:"fcrm_contact_email"},le={key:1},se={key:0},ne={key:1},re=["title"],oe={key:0,class:"fcrm_table_body_actions justify-center"},ce={class:"icon"},de={class:"icon"},me={class:"fcrm_bulk_action_bar"},he={class:"fcrm_bulk_action_left"},pe={class:"fc_bulk_selection_count"},ue={class:"icon"};const _e=j({name:"AllEmails",components:{Badge:H,ActiveFiltersBar:R,AllEmailsLoader:j({name:"AllEmailsLoader"},[["render",function(l,s,n,r,o,c){const d=a,m=t,h=e,v=i;return p(),u(v,{style:{width:"100%"},data:[1,2,3,4,5,6,7,8]},{default:_(()=>[f(h,{type:"selection",width:"55",fixed:""},{default:_(()=>[f(m,{animated:""},{template:_(()=>[f(d,{variant:"button",style:{width:"20px",height:"20px","border-radius":"6px"}})]),_:1})],void 0,!0),_:1}),f(h,{label:l.$t("Contact"),width:"240"},{default:_(()=>[g("div",K,[f(m,{animated:"",style:{width:"36px",flex:"none"}},{template:_(()=>[f(d,{variant:"circle",style:{width:"36px",height:"36px","border-radius":"50%"}})]),_:1}),g("div",M,[g("div",N,[f(m,{animated:""},{template:_(()=>[f(d,{variant:"text",style:{width:"100px",height:"17px","border-radius":"6px"}})]),_:1})]),g("div",U,[f(m,{animated:""},{template:_(()=>[f(d,{variant:"text",style:{width:"60px",height:"17px","border-radius":"6px"}})]),_:1})])])])],void 0,!0),_:1},8,["label"]),f(h,{label:l.$t("Subject")},{default:_(()=>[f(m,{animated:""},{template:_(()=>[f(d,{variant:"text",style:{width:"100px",height:"17px","border-radius":"6px"}})]),_:1})],void 0,!0),_:1},8,["label"]),f(h,{label:l.$t("Source")},{default:_(()=>[f(m,{animated:""},{template:_(()=>[f(d,{variant:"text",style:{width:"100px",height:"17px","border-radius":"6px"}})]),_:1})],void 0,!0),_:1},8,["label"]),f(h,{width:"180",label:l.$t("Type")},{default:_(()=>[f(m,{animated:""},{template:_(()=>[f(d,{variant:"text",style:{width:"120px",height:"17px","border-radius":"6px"}})]),_:1})],void 0,!0),_:1},8,["label"]),f(h,{width:"120",label:l.$t("Status")},{default:_(()=>[f(m,{animated:""},{template:_(()=>[f(d,{variant:"text",style:{width:"80px",height:"17px","border-radius":"6px"}})]),_:1})],void 0,!0),_:1},8,["label"]),f(h,{width:"180",label:l.$t("Sending Time")},{default:_(()=>[f(m,{animated:""},{template:_(()=>[f(d,{variant:"text",style:{width:"130px",height:"17px","border-radius":"6px"}})]),_:1})],void 0,!0),_:1},8,["label"]),f(h,{label:l.$t("Preview"),fixed:"right",width:"150",align:"center"},{default:_(()=>[f(m,{animated:""},{template:_(()=>[g("div",J,[f(d,{variant:"text",style:{width:"60px",height:"24px","border-radius":"6px"}}),f(d,{variant:"text",style:{width:"60px",height:"24px","border-radius":"6px"}})])]),_:1})],void 0,!0),_:1},8,["label"])],void 0),_:1})}]]),FilterPopover:L,Icons:B,PageHeader:V,TopNav:A,PaginationBar:T,EmailPreview:F,DataTable:z,FloatingBulkActionShell:I,Close:l},data:()=>({emails:[],pagination:{total:0,per_page:10,current_page:1},loading:!0,preview:{id:null,isVisible:!1},resending:!1,selections:[],deleting:!1,statuses:null,selectStatus:"",search:"",types:[],selectedFilters:{types:[]},current_mode:"system"===D.getCurrentTheme()?D.getSystemTheme():D.getCurrentTheme()}),methods:{fetchEmails(){this.loading=!0,this.storage.set("all_emails_perpage",this.pagination.per_page);const e={per_page:this.pagination.per_page,page:this.pagination.current_page,status:this.selectStatus,search:this.search,types:this.selectedFilters.types};this.$get("reports/emails",e).then(e=>{this.emails=e.emails.data,e.statuses&&(this.statuses=e.statuses),e.types&&(this.types=e.types),this.pagination.total=e.emails.total}).catch(e=>{this.handleError(e)}).finally(()=>{this.loading=!1})},handleStatusChange(){this.pagination.current_page=1,this.fetchEmails()},handleSearch(){this.pagination.current_page=1,this.fetchEmails()},handleFilterApply(e){this.selectedFilters.types=e.types||[],this.pagination.current_page=1,this.fetchEmails()},handleFilterBarChange(e){this.selectedFilters.types=e.types||[],this.pagination.current_page=1,this.fetchEmails()},confirmResendEmail(e){h.confirm(this.$t("Are you sure you want to resend this email? The contact will receive the email again."),this.$t("Resend Email"),{confirmButtonText:this.$t("Resend"),cancelButtonText:this.$t("Cancel"),type:"warning"}).then(()=>{this.resendEmail(e)}).catch(()=>{})},resendEmail(e){if(!this.has_campaign_pro)return this.$notify.error(this.$t("_Ca_Please_utptutf")),!1;this.resending=!0,this.$post(`campaigns-pro/${e.campaign_id}/resend-emails`,{email_ids:[e.id]}).then(e=>{this.$notify.success(e.message),this.fetchEmails()}).catch(e=>{this.handleError(e)}).finally(()=>{this.resending=!1})},previewEmail(e){this.preview.id=e,this.preview.isVisible=!0},confirmAndDeleteSelected(){h.confirm(this.$t("Are you sure you want to delete the selected emails?"),this.$t("Delete Emails"),{confirmButtonText:this.$t("Delete"),cancelButtonText:this.$t("Cancel"),type:"warning"}).then(()=>{this.deleteSelected()}).catch(()=>{})},deleteSelected(){this.deleting=!0;const e=this.selections.map(e=>e.id);this.$del("reports/emails",{email_ids:e}).then(e=>{this.selections=[],this.$notify.success(e.message),this.fetchEmails()}).catch(e=>{this.handleError(e)}).finally(()=>{this.deleting=!1})},handleSelectionChange(e){this.selections=e},clearEmailSelection(){this.$refs.emailsTable&&this.$refs.emailsTable.clearSelection(),this.selections=[]},onThemeChanged(e){var t;this.current_mode=(null==(t=e.detail)?void 0:t.effective)||("system"===D.getCurrentTheme()?D.getSystemTheme():D.getCurrentTheme())}},mounted(){window.addEventListener(P,this.onThemeChanged),this.pagination.per_page=parseInt(this.storage.get("all_emails_perpage",10),10)||10,this.fetchEmails(),this.changeTitle(this.$t("All Emails"))},beforeUnmount(){window.removeEventListener(P,this.onThemeChanged)}},[["render",function(t,a,l,h,T,F){const A=v("TopNav"),j=v("page-header"),B=v("Icons"),P=d,D=c,V=o,z=v("filter-popover"),I=v("active-filters-bar"),L=v("AllEmailsLoader"),R=v("icons"),H=e,K=v("router-link"),M=v("Badge"),N=n,U=s,J=i,_e=v("pagination-bar"),fe=v("data-table"),ge=v("Close"),ve=m,be=v("floating-bulk-action-shell"),ye=v("email-preview"),we=r;return p(),b("div",Y,[g("div",Q,[g("div",W,[f(A)])]),g("div",X,[f(j,null,{title:_(()=>[y(w(t.$t("All Email Activities"))+" ",1),T.pagination.total?(p(),b("small",Z,"("+w(t.formatMoney(T.pagination.total))+")",1)):x("",!0)]),_:1}),f(fe,{"has-selection":!1},$({"header-left":_(()=>[f(P,{clearable:"",size:"small",modelValue:T.search,"onUpdate:modelValue":a[0]||(a[0]=e=>T.search=e),onClear:F.handleSearch,onKeyup:k(F.handleSearch,["enter"]),placeholder:t.$t("Search by subject, source or email...")},{prefix:_(()=>[g("span",q,[f(B,{"icon-name":"search"})])]),_:1},8,["modelValue","onClear","onKeyup","placeholder"])]),"header-actions":_(()=>[T.statuses?(p(),u(V,{key:0,placeholder:t.$t("All"),onChange:F.handleStatusChange,modelValue:T.selectStatus,"onUpdate:modelValue":a[1]||(a[1]=e=>T.selectStatus=e),style:{"min-width":"80px"},size:"small"},{default:_(()=>[f(D,{value:"",label:t.$t("All")},null,8,["label"]),(p(!0),b(E,null,S(T.statuses,(e,a)=>(p(),u(D,{key:a,label:t.ucFirst(a)+" ("+e+")",value:a},null,8,["label","value"]))),128))],void 0,!0),_:1},8,["placeholder","onChange","modelValue"])):x("",!0),f(z,{options:{types:T.types},"selected-filters":T.selectedFilters,onApply:F.handleFilterApply},null,8,["options","selected-filters","onApply"])]),"active-filters":_(()=>[f(I,{"selected-filters":T.selectedFilters,options:{types:T.types},onFilterChange:F.handleFilterBarChange,plus_filter_icon:!0},null,8,["selected-filters","options","onFilterChange"])]),table:_(()=>[T.loading?(p(),u(L,{key:0})):C((p(),u(J,{key:1,ref:"emailsTable",border:"",stripe:"",data:T.emails,style:{width:"100%"},onSelectionChange:F.handleSelectionChange},{empty:_(()=>[g("div",G,[f(R,{"icon-name":"common-empty-state"}),g("div",O,[g("span",null,w(t.$t("You haven't sent or scheduled any email logs. Start a campaign to see activities here.")),1)])])]),default:_(()=>[f(H,{type:"selection",width:"55",fixed:""}),f(H,{label:t.$t("Contact"),width:"240"},{default:_(e=>[e.row.subscriber?(p(),u(K,{key:0,class:"fcrm_contact_cell",to:{name:"subscriber",params:{id:e.row.subscriber_id}}},{default:_(()=>[g("img",{title:t.$t("Contact ID: %s",e.row.subscriber_id),class:"fcrm_contact_photo",src:e.row.subscriber.photo,alt:e.row.subscriber.full_name},null,8,ee),g("div",te,[g("div",ae,w(e.row.subscriber.full_name),1),g("div",ie,w(e.row.subscriber.email),1)])],void 0,!0),_:2},1032,["to"])):(p(),b("span",le,w(e.row.mobile_number),1))]),_:1},8,["label"]),f(H,{label:t.$t("Subject")},{default:_(e=>[g("span",null,w(e.row.email_subject),1)]),_:1},8,["label"]),f(H,{label:t.$t("Source")},{default:_(e=>[e.row.campaign?(p(),b("span",se,w(e.row.campaign.title),1)):(p(),b("span",ne,w(t.$t("n/a")),1))]),_:1},8,["label"]),f(H,{width:"180",label:t.$t("Type")},{default:_(e=>[g("span",null,w(e.row.email_type_label),1)]),_:1},8,["label"]),f(H,{width:"120",label:t.$t("Status")},{default:_(e=>[f(M,{type:e.row.status},null,8,["type"])]),_:1},8,["label"]),f(H,{width:"180",label:t.$t("Sending Time")},{default:_(e=>[g("span",{title:e.row.scheduled_at},w(t.nsHumanDiffTime(e.row.scheduled_at)),9,re)]),_:1},8,["label"]),f(H,{label:t.$t("Preview"),fixed:"right",width:"150",align:"center"},{default:_(e=>[e.row.subscriber?(p(),b("div",oe,[f(U,{class:"box-item",effect:"dark",content:t.$t("Preview Email"),placement:"top"},{default:_(()=>[f(N,{size:"small",class:"only-icon-btn small",onClick:t=>F.previewEmail(e.row.id),"aria-label":t.$t("Preview Email")},{default:_(()=>[g("span",ce,[f(B,{"icon-name":"eye"})])],void 0,!0),_:1},8,["onClick","aria-label"])],void 0,!0),_:2},1032,["content"]),f(U,{class:"box-item",effect:"dark",content:t.$t("Resend Email"),placement:"top"},{default:_(()=>["sent"!=e.row.status&&"failed"!=e.row.status||!e.row.campaign_id?x("",!0):(p(),u(N,{key:0,size:"small",onClick:t=>F.confirmResendEmail(e.row),class:"only-icon-btn small","aria-label":t.$t("Resend Email")},{default:_(()=>[g("span",de,[f(B,{"icon-name":"resend-email"})])],void 0,!0),_:1},8,["onClick","aria-label"]))],void 0,!0),_:2},1032,["content"])])):x("",!0)]),_:1},8,["label"])],void 0,!0),_:1},8,["data","onSelectionChange"])),[[we,T.resending]])]),_:2},[T.loading||T.resending?void 0:{name:"pagination",fn:_(()=>[f(_e,{pagination:T.pagination,onFetch:F.fetchEmails,extra_sizes:[200,250,300,400,600]},null,8,["pagination","onFetch"])]),key:"0"}]),1024),f(be,{visible:!!T.selections.length,"theme-mode":T.current_mode,"custom-layout":!0},{default:_(()=>[g("div",me,[g("div",he,[f(N,{link:"","aria-label":t.$t("Deselect"),onClick:F.clearEmailSelection},{default:_(()=>[f(ve,null,{default:_(()=>[f(ge)],void 0,!0),_:1})],void 0,!0),_:1},8,["aria-label","onClick"]),g("span",pe,[g("strong",null,w(T.selections.length),1),y(" "+w(t.$t("selected")),1)]),a[2]||(a[2]=g("div",{class:"fcrm_bulk_divider"},null,-1)),C((p(),u(N,{disabled:T.deleting,type:"danger",size:"small",plain:"",onClick:F.confirmAndDeleteSelected},{default:_(()=>[g("span",ue,[f(B,{"icon-name":"delete"})]),y(" "+w(t.$t("Delete")),1)],void 0,!0),_:1},8,["disabled","onClick"])),[[we,T.deleting]])])])],void 0),_:1},8,["visible","theme-mode"])]),f(ye,{preview:T.preview},null,8,["preview"])])}]]);export{_e as default};