BREAKING CHANGES: Converted to use Redux stores. Login now working using Redux.

This commit is contained in:
Patrick Fic
2020-01-31 13:20:15 -08:00
parent f1ac052a1b
commit 3060c16dd3
26 changed files with 628 additions and 360 deletions

View File

@@ -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>
);
}
});