forgeplus-react/src/common/components/LinkAfterLogin.js

31 lines
651 B
JavaScript
Raw Normal View History

2020-03-16 14:12:11 +08:00
import React, { Component } from 'react';
// 登录后才能跳转
class LinkAfterLogin extends Component {
constructor(props) {
super(props);
}
2020-04-28 17:23:34 +08:00
checkAuth = () => {
if (this.props.checkIfLogin()) {
if (this.props.checkProfileComplete) {
if (this.props.checkIfProfileCompleted()) {
this.props.history.push(this.props.to)
} else {
this.props.showProfileCompleteDialog();
}
} else {
this.props.history.push(this.props.to)
}
} else {
this.props.showLoginDialog()
}
}
2020-03-16 14:12:11 +08:00
render() {
2020-04-28 17:23:34 +08:00
return (
2020-03-16 14:12:11 +08:00
<a {...this.props} onClick={this.checkAuth}>{this.props.children}</a>
)
}
}
export default LinkAfterLogin;