{"size": 790, "ext": "js", "max_stars_repo_path": "forgettable-frontend/src/components/AutocompleteLocationInput/AutocompleteLocationInput.js", "max_stars_repo_name": "Dj5822/Forgettable", "max_stars_repo_stars_event_min_datetime": "2022-03-08T06:05:01.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T15:04:55.000Z", "max_issues_repo_path": "forgettable-frontend/src/components/AutocompleteLocationInput/AutocompleteLocationInput.js", "max_issues_repo_name": "Dj5822/Forgettable", "max_issues_repo_issues_event_min_datetime": "2022-03-05T01:07:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T06:45:38.000Z", "max_forks_repo_path": "forgettable-frontend/src/components/AutocompleteLocationInput/AutocompleteLocationInput.js", "max_forks_repo_name": "Dj5822/Forgettable", "max_forks_repo_forks_event_min_datetime": "2022-03-05T02:11:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T22:45:16.000Z"}
{"max_stars_count": 9, "max_issues_count": 215, "max_forks_count": 52, "avg_line_length": 28.2142857143, "max_line_length": 78, "alphanum_fraction": 0.6202531646}
import React, {useState} from 'react';
import classes from './AutocompleteLocationInput.module.css';
import Autocomplete from 'react-google-autocomplete';

export default function AutocompleteLocationInput({setLocation, setLatLong}) {
  return (
    <Autocomplete
      apiKey={process.env.REACT_APP_MAPS_API_KEY}
      options={{
        componentRestrictions: {country: 'nz'},
        types: ['establishment'],
        fields: ['name', 'geometry.location'],
      }}
      onChange={(event) => {
        setLocation(event.target.value);
      }}
      className={classes.InputBox}
      onPlaceSelected={(place) => {
        setLocation(place.name);
        setLatLong([
          place.geometry.location.lat(),
          place.geometry.location.lng(),
        ]);
      }}
    />
  );
}
