From 9f8c0cba66821526e54ce594c6e009bcbcfb4836 Mon Sep 17 00:00:00 2001 From: Michael Fatemi Date: Sat, 10 Apr 2021 22:21:33 -0400 Subject: [PATCH] Add Google query thing --- src/api/google.ts | 5 +- src/components/Authenticator.tsx | 1 - src/components/CreateGroup.tsx | 7 +- src/components/CreatePool.tsx | 255 +++++++++++++++++-------------- src/components/UpdatePool.tsx | 7 +- 5 files changed, 145 insertions(+), 130 deletions(-) diff --git a/src/api/google.ts b/src/api/google.ts index 4256111..fea6950 100644 --- a/src/api/google.ts +++ b/src/api/google.ts @@ -7,9 +7,12 @@ export async function searchForPlaces(query: string) { url.searchParams.set('key', GOOGLE_MAPS_API_KEY); url.searchParams.set('input', query); url.searchParams.set('inputtype', 'textquery'); + url.searchParams.set('fields', 'place_id,name,formatted_address'); - let res = await fetch(url.toString()); + let res = await fetch(url.toString(), { mode: 'no-cors' }); let json = await res.json(); return json; } + +console.log(searchForPlaces); diff --git a/src/components/Authenticator.tsx b/src/components/Authenticator.tsx index c7ca7ef..ed07392 100644 --- a/src/components/Authenticator.tsx +++ b/src/components/Authenticator.tsx @@ -1,6 +1,5 @@ import { useContext, useEffect, useState } from 'react'; import { Redirect, useLocation, useParams } from 'react-router-dom'; -import { API_ENDPOINT } from '../api/api'; import { makeAPIPostCall } from '../api/utils'; import AuthenticationContext from './AuthenticationContext'; diff --git a/src/components/CreateGroup.tsx b/src/components/CreateGroup.tsx index 2f8d789..c51feec 100644 --- a/src/components/CreateGroup.tsx +++ b/src/components/CreateGroup.tsx @@ -1,12 +1,11 @@ -import { useCallback } from 'react'; -import { makeAPIPostCall } from '../api/utils'; +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 Button from '@material-ui/core/Button'; import Typography from '@material-ui/core/Typography'; -import { useState, useEffect } from 'react'; import CloudUploadIcon from '@material-ui/icons/CloudUpload'; +import { useState } from 'react'; +import { makeAPIPostCall } from '../api/utils'; const useStyles = makeStyles((theme) => ({ root: { diff --git a/src/components/CreatePool.tsx b/src/components/CreatePool.tsx index e3e10b3..b96a59a 100644 --- a/src/components/CreatePool.tsx +++ b/src/components/CreatePool.tsx @@ -6,6 +6,7 @@ import Button from '@material-ui/core/Button'; import Typography from '@material-ui/core/Typography'; import CloudUploadIcon from '@material-ui/icons/CloudUpload'; import { useState, useEffect } from 'react'; +import { searchForPlaces } from '../api/google'; const useStyles = makeStyles((theme) => ({ root: { maxWidth: 345, @@ -51,125 +52,143 @@ const CreatePool = () => { -
-
-

- Create Pool -

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