Files
server/opt/psa/admin/cp/public/javascript/components/pages/CreateMassMailTemplatePage.js
2026-01-07 20:52:11 +01:00

2 lines
7.7 KiB
JavaScript

(globalThis.webpackChunkPlesk=globalThis.webpackChunkPlesk||[]).push([["components/pages/CreateMassMailTemplatePage"],{2599:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>g});var l=n(696),i=n(620),t=n(297),a=n(546),o=n(90),d=n(296),r=n(2600),c=n(1212),m=n.n(c),u=n(2601),p=n.n(u),f=n(2602),b=n(599);const h=o.Locale.getSection("components.pages.CreateMassMailTemplatePage"),g=()=>{const[e,s]=(0,d.useState)(()=>({sendToClientsMode:"all",sendToResellersMode:"all",sendToAdmins:!1,sendToClients:!1,sendToResellers:!1})),{data:{viewer:{customers:n,resellers:o}}}=(0,i.useQuery)(m()),c=(0,b.useNavigate)(),[u,{loading:g}]=(0,l.useMutation)(p(),{update:r.evictMassEmailCache});return(0,d.jsx)(f.default,{onSuccess:()=>{(0,a.addToast)({intent:"success",message:h.formatMessage("templateCreated")}),c("..")},mutation:u,loading:g,customers:n,resellers:o,onChange:(e,n)=>{s(s=>(0,t.setIn)(s,e,n))},values:e})}},2600:(e,s,n)=>{"use strict";n.r(s),n.d(s,{evictMassEmailCache:()=>l});const l=e=>{e.evict({id:e.identify({__typename:"Query"}),fieldName:"massEmail"})}},2601:e=>{var s={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}};s.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 n(e,s){if("FragmentSpread"===e.kind)s.add(e.name.value);else if("VariableDefinition"===e.kind){var l=e.type;"NamedType"===l.kind&&s.add(l.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(e){n(e,s)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(e){n(e,s)}),e.definitions&&e.definitions.forEach(function(e){n(e,s)})}var l={};function i(e,s){for(var n=0;n<e.definitions.length;n++){var l=e.definitions[n];if(l.name&&l.name.value==s)return l}}s.definitions.forEach(function(e){if(e.name){var s=new Set;n(e,s),l[e.name.value]=s}}),e.exports=s,e.exports.AddMassEmailTemplate=function(e,s){var n={kind:e.kind,definitions:[i(e,s)]};e.hasOwnProperty("loc")&&(n.loc=e.loc);var t=l[s]||new Set,a=new Set,o=new Set;for(t.forEach(function(e){o.add(e)});o.size>0;){var d=o;o=new Set,d.forEach(function(e){a.has(e)||(a.add(e),(l[e]||new Set).forEach(function(e){o.add(e)}))})}return a.forEach(function(s){var l=i(e,s);l&&n.definitions.push(l)}),n}(s,"AddMassEmailTemplate")},2602:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>l.default});var l=n(2603)},2603:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>b});var l=n(297),i=n(1305),t=n(90),a=n(668),o=n.n(a),d=n(296),r=n(683),c=n.n(r),m=n(718),u=n(2604);const p=t.Locale.getSection("components.forms.MassMailForm"),f=({customers:e,resellers:s,loading:n,mutation:t,onSuccess:a,values:o,onChange:r,children:f=null,footer:b=null,errors:h={},submitButtonProps:g={},hideNameField:v=!1,onSubmit:T=e=>e,applyButton:x=!1})=>{const k=(0,d.useMemo)(()=>s.map(({id:e,name:s,email:n})=>{const l=atob(e).split(":")[1];return{id:l,title:`${s} (${n})`,selected:o.resellers?.includes(l)}}),[s,o.resellers]),M=(0,d.useMemo)(()=>e.map(({id:e,name:s,email:n})=>{const l=atob(e).split(":")[1];return{id:l,title:`${s} (${n})`,selected:o.clients?.includes(l)}}),[e,o.clients]);return(0,d.jsxs)(i.default,{state:n?"submit":null,values:o,onFieldChange:r,mutation:t,onSuccess:a,onSubmit:e=>T({...e,sendToResellersMode:e.sendToResellers?e.sendToResellersMode:"all",sendToClientsMode:e.sendToClients?e.sendToClientsMode:"all",resellers:(e.resellers??[]).map(Number),clients:(e.clients??[]).map(Number)}),errors:h,submitButton:{"data-testid":"btn-submit",...g},applyButton:x,cancelButton:{"data-testid":"btn-cancel",component:m.default,to:"/cp/server/mass-mail"},children:[f,!v&&(0,d.jsx)(l.FormFieldText,{required:!0,size:"xl",label:p.lmsg("name"),name:"name"}),(0,d.jsx)(l.FormFieldText,{required:!0,size:"xl",label:p.lmsg("fromEmail"),name:"fromEmail"}),(0,d.jsx)(l.FormFieldCheckbox,{label:p.lmsg("sendToAdmins"),name:"sendToAdmins"}),(0,d.jsx)(l.FormFieldCheckbox,{label:p.lmsg("sendToResellers"),name:"sendToResellers"}),(0,d.jsxs)("div",{className:c()({"mass-mail-form-block-hidden":!o.sendToResellers}),children:[(0,d.jsxs)(l.FormFieldSelect,{size:"lg",name:"sendToResellersMode",label:p.lmsg("sendToResellersMode"),children:[(0,d.jsx)("option",{value:"all",children:p.lmsg("sendToResellersModeAll")}),(0,d.jsx)("option",{value:"select",children:p.lmsg("sendToResellersModeSelect")}),(0,d.jsx)("option",{value:"except",children:p.lmsg("sendToResellersModeExcept")})]}),(0,d.jsx)(l.FormField,{className:c()({"mass-mail-form-block-hidden":"all"===o.sendToResellersMode}),name:"resellers",children:({setValue:e})=>(0,d.jsx)(u.default,{name:"select-reseller",onChange:e,options:k})})]}),(0,d.jsx)(l.FormFieldCheckbox,{label:p.lmsg("sendToClients"),name:"sendToClients"}),(0,d.jsxs)("div",{className:c()({"mass-mail-form-block-hidden":!o.sendToClients}),children:[(0,d.jsxs)(l.FormFieldSelect,{size:"lg",name:"sendToClientsMode",label:p.lmsg("sendToClientsMode"),children:[(0,d.jsx)("option",{value:"all",children:p.lmsg("sendToClientsModeAll")}),(0,d.jsx)("option",{value:"select",children:p.lmsg("sendToClientsModeSelect")}),(0,d.jsx)("option",{value:"except",children:p.lmsg("sendToClientsModeExcept")})]}),(0,d.jsx)(l.FormField,{className:c()({"mass-mail-form-block-hidden":"all"===o.sendToClientsMode}),name:"clients",children:({setValue:e})=>(0,d.jsx)(u.default,{name:"select-client",onChange:e,options:M})})]}),(0,d.jsx)(l.FormFieldText,{required:!0,size:"xl",label:p.lmsg("subject"),name:"subject"}),(0,d.jsx)(l.FormFieldText,{description:p.lmsg("bodyDescription"),required:!0,size:"fill",rows:10,multiline:!0,label:p.lmsg("body"),name:"body"}),b]})};f.propTypes={customers:o().array.isRequired,resellers:o().array.isRequired,loading:o().bool.isRequired,mutation:o().func.isRequired,onSuccess:o().func.isRequired,onSubmit:o().func,values:o().object.isRequired,submitButtonProps:o().object,onChange:o().func.isRequired,children:o().node,footer:o().node,errors:o().object,hideNameField:o().bool,applyButton:o().oneOf([o().object,o().bool])};const b=f},2604:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>c});var l=n(296),i=n(90),t=n(713),a=n(668),o=n.n(a);const d=i.Locale.getSection("components.elements.double-list-selector"),r=({name:e,options:s,onChange:n=()=>{},...a})=>{const[o,r]=(0,l.useState)(null),c=(0,l.useRef)(s);return(0,l.useEffect)(()=>{const l=new i.EnhancedDoubleListSelector({list:s,applyTo:e,isSearchable:!0,locale:d,name:e,onChange:e=>{const s=Object.keys(e).reduce((s,n)=>e[n]?[...s,n]:s,[]);n(s)},...a});return r(l),()=>{l.remove(),r(null)}},[]),(0,l.useEffect)(()=>{o&&c.current!==s&&s.forEach((e,s)=>{c.current[s].selected!==e.selected&&(o._toggleItemSelection(s,!e.selected),c.current[s].selected=e.selected)})},[o,s]),(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{id:e}),o&&(0,l.jsx)(t.default,{children:o})]})};r.propTypes={name:o().string.isRequired,options:o().arrayOf(o().shape({selected:o().bool,id:o().any,title:o().string,description:o().string,icons:o().arrayOf(o().shape({src:o().string,title:o().string}))})).isRequired,isSearchable:o().bool,onChange:o().func};const c=r}}]);
//# sourceMappingURL=CreateMassMailTemplatePage.js.map?8be0370c90e39509c87e