Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useState } from 'react'
  2.  
  3. // Components
  4. import Autosuggest from '../Utils/Autosuggest'
  5. import GooglePlacesAutocomplete from '../Utils/GooglePlacesAutocomplete'
  6. import Results from '../Utils/Results'
  7.  
  8. // types
  9. export type Place = {
  10.   name?: string
  11.   lat?: number
  12.   lng?: number
  13. }
  14.  
  15. // context
  16. export const PlaceContext = React.createContext<Place | null>(null)
  17.  
  18. const ClubSearch = () => {
  19.   const [place, setPlace] = useState<Place>({})
  20.   const [sport, setSport] = React.useState<string | null>(null)
  21.  
  22.   const handleSubmit = (e: React.FormEvent) => {
  23.     e.preventDefault()
  24.   }
  25.  
  26.   const handleReset = () => setSport(null)
  27.  
  28.   return (
  29.     <PlaceContext.Provider value={place}>
  30.       <form onSubmit={handleSubmit} autoComplete="off">
  31.         <Autosuggest
  32.           suggestions={sports}
  33.           label="Find an activity"
  34.           placeholder="Maybe surfing?"
  35.           onSelect={setSport}
  36.           onReset={handleReset}
  37.         />
  38.         <GooglePlacesAutocomplete label="In" setPlace={setPlace} />
  39.         <Results sport={sport} />
  40.       </form>
  41.     </PlaceContext.Provider>
  42.   )
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement