(this["webpackJsonpqq-delivery-ui"]=this["webpackJsonpqq-delivery-ui"]||[]).push([[159],{894:function(e,t,s){"use strict";s.r(t);var a=s(0),r=s.n(a),i=s(41),o=s(36),n=s(48),h=s(21),c=s.n(h),E=s(367),d=s(1452),g=(s(88),s(455));class l extends a.Component{constructor(e){super(e),this.state={errors:{error:!1,errorMessage:""},message:!1,loading:!1},this.config=new i.a,this.resources=new o.a,this.dataService=new n.a,this.t=this.props.lang,this.i18n=this.props.i18n}handleValueChange(e){this.setState(Object.assign(this.state.login,{[e.target.name]:e.target.value}))}render(){return r.a.createElement("div",{style:{paddingTop:"4%"}},r.a.createElement("div",{style:{height:"100%",paddingTop:"3%"}},"Requesting access"),r.a.createElement(E.a,{open:this.state.errors.error,autoHideDuration:5e3,anchorOrigin:{vertical:"top",horizontal:"center"},onClose:e=>{this.setState(Object.assign(this.state.errors,{error:!1}))}},r.a.createElement(d.a,{severity:"error",elevation:6,variant:"filled",onClose:e=>{this.setState(Object.assign(this.state.errors,{error:!1}))}},this.state.errors.errorMessage)))}componentDidMount(){const e=this.props.match.params.module,t=this.props.match.params.token;this.i18n.changeLanguage(this.dataService.getLanguage());let s=new Date;s.setTime(s.getTime()+3e5),c.a.remove(this.config.COOKIE_NAME_TOKEN,{path:"/"}),c.a.save(this.config.COOKIE_NAME_TOKEN,t,{path:"/",d:s,maxAge:3e5}),window.sessionStorage.setItem(this.config.COOKIE_NAME_TOKEN,t),this.loadDuration(t,e)}loadDuration(e,t){this.dataService.retrieve(this.config.SERVICE_NAME_USER,this.config.SERVICE_ACTION_USER_ROLE_CHECK).then(s=>{if(s){var a=s.data.expireAfter,r=s.data.userName;let i=new Date;i.setTime(i.getTime()+1e3*a),c.a.remove(this.config.COOKIE_NAME_TOKEN,{path:"/"}),c.a.save(this.config.COOKIE_NAME_TOKEN,e,{path:"/",d:i,maxAge:a}),c.a.save(this.config.COOKIE_NAME_LOGIN_USER_NAME,r,{path:"/",d:i,maxAge:a}),window.sessionStorage.setItem(this.config.COOKIE_NAME_TOKEN,e),this.loadBrief(t)}else this.dataService.removeUserData(),this.state.errors.error=!0,this.state.errors.errorMessage=this.config.MESSAGE_AUTH_FAILED,this.setState({loading:!1})})}loadBrief(e){this.dataService.retrieve(this.config.SERVICE_NAME_USER,this.config.SERVICE_ACTION_USER_BRIEF).then(t=>{t?(this.dataService.storeCurrentUserData(t.success?t.data:null),this.loadAuthorities(e)):(this.dataService.removeUserData(),this.state.errors.error=!0,this.state.errors.errorMessage=this.config.MESSAGE_AUTH_FAILED,this.setState({loading:!1}))})}loadAuthorities(e){this.dataService.retrieve(this.config.SERVICE_NAME_USER,this.config.SERVICE_ACTION_USER_ROLE_CHECK).then(t=>{if(t){var s=t.data.authorities;window.sessionStorage.setItem(this.config.COOKIE_NAME_AUTH,s),this.userData=this.dataService.getCurrentUserData(),"Employee"===this.userData.roleName?window.location.href="/deman_detail/"+this.userData.guid+"/"+this.userData.name+"/"+this.userData.personId+"/0":"OS"===this.userData.roleName?this.loadPOSPrivilege(e):window.location.href="/organization_admin_dashboard"}else this.dataService.removeUserData(),this.state.errors.error=!0,this.state.errors.errorMessage=this.config.MESSAGE_AUTH_FAILED,this.setState({loading:!1})})}loadPOSPrivilege(e){this.dataService.retrieve(this.config.SERVICE_NAME_SETTINGS,this.config.SERVICE_ACTION_SETTINGS_LOCAL_GET_BY_NAME+"allow_pos?merchantGuid="+this.userData.guid).then(t=>{t&&t.success&&(this.dataService.setCurrentUserPOSPrivilege(t.success?t.data:null),this.userData=this.dataService.getCurrentUserData(),"true"===t.data.value?window.location.href="pos"===e?"/pos_report_order":"/"+e:window.location.href="/merchant_detail/"+this.userData.guid+"/"+this.userData.name+"/"+this.userData.personId+"/0")})}}t.default=e=>{const{t:t,i18n:s}=Object(g.a)();return r.a.createElement(l,Object.assign({lang:t,i18n:s,props:!0},e))}}}]);
//# sourceMappingURL=159.bab8accc.chunk.js.map