BREAKING CHANGES: Converted to use Redux stores. Login now working using Redux.
This commit is contained in:
@@ -4,18 +4,23 @@ import { Link } from "react-router-dom";
|
||||
import { GET_CURRENT_USER } from "../../graphql/local.queries";
|
||||
import { Icon } from "antd";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
||||
|
||||
export default function ManageSignInButton() {
|
||||
const {
|
||||
loading,
|
||||
error,
|
||||
data: { currentUser }
|
||||
} = useQuery(GET_CURRENT_USER);
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser
|
||||
});
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return error.message;
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
// signOutStart: () => dispatch(signOutStart())
|
||||
});
|
||||
|
||||
return currentUser ? (
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(function ManageSignInButton({ currentUser }) {
|
||||
return currentUser.isAuthorized ? (
|
||||
<div>
|
||||
{" "}
|
||||
<Link to="/manage">
|
||||
@@ -31,4 +36,4 @@ export default function ManageSignInButton() {
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user