In progress changes for ensuring that new clients are written to the database.
This commit is contained in:
@@ -2,6 +2,7 @@ import React from "react";
|
||||
import { auth } from "../../firebase/firebase.utils";
|
||||
import { Form, Icon, Input, Button, Alert } from "antd";
|
||||
|
||||
import { UPSERT_USER } from "../../graphql/user.queries";
|
||||
class SignInForm extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
@@ -12,11 +13,27 @@ class SignInForm extends React.Component {
|
||||
|
||||
handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
const { apolloClient } = this.props;
|
||||
|
||||
this.props.form.validateFields(async (err, values) => {
|
||||
if (!err) {
|
||||
const { email, password } = values;
|
||||
try {
|
||||
await auth.signInWithEmailAndPassword(email, password);
|
||||
const { user } = await auth.signInWithEmailAndPassword(
|
||||
email,
|
||||
password
|
||||
);
|
||||
|
||||
apolloClient
|
||||
.mutate({
|
||||
mutation: UPSERT_USER,
|
||||
variables: { authEmail: user.email, authToken: user.uid }
|
||||
})
|
||||
.then(r => console.log("Successful Upsert", r))
|
||||
.catch(error => {
|
||||
console.log("Upsert error!!!!", error);
|
||||
});
|
||||
|
||||
this.props.form.resetFields();
|
||||
} catch (error) {
|
||||
this.setState({ ...this.state, errorMessage: error.message });
|
||||
@@ -28,6 +45,7 @@ class SignInForm extends React.Component {
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
const { errorMessage } = this.state;
|
||||
|
||||
return (
|
||||
<Form onSubmit={this.handleSubmit} className="login-form">
|
||||
<Form.Item label="E-mail">
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import React from "react";
|
||||
import { ApolloConsumer } from "react-apollo";
|
||||
import SignInFormComponent from "./sign-in-form.component";
|
||||
|
||||
export default function SignInFormContainer() {
|
||||
return (
|
||||
<ApolloConsumer>
|
||||
{client => {
|
||||
return <SignInFormComponent apolloClient={client} />;
|
||||
}}
|
||||
</ApolloConsumer>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from "react";
|
||||
import firebase from "../../firebase/firebase.utils";
|
||||
|
||||
export default function SignOut() {
|
||||
export default function SignOut({ match }) {
|
||||
const signOut = async () => {
|
||||
try {
|
||||
await firebase.auth().signOut();
|
||||
console.log("Signin out!");
|
||||
console.log("match", match);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user