(self.webpackChunk_mattermost_webapp=self.webpackChunk_mattermost_webapp||[]).push([[626],{56626:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>M});var s=r(14494),i=r(90879),a=r(33383),n=r(22742),c=r(21226),o=r(45697),l=r.n(o),m=(r(88674),r(33948),r(60285),r(74916),r(64765),r(4723),r(67294)),d=r(66456),u=r(78318),g=r(44012),h=r(16794),f=r(34288),v=r(11796),p=r(19476),E=r(56640),T=r(73406),S=r(37668),_=r(89262),b=r(8742),O=r(54140),R=r(68336);function Z(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class A extends m.PureComponent{constructor(e){super(e),Z(this,"formattedText",void 0),Z(this,"getTermsOfService",(async()=>{this.setState({customTermsOfServiceId:"",customTermsOfServiceText:"",loading:!0});const{data:e}=await this.props.actions.getTermsOfService();e?this.setState({customTermsOfServiceId:e.id,customTermsOfServiceText:e.text,loading:!1}):f.gc("/login?extra=".concat(R.gT.GET_TERMS_ERROR))})),Z(this,"handleLogoutClick",(e=>{e.preventDefault(),f.gc("/login")})),Z(this,"handleAcceptTerms",(()=>{this.setState({loadingAgree:!0,serverError:null}),this.registerUserAction(!0,(()=>{const e=new URLSearchParams(this.props.location.search).get("redirect_to");e&&e.match(/^\/([^/]|$)/)?_.m.push(e):f.mc()}))})),Z(this,"handleRejectTerms",(()=>{this.setState({loadingDisagree:!0,serverError:null}),this.registerUserAction(!1,(()=>{f.gc("/login?extra=".concat(R.gT.TERMS_REJECTED))}))})),Z(this,"registerUserAction",(async(e,t)=>{const{data:r}=await this.props.actions.updateMyTermsOfServiceStatus(this.state.customTermsOfServiceId,e);r?t(r):this.setState({loadingAgree:!1,loadingDisagree:!1,serverError:m.createElement(g.Z,{id:"terms_of_service.api_error",defaultMessage:"Unable to complete the request. If this issue persists, contact your System Administrator."})})})),this.state={customTermsOfServiceId:"",customTermsOfServiceText:"",loading:!0,loadingAgree:!1,loadingDisagree:!1,serverError:null},this.formattedText=(0,h.GA)((t=>(0,O.RZ)(t,{},e.emojiMap)))}componentDidMount(){this.props.termsEnabled?this.getTermsOfService():f.mc()}render(){if(this.state.loading)return m.createElement(p.Z,null);let e="terms-of-service__markdown";return this.state.serverError?e+=" terms-of-service-error__height--fill":e+=" terms-of-service__height--fill",m.createElement("div",null,m.createElement(v.Z,null),m.createElement("div",{className:"signup-header"},m.createElement("a",{href:"#",onClick:this.handleLogoutClick},m.createElement(T.Z,null),m.createElement(g.Z,{id:"web.header.logout",defaultMessage:"Logout"}))),m.createElement("div",null,m.createElement("div",{className:"signup-team__container terms-of-service__container"},m.createElement("div",{className:e},m.createElement("div",{className:"medium-center","data-testid":"termsOfService"},(0,b.Z)(this.formattedText(this.state.customTermsOfServiceText),!1,{mentions:!1}))),m.createElement("div",{className:"terms-of-service__footer medium-center"},m.createElement(d.Z,{className:"terms-of-service__button-group"},m.createElement(u.Z,{bsStyle:"primary",disabled:this.state.loadingAgree||this.state.loadingDisagree,id:"acceptTerms",onClick:this.handleAcceptTerms,type:"submit"},this.state.loadingAgree&&m.createElement(E.Z,null),m.createElement(g.Z,{id:"terms_of_service.agreeButton",defaultMessage:"I Agree"})),m.createElement(u.Z,{bsStyle:"link",disabled:this.state.loadingAgree||this.state.loadingDisagree,id:"rejectTerms",onClick:this.handleRejectTerms,type:"reset"},this.state.loadingDisagree&&m.createElement(E.Z,null),m.createElement(g.Z,{id:"terms_of_service.disagreeButton",defaultMessage:"I Disagree"}))),Boolean(this.state.serverError)&&m.createElement("div",{className:"terms-of-service__server-error alert alert-warning"},m.createElement(S.Z,null)," ",this.state.serverError)))))}}Z(A,"propTypes",{location:l().shape({search:l().string.isRequired}).isRequired,termsEnabled:l().bool.isRequired,actions:l().shape({getTermsOfService:l().func.isRequired,updateMyTermsOfServiceStatus:l().func.isRequired}).isRequired});const M=(0,s.connect)((function(e){return{termsEnabled:"true"===(0,n.iE)(e).EnableCustomTermsOfService,emojiMap:(0,c.kM)(e)}}),(function(e){return{actions:(0,i.bindActionCreators)({getTermsOfService:a.Oi,updateMyTermsOfServiceStatus:a.oR},e)}}))(A)},73406:(e,t,r)=>{"use strict";r.d(t,{Z:()=>a});var s=r(67294),i=r(86896);function a(){const{formatMessage:e}=(0,i.Z)();return s.createElement("i",{className:"fa fa-1x fa-angle-left",title:e({id:"generic_icons.logout",defaultMessage:"Logout Icon"})})}}}]);
//# sourceMappingURL=626.72159aa1b9307781e717.js.map