text: import React, { Component } from 'react';
  import { Mutation } from 'react-apollo';
  import gql from 'graphql-tag';
  import Form from './reuseStyles/Form';
  import Error from './ErrorMessage';
  import { CURRENT_USER_QUERY } from './User';
  
  const SIGNIN_MUTATION = gql`
    mutation SIGNIN_MUTATION($email: String!, $password: String!) {
      signin(email: $email, password: $password) {
        id
        email
        name
      }
    }
  `;
  
  class Signin extends Component {
    state = {
      name: '',
      password: '',
      email: '',
    };
    saveToState = e => {
      this.setState({ [e.target.name]: e.target.value });
    };
    render() {
      return (
        <Mutation
          mutation={SIGNIN_MUTATION}
          variables={this.state}
          refetchQueries={[{ query: CURRENT_USER_QUERY }]}
        >
          {(signup, { error, loading }) => (
            <Form
              method="post"
              onSubmit={async e => {
                e.preventDefault();
                await signup();
                this.setState({ name: '', email: '', password: '' });
              }}
            >
              <fieldset disabled={loading} aria-busy={loading}>
                <h2>Войти в личный кабинет</h2>
                <Error error={error} />
                <label htmlFor="email">
                  Адрес электронной почты
                  <input
                    type="email"
                    name="email"
                    placeholder="email"
                    value={this.state.email}
                    onChange={this.saveToState}
                  />
                </label>
                <label htmlFor="password">
                  Пароль
                  <input
                    type="password"
                    name="password"
                    placeholder="password"
                    value={this.state.password}
                    onChange={this.saveToState}
                  />
                </label>
  
                <button type="submit">Войти</button>
              </fieldset>
            </Form>
          )}
        </Mutation>
      );
    }
  }
  
  export default Signin;
  