"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/MassMailPage"],{2106:(e,t,s)=>{s.r(t),s.d(t,{default:()=>T});var n=s(271),a=s(89),o=s(270),l=s(495),i=s(616),r=s(699),c=s(835),d=s.n(c),m=s(633),p=s(1051),u=s(530);const g=l.gql`
    mutation DeleteMassEmailTemplateMutation($input: DeleteMassEmailTemplateInput!) {
        deleteMassEmailTemplate(input: $input) {
            ids
        }
    }
`,h=a.Locale.getTranslate("components.pages.MassMailPage"),x=a.Locale.getSection("components.pages.MassMailPage"),j=[{key:"name",sortable:!0,title:(0,o.jsx)(h,{content:"name"}),render:({name:e,templateId:t})=>(0,o.jsx)(m.default,{to:`${t}/edit`,children:e})},{key:"fromEmail",sortable:!0,title:(0,o.jsx)(h,{content:"sender"})},{key:"sendToResellersMode",title:(0,o.jsx)(h,{content:"recipients"}),width:"350px",render:({sendToAdmins:e,sendToResellers:t,sendToResellersMode:s,sendToClients:n,sendToClientsMode:a})=>{if(!e&&!t&&!n)return(0,o.jsx)(h,{content:"recipientsNone"});const l=[];return e&&l.push(x.lmsg("recipientsAdmins")),t&&("all"===s?l.push(x.lmsg("recipientsResellers")):l.push(x.lmsg("select"===s?"recipientsResellersSelected":"recipientsResellersExcept"))),n&&("all"===a?l.push(x.lmsg("recipientsClients")):l.push(x.lmsg("select"===a?"recipientsClientsSelected":"recipientsClientsExcept"))),l.join(", ")}},{title:(0,o.jsx)(h,{content:"subject"}),key:"subject",sortable:!0},{title:(0,o.jsx)(h,{content:"created"}),key:"created",sortable:!0,render:({created:e})=>(0,p.formatDateFromTimestamp)(e)},{title:(0,o.jsx)(h,{content:"send"}),key:"send",render:({templateId:e})=>(0,o.jsx)(n.Button,{component:m.default,to:`send?templateId=${e}`,ghost:!0,icon:"mail"})}],T=()=>{const[e,t]=(0,o.useState)([]),{queryResult:{refetch:s},listProps:a,listInput:l}=(0,r.useGraphQlList)({key:"MassMailPage",onListInputChange:()=>t([]),query:d(),extractList:e=>e.massEmail.templates}),c=!!l.searchFilters?.query,[p,{loading:T}]=(0,i.useMutation)(g,{onCompleted:()=>{(0,u.addToast)({intent:"success",message:x.formatMessage("templatesRemoved",{count:e.length})}),t([]),s()}});return(0,o.jsx)(r.GraphQlList,{selection:e,rowKey:"templateId",filtered:c,onSelectionChange:e=>t(e),emptyView:(0,o.jsx)(n.ListEmptyView,{title:(0,o.jsx)(h,{content:"emptyViewTitle"}),actions:c?void 0:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.Button,{"data-testid":"new-mass-mail-template",component:m.default,to:"create",intent:"primary",children:(0,o.jsx)(h,{content:"addNew"})}),(0,o.jsx)(n.Button,{"data-testid":"send-mass-mail",component:m.default,to:"send",intent:"secondary",children:(0,o.jsx)(h,{content:"sendEmail"})})]})}),toolbar:(0,o.jsxs)(n.Toolbar,{children:[(0,o.jsx)(n.ToolbarGroup,{title:x.lmsg("addNew"),children:(0,o.jsx)(n.Button,{"data-testid":"new-mass-mail-template",component:m.default,to:"create",icon:"plus",intent:"primary"})}),(0,o.jsx)(n.ToolbarGroup,{title:x.lmsg("addNew"),children:(0,o.jsx)(n.Button,{"data-testid":"send-mass-mail",component:m.default,to:"send",intent:"primary",children:(0,o.jsx)(h,{content:"sendEmail"})})}),(0,o.jsx)(n.ToolbarGroup,{title:x.lmsg("actions"),children:(0,o.jsx)(n.ListOperation,{critical:!0,noSelectionText:(0,o.jsx)(h,{content:"selectAtLeastOneTemplate"}),confirmationText:x.formatMessage("confirmRemoval",{count:e.length}),actionButtonText:(0,o.jsx)(h,{content:"remove"}),children:(0,o.jsx)(n.Button,{onClick:async()=>{await p({variables:{input:{ids:e.map((e=>btoa(`MassEmailTemplate:${e}`)))}}})},state:T?"loading":void 0,children:(0,o.jsx)(h,{content:"remove"})})})}),(0,o.jsx)(n.ToolbarExpander,{}),(0,o.jsx)(n.ToolbarGroup,{title:(0,o.jsx)(h,{content:"filters"}),groupable:!1,children:(0,o.jsx)(r.GraphQlList.SearchBar,{name:"query"})})]}),columns:j,...a})}},1051:(e,t,s)=>{s.r(t),s.d(t,{HOURS_IN_MS:()=>n,addDays:()=>l,addHours:()=>i,formatDate:()=>d,formatDateFromTimestamp:()=>m,getSysdate:()=>o,getTimezoneShift:()=>c,isSameDay:()=>r,toDatePeriod:()=>p});const n=36e5,a=3600,o=()=>new Date,l=(e,t=new Date)=>{const s=new Date(t.getTime());return s.setDate(s.getDate()+e),s},i=(e,t=new Date)=>{const s=new Date(t.getTime());return s.setHours(s.getHours()+e),s},r=(e,t)=>{const s=e.getYear()===t.getYear(),n=e.getMonth()===t.getMonth(),a=e.getDate()===t.getDate();return s&&n&&a},c=e=>{const[t,s]=e.split(":");return+t<0?-(Math.abs(t)+s/60):+t+s/60},d=e=>new Date(e).toLocaleDateString(document.documentElement.lang??"en",{month:"long",day:"numeric",year:"numeric"}),m=e=>d(1e3*e),p=e=>{const t=Math.floor(e/86400),s=86400*t,n=Math.floor((e-s)/a),o=n*a,l=Math.floor((e-s-o)/60);return{days:t,hours:n,minutes:l,seconds:e-s-o-60*l}}}}]);
//# sourceMappingURL=MassMailPage.js.map?ea72f6a67df63d9b00d0