27 lines
664 B
JavaScript
27 lines
664 B
JavaScript
import React from "react";
|
|
import PropTypes from "prop-types";
|
|
import { connect } from "react-redux";
|
|
import { Redirect } from "react-router-dom";
|
|
|
|
import { userLogout } from "../../actions/users";
|
|
|
|
const mapStateToProps = state => ({
|
|
isLogged: state.userStore.get("isLogged")
|
|
});
|
|
const mapDispatchToProps = { userLogout };
|
|
|
|
const UserLogout = props => {
|
|
if (props.isLogged) {
|
|
props.userLogout();
|
|
}
|
|
|
|
return <Redirect to="/users/login" />;
|
|
};
|
|
UserLogout.propTypes = {
|
|
isLogged: PropTypes.bool.isRequired,
|
|
userLogout: PropTypes.func.isRequired,
|
|
history: PropTypes.object
|
|
};
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(UserLogout);
|