"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/login/recovery-password"],{1788:(e,s,t)=>{t.r(s),t.d(s,{default:()=>h});var n=t(93),r=t(286),i=t(285),o=t(591),a=t.n(o),c=t(89),l=t(1436),d=t(536);class p extends i.Component{constructor(e){if(super(e),(0,n.default)(this,"state",{recoveryLink:"",recoveryEmail:"",isActionInProgress:!1,isDrawerOpen:!1,isSendingInProgress:!1}),(0,n.default)(this,"handleAction",(()=>{if(this.state.isActionInProgress)return;if(this.state.recoveryLink)return void this.setState({isDrawerOpen:!0});this.setState({isActionInProgress:!0});const{userType:e,userId:s}=this.props;c.api.post((0,c.prepareUrl)(`${this.endpoint}/generate-secret`),{userType:e,userId:s}).then((e=>{"success"===e.status?this.setState({recoveryLink:e.link,recoveryEmail:e.email,isActionInProgress:!1,isDrawerOpen:!0}):location.reload()}))})),(0,n.default)(this,"handleSend",(()=>{if(this.state.isSendingInProgress)return;this.setState({isSendingInProgress:!0});const{messages:e}=this.props,{userType:s,userId:t}=this.props;c.api.post((0,c.prepareUrl)(`${this.endpoint}/send-secret`),{userType:s,userId:t,secret:this.state.recoveryLink}).then((s=>{"success"===s.status?(this.setState({isDrawerOpen:!1}),(0,d.addToast)({intent:"success",message:e.linkSendedMessage}),this.setState({isSendingInProgress:!1,recoveryLink:null})):location.reload()}))})),(0,n.default)(this,"handleClose",(()=>{this.setState({isDrawerOpen:!1,recoveryLink:null})})),2===this.props.userType)this.endpoint="/admin/reseller";else if(4===this.props.userType)this.endpoint="/admin/customer";else if(8===this.props.userType)this.endpoint="/smb/user";else{if(32!==this.props.userType)throw new Error("Unexpected user type.");this.endpoint="/smb/email-address"}}render(){const{renderAction:e}=this.props,s=e?.(this.handleAction,this.state.isActionInProgress)??(0,i.jsx)(r.Action,{onClick:this.handleAction,progress:this.state.isActionInProgress,children:(0,i.jsx)(r.Translate,{content:"action"})});return(0,i.jsxs)(i.Fragment,{children:[s,(0,i.jsxs)(r.Drawer,{size:"sm",isOpen:this.state.isDrawerOpen,title:(0,i.jsx)(r.Translate,{content:"title"}),cancelTitle:(0,i.jsx)(r.Translate,{content:"closeButton"}),onClose:this.handleClose,"data-type":"recovery-password",children:[(0,i.jsx)(r.Paragraph,{children:(0,i.jsx)(r.Translate,{content:"copyText",params:{email:(0,i.jsx)(r.Text,{bold:!0,children:this.state.recoveryEmail})}})}),(0,i.jsxs)(r.Alert,{intent:"info",children:[(0,i.jsx)("div",{"data-cy":"recovery-link",children:this.state.recoveryLink}),(0,i.jsx)("br",{}),(0,i.jsx)("div",{children:(0,i.jsx)(l.default,{content:this.state.recoveryLink||"",onCopy:()=>(0,d.addToast)({intent:"success",message:c.Locale.getSection("components.buttons").lmsg("copied")}),children:(0,i.jsx)(r.Translate,{content:"copyButton"})})})]}),!!this.state.recoveryEmail&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.Paragraph,{children:(0,i.jsx)(r.Translate,{content:"text",params:{email:(0,i.jsx)(r.Text,{bold:!0,children:this.state.recoveryEmail})}})}),(0,i.jsx)(r.Button,{size:"lg",intent:"primary",onClick:this.handleSend,state:this.state.isSendingInProgress?"loading":void 0,children:(0,i.jsx)(r.Translate,{content:"sendButton"})},"sendButton")]})]})]})}}p.propTypes={messages:a().object.isRequired,userType:a().number.isRequired,userId:a().number.isRequired,renderAction:a().func},p.defaultProps={renderAction:null};const h=p},3026:(e,s,t)=>{t.r(s),t.d(s,{default:()=>a});var n=t(286),r=t(285),i=t(89),o=t(1788);const a=({renderTo:e,...s})=>{const t=i.Locale.getSection("components.login.recovery-password").messages;(0,r.render)((0,r.jsx)(n.LocaleProvider,{messages:t,children:(0,r.jsx)(o.default,{messages:t,...s})}),document.getElementById(e))}},1436:(e,s,t)=>{t.r(s),t.d(s,{default:()=>a});var n=t(286),r=t(89),i=t(285);const o=r.Locale.getSection("components.buttons"),a=({id:e,content:s,icon:t="copy",className:r,tooltip:a=o.lmsg("copyToClipboard"),onCopy:c=()=>{},children:l})=>(0,i.jsx)(n.Button,{className:r,ghost:!0,icon:t,tooltip:a,tooltipAsLabel:!0,onClick:()=>{(0,n.copyToClipboard)(s),c()},"data-action":"copy-to-clipboard"+(e?`-${e}`:""),children:l})}}]);
//# sourceMappingURL=recovery-password.js.map?46210f10661f79a74112