resolve warnings

This commit is contained in:
Mario Pesch
2022-02-18 12:20:22 +01:00
parent a34e0bbb5d
commit 8620a452a3
13 changed files with 492 additions and 465 deletions
+23 -26
View File
@@ -1,44 +1,41 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Route, Redirect, withRouter } from 'react-router-dom';
import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { Route, Redirect, withRouter } from "react-router-dom";
class PrivateRoute extends Component {
render() {
return (
!this.props.progress ?
return !this.props.progress ? (
<Route
{...this.props.exact}
render={({ location }) =>
this.props.isAuthenticated ? (
this.props.children
) : (()=>{
return (
<Redirect
to={{
pathname: "/user/login",
state: { from: location }
}}
/>
)
})()
this.props.isAuthenticated
? this.props.children
: (() => {
return (
<Redirect
to={{
pathname: "/user/login",
state: { from: location },
}}
/>
);
})()
}
/> : null
);
/>
) : null;
}
}
PrivateRoute.propTypes = {
isAuthenticated: PropTypes.bool.isRequired,
progress: PropTypes.bool.isRequired
isAuthenticated: PropTypes.bool,
progress: PropTypes.bool.isRequired,
};
const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
isAuthenticated: state.auth.isAuthenticated,
progress: state.auth.progress
progress: state.auth.progress,
});
export default connect(mapStateToProps, null)(withRouter(PrivateRoute));