Replaced remaining parts of app to use Redux.

This commit is contained in:
Patrick Fic
2020-01-31 13:57:27 -08:00
parent 3060c16dd3
commit e2518a95ab
12 changed files with 104 additions and 168 deletions

View File

@@ -1,14 +1,13 @@
import { Button, Form, Icon, Input } from "antd";
import React from "react";
import { useApolloClient } from "react-apollo";
import { connect } from "react-redux";
import { Redirect } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import Logo from "../../assets/logo240.png";
import { UPSERT_USER } from "../../graphql/user.queries";
import { emailSignInStart } from "../../redux/user/user.actions";
import {
selectCurrentUser,
selectSignInError
} from "../../redux/user/user.selectors";
import { Redirect } from "react-router-dom";
import { selectCurrentUser, selectSignInError } from "../../redux/user/user.selectors";
const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser,
@@ -30,6 +29,8 @@ export default connect(
currentUser,
signInError
}) {
const apolloClient = useApolloClient();
const handleSubmit = e => {
e.preventDefault();
form.validateFields(async (err, values) => {
@@ -41,7 +42,21 @@ export default connect(
});
};
console.log("currentUser", currentUser);
if (currentUser.authorized === true) {
apolloClient
.mutate({
mutation: UPSERT_USER,
variables: {
authEmail: currentUser.email,
authToken: currentUser.uid
}
})
.then()
.catch(error => {
console.log("User login upsert error.", error);
});
}
const { getFieldDecorator } = form;
return (
<div>