D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
local
/
psa
/
admin
/
cp
/
public
/
javascript
/
app
/
Filename :
newsletter-subscription.js
back
Copy
(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/newsletter-subscription"],{3032:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>g});var i=t(286),s=t(285),o=t(596),r=t.n(o),a=t(89),c=t(3033),l=t.n(c),d=t(536);const u="send_announce",m="send_personalized_announce",p=a.Locale.getSection("components.newsletter-subscription"),f=a.Locale.getTranslate("components.newsletter-subscription"),v=({consents:e,email:n,reportConsent:t,onClose:o,privacyPolicyUrl:r,isOpen:a})=>{const[c,v]=(0,s.useState)(null),g=()=>p.lmsg(y()?"reconfirmConsent":"consent",{adminEmail:n,privacyPolicy:p.lmsg("privacyPolicy")}),y=()=>e.some((e=>e.enabled&&e.type===u))&&!e.some((e=>e.enabled&&e.type===m)),k=y();return(0,s.jsxs)(i.Dialog,{isOpen:a,size:"sm",banner:l(),title:(0,s.jsx)(f,{content:k?"reconfirmTitle":"title"}),form:{state:c,onSubmit:async()=>{v("submit");const e=await t(n,m,g());v(null),e?(0,d.addToast)({intent:"success",message:(0,s.jsx)(f,{content:"subscribeMessage"})}):(0,d.addToast)({intent:"danger",message:(0,s.jsx)(f,{content:"errorMessage"})}),o(!!e||void 0)},submitButton:{children:(0,s.jsx)(f,{content:k?"reconfirmButton":"subscribeButton"})},cancelButton:{children:(0,s.jsx)(f,{content:"closeButton"})},hideRequiredLegend:!0},onClose:async()=>{if(c)return;const e=y();v("cancel");const i=await t(n,e?u:"none",g());v(null),i?e&&(0,d.addToast)({intent:"success",message:(0,s.jsx)(f,{content:"noReconfirmMessage"})}):(0,d.addToast)({intent:"danger",message:(0,s.jsx)(f,{content:"errorMessage"})}),o(!i&&void 0)},children:[!k&&(0,s.jsx)("p",{children:(0,s.jsx)(f,{content:"text"})}),(()=>{if(y())return(0,s.jsx)(i.StatusMessage,{intent:"info",children:(0,s.jsx)(f,{content:"consentGivenInfo"})})})(),(0,s.jsx)("p",{children:(0,s.jsx)(f,{content:k?"reconfirmConsent":"consent",params:{privacyPolicy:(0,s.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:(0,s.jsx)(f,{content:"privacyPolicy"})}),adminEmail:n}})})]})};v.propTypes={isOpen:r().bool.isRequired,email:r().string.isRequired,reportConsent:r().func.isRequired,privacyPolicyUrl:r().string.isRequired,consents:r().array.isRequired,onClose:r().func.isRequired};const g=v},3031:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>v});var i=t(285),s=t(89),o=t(380),r=t(3032),a=t(596),c=t.n(a),l=t(586),d=t(3034),u=t.n(d);const m="plesk-newsletter-subscription-shown",p=async(e,n,t)=>{const i=new Date(Date.now()+864e5);o.default.set(m,1,i.toUTCString(),"/");try{const i=await s.api.post((0,s.prepareUrl)("/my-profile/report-consent"),{email:e,text:t,consent:n});return"error"!==i.status&&window.loadConsentStatus(),"error"!==i.status}catch{return!1}},f=({isShow:e,...n})=>{const[t,a]=(0,i.useState)(null),c=(0,i.useRef)([]),{data:{viewer:d,config:f}={}}=(0,l.useQuery)(u()),v=async(e,n=s.emptyFn)=>{c.current.push(n),a(await(async e=>{const{consents:n=[]}=await s.api.get((0,s.prepareUrl)("/my-profile/get-consent"),{email:e});return n})(e))};return(0,i.useEffect)((()=>{if(d?.client?.email)return e&&!o.default.get(m)&&v(d?.client?.email),(0,s.namespace)("PleskExt.Advisor").showNewsletterSubscription=e=>{v(d?.client?.email,e)},()=>{delete(0,s.namespace)("PleskExt.Advisor").showNewsletterSubscription}}),[d?.client?.email]),(0,i.jsx)(r.default,{isOpen:null!==t,consents:t||[],reportConsent:p,onClose:e=>{a(null),void 0!==e&&c.current.forEach((n=>n(e))),c.current=[]},privacyPolicyUrl:f?.product?.privacyPolicyUrl,email:d?.client?.email,...n})};f.propTypes={isShow:c().bool.isRequired};const v=f},3033:e=>{e.exports=Jsw.skinUrl+"/images/newsletter-subscription.png?b1de5a7718f72cdae8b90e2f38d2b322"},3034:e=>{var n={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"NewsletterSubscription"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"viewer"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"login"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"client"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"email"},arguments:[],directives:[]}]}}]}},{kind:"Field",name:{kind:"Name",value:"config"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"product"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"privacyPolicyUrl"},arguments:[],directives:[]}]}}]}}]}}],loc:{start:0,end:202}};n.loc.source={body:"query NewsletterSubscription {\n viewer {\n login\n client {\n id\n email\n }\n }\n config {\n product {\n privacyPolicyUrl\n }\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function t(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var i=e.type;"NamedType"===i.kind&&n.add(i.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){t(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){t(e,n)})),e.definitions&&e.definitions.forEach((function(e){t(e,n)}))}var i={};function s(e,n){for(var t=0;t<e.definitions.length;t++){var i=e.definitions[t];if(i.name&&i.name.value==n)return i}}n.definitions.forEach((function(e){if(e.name){var n=new Set;t(e,n),i[e.name.value]=n}})),e.exports=n,e.exports.NewsletterSubscription=function(e,n){var t={kind:e.kind,definitions:[s(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var o=i[n]||new Set,r=new Set,a=new Set;for(o.forEach((function(e){a.add(e)}));a.size>0;){var c=a;a=new Set,c.forEach((function(e){r.has(e)||(r.add(e),(i[e]||new Set).forEach((function(e){a.add(e)})))}))}return r.forEach((function(n){var i=s(e,n);i&&t.definitions.push(i)})),t}(n,"NewsletterSubscription")}}]); //# sourceMappingURL=newsletter-subscription.js.map?32072798628b84dfb5bb