import React, {Component} from 'react'
import classNames from 'classnames/bind'
import Geosuggest from 'react-geosuggest'

const cx = classNames.bind(require('../styles/address_picker.scss'))

const AddressPicker = (props) => (
  window.google !== undefined ? (
    <Geosuggest
      initialValue={props.initial_query}
      className={cx('address-picker')}
      placeholder={"Adresse"}
      onSuggestSelect={props.on_place_select}
      onBlur={(value) => {
        if (!value) {
          props.on_clear_place_input()
        }
      }}
      location={new google.maps.LatLng(48.85341, 2.3488)}
      radius={300}
      />
  ) : null
)

export default AddressPicker
