{"size": 1922, "ext": "js", "max_stars_repo_path": "client/src/components/NavbarSearch.js", "max_stars_repo_name": "travisstew/real-estate-app", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/src/components/NavbarSearch.js", "max_issues_repo_name": "travisstew/real-estate-app", "max_issues_repo_issues_event_min_datetime": "2021-05-11T07:59:29.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-11T07:59:29.000Z", "max_forks_repo_path": "client/src/components/NavbarSearch.js", "max_forks_repo_name": "travisstew/real-estate-app", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 29.5692307692, "max_line_length": 157, "alphanum_fraction": 0.5156087409}
import React, { Component } from 'react';
import Navbar from 'react-bootstrap/Navbar';
import Nav from 'react-bootstrap/Nav';
import logo from '../images/logo.png';
import { withRouter} from 'react-router-dom';


class NavbarSearch extends Component {
  state = { 
    location:'',
    state:'',
   }

   handleChange =(e)=>{
    this.setState({
          [e.target.name]: e.target.value
    });  
   }

   handleSubmit = (e)=>{
    e.preventDefault();
    // console.log(this.state.location);
    this.props.history.push({
      pathname: '/listing',
      search: '',
      state: { city: this.state.location, newState: this.state.state }
    });
    window.location.reload();
  }
   

  render() { 
      return ( 
          <>
           <Navbar className="navbar-bac text-white" expand="lg">
            <Navbar.Brand href="/" id="home" className="new-font">
            <img
                alt=""
                src={logo}
                width="30"
                height="30"
                className="d-inline-block align-top"
              />{' '}
            Real Estate</Navbar.Brand>
            <Navbar.Toggle aria-controls="basic-navbar-nav" />
            <Navbar.Collapse id="basic-navbar-nav">
              <Nav className="ml-auto">
                  <form onSubmit={this.handleSubmit} class="form-inline">
                    <input  type="text" name="location" value={this.state.location} onChange={this.handleChange} class="form-control" placeholder="Search" />
                    <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
                  </form>
                {/* <Nav.Link href="/">Home</Nav.Link> */}
                {/* <Nav.Link href="#link">Link</Nav.Link> */}
             
              </Nav>
            
             </Navbar.Collapse>
          </Navbar>
          </> 
          
      );
  }
}
 
export default withRouter( NavbarSearch);