import Button from '@material-ui/core/Button'; import Card from '@material-ui/core/Card'; import CardContent from '@material-ui/core/CardContent'; import { makeStyles } from '@material-ui/core/styles'; import CloudUploadIcon from '@material-ui/icons/CloudUpload'; import { useEffect, useState } from 'react'; import { makeAPIPostCall, makeAPIGetCall } from '../api/utils'; import { useHistory } from 'react-router-dom'; import PlacesAutocomplete from 'react-places-autocomplete'; const useStyles = makeStyles((theme) => ({ root: { maxWidth: 345, }, media: { height: 140, }, button: { margin: theme.spacing(1), }, })); const CreatePool = ({ groupID }: { groupID?: string }) => { const history = useHistory(); const [title, setTitle] = useState('No Title'); const [capacity, setCapacity] = useState(0); const [start, setStart] = useState(''); const [end, setEnd] = useState(''); const [direction, setDirection] = useState('pickup'); const [type, setType] = useState('offer'); const [description, setDescription] = useState(''); const classes = useStyles(); const [group, setGroup] = useState(''); const [groups, setGroups] = useState([]); const [address, setAddress] = useState(''); const handleChange = (address: string) => { setAddress(address); }; const handleSelect = (address: string) => { setAddress(address); // geocodeByAddress(address) // .then((results) => getLatLng(results[0])) // .then((latLng) => console.log('Success', latLng)) // .catch((error) => console.error('Error', error)); }; const onClick = () => { console.log(address); makeAPIPostCall('/pools/', { title, description, start_time: start, end_time: end, capacity, direction, type, group_id: group, address, }).then((res) => { handleCallback(res.data); }); }; const handleCallback = (res: any) => { if (res.status === 'error') { alert('There was a problem with your form!'); } else { history.push('/profile'); } }; useEffect(() => { makeAPIGetCall('/users/@me/groups').then((res) => { if (res.data.data) setGroups(res.data.data); }); }, []); return (

Create Pool

setTitle(event.target.value)} >
setCapacity(parseInt(event.target.value))} >
setStart(event.target.value)} >
setEnd(event.target.value)} >