Replaced remaining parts of app to use Redux.
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user