(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[626],{56626:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>y});var s=r(37703),i=r(14890),a=r(12543),n=r(78781),c=r(21226),o=(r(88674),r(4723),r(64765),r(33948),r(60285),r(45697)),l=r.n(o),m=r(67294),d=r(66456),u=r(78318),g=r(44012),f=r(61625),h=r(34288),v=r(26521),p=r(19476),E=r(56640),T=r(30233),S=r(37668),_=r(89262),b=r(18350),O=r(54140),R=r(78274);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 M 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}):h.gc("/login?extra=".concat(R.gT.GET_TERMS_ERROR))})),Z(this,"handleLogoutClick",(e=>{e.preventDefault(),h.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):h.mc()}))})),Z(this,"handleRejectTerms",(()=>{this.setState({loadingDisagree:!0,serverError:null}),this.registerUserAction(!1,(()=>{h.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,f.memoizeResult)((t=>(0,O.RZ)(t,{},e.emojiMap)))}componentDidMount(){this.props.termsEnabled?this.getTermsOfService():h.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(M,"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 y=(0,s.connect)((function(e){return{termsEnabled:"true"===(0,n.getConfig)(e).EnableCustomTermsOfService,emojiMap:(0,c.kM)(e)}}),(function(e){return{actions:(0,i.bindActionCreators)({getTermsOfService:a.getTermsOfService,updateMyTermsOfServiceStatus:a.updateMyTermsOfServiceStatus},e)}}))(M)},30233:(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.5699da7df2912ef53960.js.map