From 9f8904d020fdc4cb5fa3d7f27a4a1e981c60624f Mon Sep 17 00:00:00 2001 From: Mick Thompson Date: Thu, 19 Sep 2019 17:16:39 -0700 Subject: [PATCH 1/2] what does loading all events look like --- src/App.js | 9 ++++----- src/Map.js | 27 +++++++++++++-------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/App.js b/src/App.js index f2fb760..113d33c 100644 --- a/src/App.js +++ b/src/App.js @@ -15,17 +15,16 @@ function App() { //Makes API call when zipcode entered useEffect(() => { - if(currZip != null){ - fetch("https://api.mobilize.us/v1/organizations/1316/events?timeslot_start=gte_now&zipcode=" + currZip) + + fetch("https://gist.githubusercontent.com/mick/6c85985bbaee7419b6351501edd05de0/raw/f41482f485d3390516c390180c841c25b4213987/events.json") .then((res)=>res.json()) - .then((data)=>setEvents(data['data'])); + .then((data)=>setEvents(data)); //Reset states on new zipcode setHoverEvent(null); setLocFilt(null); - } - }, [currZip]); + }, []); return (
diff --git a/src/Map.js b/src/Map.js index 7d4e20a..80427d0 100644 --- a/src/Map.js +++ b/src/Map.js @@ -14,7 +14,6 @@ export function Map(props){ //Called to set/unset location filter function locationFilter(event, set){ - console.log(event) if(set){ props.selectLoc({ @@ -109,27 +108,27 @@ export function Map(props){ if(props.events != null){ //Initiates map's focus at the first event (typically the closest to the provided zipcode) with a valid lat & long position - let first = 0; - if (!('location' in props.events[first]) || !('location' in props.events[first]['location']) || !('latitude' in props.events[first]['location']['location'])) { - first++; - } + // let first = 0; + // if (!('location' in props.events[first]) || !('location' in props.events[first]['location']) || !('latitude' in props.events[first]['location']['location'])) { + // first++; + // } - var lat = props.events[first]['location']['location']['latitude']; - var long = props.events[first]['location']['location']['longitude']; + // var lat = props.events[first]['location']['location']['latitude']; + // var long = props.events[first]['location']['location']['longitude']; - if(center[0] !== lat || center[0] !== long){ - setCenter([lat, long]); - setNewCenter(true); - } + // if(center[0] !== lat || center[0] !== long){ + // setCenter([lat, long]); + // setNewCenter(true); + // } var places = {}; props.events.forEach(function(event, index) { - + if (index > 500) return; //If has longitude and latitute if ('location' in event && 'location' in event['location'] && 'latitude' in event['location']['location']) { - //Creates string key for {places} dictionary + //Creates string key for {places} dictionary let str = event['location']['location']['latitude'] + "&" + event['location']['location']['longitude']; //Creates or adds to a location - adds HTML code for event list for that location if (str in places) { @@ -139,7 +138,7 @@ export function Map(props){ } } - }); + }); setLocations(places); } From e05361dcfea79375323284e30394c9a4723119b5 Mon Sep 17 00:00:00 2001 From: Mick Thompson Date: Mon, 30 Sep 2019 12:44:10 -0700 Subject: [PATCH 2/2] use S3 path now that its being updated hourly --- src/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index 113d33c..6a29bc7 100644 --- a/src/App.js +++ b/src/App.js @@ -16,7 +16,7 @@ function App() { //Makes API call when zipcode entered useEffect(() => { - fetch("https://gist.githubusercontent.com/mick/6c85985bbaee7419b6351501edd05de0/raw/f41482f485d3390516c390180c841c25b4213987/events.json") + fetch("https://warren-events.s3.amazonaws.com/data/events.json") .then((res)=>res.json()) .then((data)=>setEvents(data));