text: import React, { Component } from "react";
  import axios from "axios";
  
  class Login extends Component {
    state = {
      email: "",
      password: "",
      loginErrors: "",
    };
    handleSubmit = (e) => {
      e.preventDefault();
  
      axios
        .post(
          "http://localhost:5000/sessions",
          {
            user: {
              email: this.state.email,
              password: this.state.password,
            },
          },
          { withCredentials: true }
        )
        .then((response) => {
          if (response.data.logged_in) {
            this.props.handleSuccessfulAuth(response.data);
          }
        })
        .catch((error) => {
          console.log("Login error:", error);
        });
    };
  
    handleChange = (e) => {
      this.setState({
        [e.target.name]: e.target.value,
      });
    };
  
    render() {
      return (
        <div>
          <form onSubmit={this.handleSubmit}>
            <input
              type="email"
              name="email"
              placeholder="Email"
              value={this.state.email}
              onChange={this.handleChange}
              required
            />
  
            <input
              type="password"
              name="password"
              placeholder="Password"
              value={this.state.password}
              onChange={this.handleChange}
              required
            />
  
            <button type="submit">Login</button>
          </form>
        </div>
      );
    }
  }
  
  export default Login;
  