"use strict";(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[4414],{3708:(e,t,r)=>{r.d(t,{A:()=>n});var s=r(36418),a=r.n(s),i=r(14778);function n(){const{formatMessage:e}=(0,i.useIntl)();return a().createElement("i",{className:"fa fa-1x fa-angle-left",title:e({id:"generic_icons.logout",defaultMessage:"Logout Icon"})})}},44414:(e,t,r)=>{r.r(t),r.d(t,{default:()=>O});var s=r(37270),a=r(32446),i=r(17085),n=r(26614),o=r(77440),c=r(69410),l=(r(15724),r(5673),r(30164),r(21279),r(36418)),m=r.n(l),d=r(89735),g=r(14778),u=r(78546),f=r(91767),h=r(32924),v=r(1396),E=r(3708),p=r(87064),T=r(53654),_=r(83007),S=r(78451),A=r(42241),M=r(62975);class b extends m().PureComponent{constructor(e){super(e),this.state={customTermsOfServiceId:"",customTermsOfServiceText:"",loading:!0,loadingAgree:!1,loadingDisagree:!1,serverError:null},this.formattedText=(0,u.el)((t=>(0,M.vX)(t,{},e.emojiMap)))}componentDidMount(){this.props.termsEnabled?this.getTermsOfService():f.tc()}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.BN(`/login?extra=${S.YM.GET_TERMS_ERROR}`)};handleLogoutClick=e=>{e.preventDefault(),f.BN("/login")};handleAcceptTerms=()=>{this.setState({loadingAgree:!0,serverError:null}),this.registerUserAction(!0,(()=>{const e=new URLSearchParams(this.props.location?.search).get("redirect_to");e&&e.match(/^\/([^/]|$)/)?(0,_.J)().push(e):this.props.onboardingFlowEnabled?(0,_.J)().push("/"):f.tc()}))};handleRejectTerms=()=>{this.setState({loadingDisagree:!0,serverError:null}),this.registerUserAction(!1,(()=>{f.BN(`/login?extra=${S.YM.TERMS_REJECTED}`)}))};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.FormattedMessage,{id:"terms_of_service.api_error",defaultMessage:"Unable to complete the request. If this issue persists, contact your System Administrator."})})};render(){if(this.state.loading)return m().createElement(v.A,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",{className:"signup-page-container"},m().createElement(h.default,null),m().createElement("div",{className:"signup-header"},m().createElement("a",{href:"#",onClick:this.handleLogoutClick},m().createElement(E.A,null),m().createElement(g.FormattedMessage,{id:"web.header.logout",defaultMessage:"Logout"}))),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,A.A)(this.formattedText(this.state.customTermsOfServiceText),{mentions:!1}))),m().createElement("div",{className:"terms-of-service__footer medium-center"},m().createElement("div",{className:"terms-of-service__button-group"},m().createElement(d.Button,{bsStyle:"primary",disabled:this.state.loadingAgree||this.state.loadingDisagree,id:"acceptTerms",onClick:this.handleAcceptTerms,type:"submit"},this.state.loadingAgree&&m().createElement(T.A,null),m().createElement(g.FormattedMessage,{id:"terms_of_service.agreeButton",defaultMessage:"I Agree"})),m().createElement(d.Button,{bsStyle:"default",className:"btn-quaternary",disabled:this.state.loadingAgree||this.state.loadingDisagree,id:"rejectTerms",onClick:this.handleRejectTerms,type:"reset"},this.state.loadingDisagree&&m().createElement(T.A,null),m().createElement(g.FormattedMessage,{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(p.A,null)," ",this.state.serverError))))}}const O=(0,s.connect)((function(e){const t=(0,n.zj)(e);return{onboardingFlowEnabled:(0,o.Pu)(e),termsEnabled:"true"===t.EnableCustomTermsOfService,emojiMap:(0,c.v6)(e)}}),(function(e){return{actions:(0,a.zH)({getTermsOfService:i.AW,updateMyTermsOfServiceStatus:i.Zg},e)}}))(b)},87064:(e,t,r)=>{r.d(t,{A:()=>l});var s=r(71633),a=r.n(s),i=r(36418),n=r.n(i),o=r(14778);const c=e=>{let{additionalClassName:t}=e;const{formatMessage:r}=(0,o.useIntl)();return n().createElement("i",{className:a()("fa fa-warning",t),title:r({id:"generic_icons.warning",defaultMessage:"Warning Icon"})})},l=n().memo(c)}}]);
//# sourceMappingURL=4414.10814b348b98d1899f86.js.map