<commit_before>/* global window */
import React, { Component } from 'react';

import Title from '../Title';
import { Form, Label, Input, Button } from '../Form';
import api from '../../utils/api';

import './index.css';

class Login extends Component {
  constructor(...props) {
    super(...props);

    this.state = {
      isValid: false,
    };
  }

  login(body) {
    api.post('/auth', body).then(({ data }) => {
      // TODO: make an easier jwt token manager
      window.localStorage.setItem('jwt.token', data.token);
      window.location = '/';
    });
  }

  render() {
    const { isValid } = this.state;

    return (
      <div className="Login">
        <Title name="Login" />
        <div className="Login__Wrapper">
          <Form
            onValidationChange={valid => this.setState({ isValid: valid })}
            onSubmit={data => this.login(data)}
          >
            <Label text="Email address" />
            <Input name="email" rules={['required', 'email']} />

            <Label text="Password" />
            <Input name="password" type="password" rules={['required']} />

            <Button disabled={!isValid}>Login</Button>
          </Form>
        </div>
      </div>
    );<commit_msg>add Header to Login screen<commit_after>/* global window */
import React, { Component } from 'react';

import Title from '../Title';
import Header from '../Header';
import { Form, Label, Input, Button } from '../Form';
import api from '../../utils/api';

import './index.css';

class Login extends Component {
  constructor(...props) {
    super(...props);

    this.state = {
      isValid: false,
    };
  }

  login(body) {
    api.post('/auth', body).then(({ data }) => {
      // TODO: make an easier jwt token manager
      window.localStorage.setItem('jwt.token', data.token);
      window.location = '/';
    });
  }

  render() {
    const { isValid } = this.state;

    return (
      <div>
        <Header />
        <div className="Login">
          <Title name="Login" />
          <div className="Login__Wrapper">
            <Form
              onValidationChange={valid => this.setState({ isValid: valid })}
              onSubmit={data => this.login(data)}
            >
              <Label text="Email address" />
              <Input name="email" rules={['required', 'email']} />

              <Label text="Password" />
              <Input name="password" type="password" rules={['required']} />

              <Button disabled={!isValid}>Login</Button>
            </Form>
          </div>
        </div>
      </div>
    );
{'fraction_non_alphanumeric': 0.17553398058252428, 'fraction_numerical': 0.0, 'mean_word_length': 2.030588235294118, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4723948', 'n_tokens_mistral': 733, 'n_tokens_neox': 726, 'n_words': 179}