D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
cp
/
public
/
javascript
/
components
/
pages
/
Filename :
SendMassMailPage.js
back
Copy
(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/SendMassMailPage"],{2555:(e,n,i)=>{"use strict";i.r(n),i.d(n,{default:()=>v});var s=i(286),a=i(1289),l=i(89),t=i(596),d=i.n(t),o=i(285),r=i(611),m=i.n(r),c=i(646),u=i(2556);const p=l.Locale.getSection("components.forms.MassMailForm"),f=({customers:e,resellers:n,loading:i,mutation:l,onSuccess:t,values:d,onChange:r,children:f=null,footer:v=null,errors:k={},submitButtonProps:T={},hideNameField:b=!1,onSubmit:g=e=>e,applyButton:h=!1})=>{const S=(0,o.useMemo)((()=>n.map((({id:e,name:n,email:i})=>{const s=atob(e).split(":")[1];return{id:s,title:`${n} (${i})`,selected:d.resellers?.includes(s)}}))),[n,d.resellers]),N=(0,o.useMemo)((()=>e.map((({id:e,name:n,email:i})=>{const s=atob(e).split(":")[1];return{id:s,title:`${n} (${i})`,selected:d.clients?.includes(s)}}))),[e,d.clients]);return(0,o.jsxs)(a.default,{state:i?"submit":null,values:d,onFieldChange:r,mutation:l,onSuccess:t,onSubmit:e=>g({...e,sendToResellersMode:e.sendToResellers?e.sendToResellersMode:"all",sendToClientsMode:e.sendToClients?e.sendToClientsMode:"all",resellers:(e.resellers??[]).map(Number),clients:(e.clients??[]).map(Number)}),errors:k,submitButton:{"data-testid":"btn-submit",...T},applyButton:h,cancelButton:{"data-testid":"btn-cancel",component:c.default,to:"/cp/server/mass-mail"},children:[f,!b&&(0,o.jsx)(s.FormFieldText,{required:!0,size:"xl",label:p.lmsg("name"),name:"name"}),(0,o.jsx)(s.FormFieldText,{required:!0,size:"xl",label:p.lmsg("fromEmail"),name:"fromEmail"}),(0,o.jsx)(s.FormFieldCheckbox,{label:p.lmsg("sendToAdmins"),name:"sendToAdmins"}),(0,o.jsx)(s.FormFieldCheckbox,{label:p.lmsg("sendToResellers"),name:"sendToResellers"}),(0,o.jsxs)("div",{className:m()({"mass-mail-form-block-hidden":!d.sendToResellers}),children:[(0,o.jsxs)(s.FormFieldSelect,{size:"lg",name:"sendToResellersMode",label:p.lmsg("sendToResellersMode"),children:[(0,o.jsx)("option",{value:"all",children:p.lmsg("sendToResellersModeAll")}),(0,o.jsx)("option",{value:"select",children:p.lmsg("sendToResellersModeSelect")}),(0,o.jsx)("option",{value:"except",children:p.lmsg("sendToResellersModeExcept")})]}),(0,o.jsx)(s.FormField,{className:m()({"mass-mail-form-block-hidden":"all"===d.sendToResellersMode}),name:"resellers",children:({setValue:e})=>(0,o.jsx)(u.default,{name:"select-reseller",onChange:e,options:S})})]}),(0,o.jsx)(s.FormFieldCheckbox,{label:p.lmsg("sendToClients"),name:"sendToClients"}),(0,o.jsxs)("div",{className:m()({"mass-mail-form-block-hidden":!d.sendToClients}),children:[(0,o.jsxs)(s.FormFieldSelect,{size:"lg",name:"sendToClientsMode",label:p.lmsg("sendToClientsMode"),children:[(0,o.jsx)("option",{value:"all",children:p.lmsg("sendToClientsModeAll")}),(0,o.jsx)("option",{value:"select",children:p.lmsg("sendToClientsModeSelect")}),(0,o.jsx)("option",{value:"except",children:p.lmsg("sendToClientsModeExcept")})]}),(0,o.jsx)(s.FormField,{className:m()({"mass-mail-form-block-hidden":"all"===d.sendToClientsMode}),name:"clients",children:({setValue:e})=>(0,o.jsx)(u.default,{name:"select-client",onChange:e,options:N})})]}),(0,o.jsx)(s.FormFieldText,{required:!0,size:"xl",label:p.lmsg("subject"),name:"subject"}),(0,o.jsx)(s.FormFieldText,{description:p.lmsg("bodyDescription"),required:!0,size:"fill",rows:10,multiline:!0,label:p.lmsg("body"),name:"body"}),v]})};f.propTypes={customers:d().array.isRequired,resellers:d().array.isRequired,loading:d().bool.isRequired,mutation:d().func.isRequired,onSuccess:d().func.isRequired,onSubmit:d().func,values:d().object.isRequired,submitButtonProps:d().object,onChange:d().func.isRequired,children:d().node,footer:d().node,errors:d().object,hideNameField:d().bool,applyButton:d().oneOf([d().object,d().bool])};const v=f},2554:(e,n,i)=>{"use strict";i.r(n),i.d(n,{default:()=>s.default});var s=i(2555)},2556:(e,n,i)=>{"use strict";i.r(n),i.d(n,{default:()=>m});var s=i(285),a=i(89),l=i(641),t=i(596),d=i.n(t);const o=a.Locale.getSection("components.elements.double-list-selector"),r=({name:e,options:n,onChange:i=()=>{},...t})=>{const[d,r]=(0,s.useState)(null),m=(0,s.useRef)(n);return(0,s.useEffect)((()=>{const s=new a.EnhancedDoubleListSelector({list:n,applyTo:e,isSearchable:!0,locale:o,name:e,onChange:e=>{const n=Object.keys(e).reduce(((n,i)=>e[i]?[...n,i]:n),[]);i(n)},...t});return r(s),()=>{s.remove(),r(null)}}),[]),(0,s.useEffect)((()=>{d&&m.current!==n&&n.forEach(((e,n)=>{m.current[n].selected!==e.selected&&(d._toggleItemSelection(n,!e.selected),m.current[n].selected=e.selected)}))}),[d,n]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{id:e}),d&&(0,s.jsx)(l.default,{children:d})]})};r.propTypes={name:d().string.isRequired,options:d().arrayOf(d().shape({selected:d().bool,id:d().any,title:d().string,description:d().string,icons:d().arrayOf(d().shape({src:d().string,title:d().string}))})).isRequired,isSearchable:d().bool,onChange:d().func};const m=r},2557:(e,n,i)=>{"use strict";i.r(n),i.d(n,{default:()=>M});var s=i(1120),a=i(586),l=i(628),t=i(286),d=i(536),o=i(89),r=i(285),m=i(579),c=i(580),u=i(415),p=i(2552),f=i(1280),v=i.n(f),k=i(2558),T=i.n(k),b=i(2553),g=i.n(b),h=i(2554);const S=s.gql` mutation SendMassEmail($input: SendMassEmailInput!) { sendMassEmail(input: $input) { errors { email error } } } `,N=o.Locale.getSection("components.pages.SendMassMailPage"),M=()=>{const{data:{viewer:{customers:e,resellers:n},massEmail:{templates:{nodes:i}}}}=(0,a.useQuery)(v()),[s]=(0,m.useSearchParams)(),[o,f]=(0,r.useState)((()=>({sendToClientsMode:"all",sendToResellersMode:"all",sendToAdmins:!1,sendToClients:!1,sendToResellers:!1,selectedTempalteId:s.get("templateId")}))),[k,b]=(0,r.useState)({});(0,r.useEffect)((()=>{const e=o.selectedTempalteId;e&&u.default.query({query:T(),variables:{numericId:Number(e),id:btoa(`MassEmailTemplate:${e}`)}}).then((({data:{massEmail:{template:e,templateClients:n,templateResellers:i}}})=>{f((s=>({...s,fromEmail:e.fromEmail,body:e.body,subject:e.subject,sendToClientsMode:e.sendToClientsMode,sendToResellersMode:e.sendToResellersMode,sendToAdmins:e.sendToAdmins,sendToClients:e.sendToClients,sendToResellers:e.sendToResellers,clients:n.contacts.map((({id:e})=>atob(e).split(":")[1])),resellers:i.contacts.map((({id:e})=>atob(e).split(":")[1]))})))}))}),[o.selectedTempalteId]);const M=(0,c.useNavigate)(),[F,{loading:x}]=(0,l.useMutation)(S,{update:p.evictMassEmailCache}),[y,{loading:E}]=(0,l.useMutation)(g());return(0,r.jsx)(h.default,{onSuccess:async()=>{if(o.saveAsTemplate){const{selectedTempalteId:e,saveAsTemplate:n,newTemplateName:i,clients:s=[],resellers:a=[],...l}=o;await y({variables:{input:{...l,name:i,resellers:s.map(Number),clients:a.map(Number)}}})}(0,d.addToast)({intent:"success",message:N.formatMessage("emailSent")}),M("..")},mutation:F,loading:x||E,customers:e,resellers:n,onChange:(e,n)=>{f((i=>(0,t.setIn)(i,e,n)))},values:o,hideNameField:!0,onSubmit:e=>{if(e.saveAsTemplate&&!e.newTemplateName)return b({newTemplateName:{required:N.lmsg("fieldIsRequired")}}),null;const{selectedTempalteId:n,saveAsTemplate:i,newTemplateName:s,...a}=e;return a},errors:k,submitButtonProps:{children:N.lmsg("send")},footer:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.FormFieldCheckbox,{label:N.lmsg("saveAsTemplate"),name:"saveAsTemplate"}),o.saveAsTemplate&&(0,r.jsx)(t.FormFieldText,{required:!0,size:"xl",label:N.lmsg("newTemplateName"),name:"newTemplateName"})]}),children:!!i.length&&(0,r.jsx)(t.FormFieldSelect,{size:"xl",name:"selectedTempalteId",label:N.lmsg("selectedTemplate"),children:i.map((({templateId:e,name:n})=>(0,r.jsx)("option",{value:e.toString(),children:n},e)))})})}},2552:(e,n,i)=>{"use strict";i.r(n),i.d(n,{evictMassEmailCache:()=>s});const s=e=>{e.evict({id:e.identify({__typename:"Query"}),fieldName:"massEmail"})}},2553:e=>{var n={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"AddMassEmailTemplate"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"AddMassEmailTemplateInput"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"addMassEmailTemplate"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"errors"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:133}};n.loc.source={body:"mutation AddMassEmailTemplate($input: AddMassEmailTemplateInput!) {\n addMassEmailTemplate(input: $input) {\n errors\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var s=e.type;"NamedType"===s.kind&&n.add(s.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,n)})),e.definitions&&e.definitions.forEach((function(e){i(e,n)}))}var s={};function a(e,n){for(var i=0;i<e.definitions.length;i++){var s=e.definitions[i];if(s.name&&s.name.value==n)return s}}n.definitions.forEach((function(e){if(e.name){var n=new Set;i(e,n),s[e.name.value]=n}})),e.exports=n,e.exports.AddMassEmailTemplate=function(e,n){var i={kind:e.kind,definitions:[a(e,n)]};e.hasOwnProperty("loc")&&(i.loc=e.loc);var l=s[n]||new Set,t=new Set,d=new Set;for(l.forEach((function(e){d.add(e)}));d.size>0;){var o=d;d=new Set,o.forEach((function(e){t.has(e)||(t.add(e),(s[e]||new Set).forEach((function(e){d.add(e)})))}))}return t.forEach((function(n){var s=a(e,n);s&&i.definitions.push(s)})),i}(n,"AddMassEmailTemplate")},2558:e=>{var n={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"MassMailTemplate"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"numericId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"massEmail"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"template"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"fromEmail"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"sendToAdmins"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"sendToResellers"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"sendToResellersMode"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"sendToClients"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"sendToClientsMode"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"subject"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"body"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"templateResellers"},arguments:[{kind:"Argument",name:{kind:"Name",value:"templateId"},value:{kind:"Variable",name:{kind:"Name",value:"numericId"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"contacts"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]}]}}]}},{kind:"Field",name:{kind:"Name",value:"templateClients"},arguments:[{kind:"Argument",name:{kind:"Name",value:"templateId"},value:{kind:"Variable",name:{kind:"Name",value:"numericId"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"contacts"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]}]}}]}}]}}]}}],loc:{start:0,end:566}};n.loc.source={body:"query MassMailTemplate($id: ID!, $numericId: Int!) {\n massEmail {\n template(id: $id) {\n name\n fromEmail\n sendToAdmins\n sendToResellers\n sendToResellersMode\n sendToClients\n sendToClientsMode\n subject\n body\n }\n templateResellers(templateId: $numericId) {\n contacts {\n id\n }\n }\n templateClients(templateId: $numericId) {\n contacts {\n id\n }\n }\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var s=e.type;"NamedType"===s.kind&&n.add(s.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,n)})),e.definitions&&e.definitions.forEach((function(e){i(e,n)}))}var s={};function a(e,n){for(var i=0;i<e.definitions.length;i++){var s=e.definitions[i];if(s.name&&s.name.value==n)return s}}n.definitions.forEach((function(e){if(e.name){var n=new Set;i(e,n),s[e.name.value]=n}})),e.exports=n,e.exports.MassMailTemplate=function(e,n){var i={kind:e.kind,definitions:[a(e,n)]};e.hasOwnProperty("loc")&&(i.loc=e.loc);var l=s[n]||new Set,t=new Set,d=new Set;for(l.forEach((function(e){d.add(e)}));d.size>0;){var o=d;d=new Set,o.forEach((function(e){t.has(e)||(t.add(e),(s[e]||new Set).forEach((function(e){d.add(e)})))}))}return t.forEach((function(n){var s=a(e,n);s&&i.definitions.push(s)})),i}(n,"MassMailTemplate")}}]); //# sourceMappingURL=SendMassMailPage.js.map?7e8989eac9548fdbf193