Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dist/assets/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
body {
background-color: #fff;
margin: 0;
padding: 0;
}
section {
margin: 0;
paddin: 0;
}

38 changes: 38 additions & 0 deletions dist/bundle.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8" />
<title>React Base</title>
<link href="assets/main.css" rel="stylesheet"></head>
<body>
<div id="app"></div>
<script type="text/javascript" src="bundle.js"></script></body>
</html>
16 changes: 9 additions & 7 deletions locations.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"locations": [
{
"venueLat": 19.42672619,
"venueLon": -99.1718706,
"venueName": "Platzi HQ CDMX"
"id": 1,
"Lat": 19.42672619,
"Lng": -99.1718706,
"title": "Platzi HQ CDMX"
},
{
"venueLat": 4.6560716,
"venueLon": -74.0595918,
"venueName": "Platzi HQ Bogota"
"id": 2,
"Lat": 4.6560716,
"Lng": -74.0595918,
"title": "Platzi HQ Bogota"
}
]
}
}
138 changes: 130 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"css-loader": "^3.2.0",
"google-maps-react": "^2.0.2",
"google-maps-react": "^2.0.6",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.7.0",
"react": "^16.10.1",
"react-dom": "^16.10.1",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"redux": "^4.0.5",
"style-loader": "^0.23.1",
"stylus": "^0.54.7",
"stylus-loader": "^3.0.2",
Expand All @@ -58,4 +61,4 @@
"url": "https://github.com/gndx/react-challenge-01/issues"
},
"homepage": "https://github.com/gndx/react-challenge-01#readme"
}
}
13 changes: 13 additions & 0 deletions src/Hooks/useInitialState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useState, useEffect } from 'react';

const useInitialState = (API) => {
const [items, setItems] = useState([]);
useEffect(() => {
fetch(API)
.then(res => res.json())
.then(response => {setItems(response);});
}, []);
return items
}

export default useInitialState;
7 changes: 7 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// eslint-disable-next-line import/prefer-default-export
export const ShowMap = (payload) => ({
type: 'SHOW_MAP',
payload,
});


49 changes: 37 additions & 12 deletions src/components/MapContainer.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
import React from 'react';
import { Map, GoogleApiWrapper, Marker } from 'google-maps-react';
import { connect } from 'react-redux';

const MapContainer = ({ google }) => {
import './styles/ButtonMap.css'

import {ShowMap} from '../actions'

const MapContainer = (props) => {
const {locations, show, google} = props
console.log({locations})

const handleShowMap = () => {
props.ShowMap()
}
return (
<Map
google={google}
zoom={5}
initialCenter={{ lat: 19.5943885, lng: -97.9526044 }}
>
<Marker
position={{ lat: 19.4267261, lng: -99.1718706 }}
/>
</Map>
<>
<button type='button' onClick={handleShowMap}>Show Map</button>
{show === true ? (
<Map
google={google}
zoom={5}
initialCenter={{ lat: 19.5943885, lng: -97.9526044 }}
>
{locations.map((item) => (
<Marker
key={item.id}
name={item.title}
position={{lat: item.Lat, lng: item.Lng}}
/>
))}
</Map>
) :
null}
</>
);
}

export default GoogleApiWrapper({
const mapDispatchToProps = {
ShowMap,
};

export default connect(null, mapDispatchToProps)(GoogleApiWrapper({
apiKey: 'AIzaSyCmjvkXB_DMnBUNwxQztLMStyQmA_szbNw'
})(MapContainer);
})(MapContainer));
7 changes: 7 additions & 0 deletions src/components/styles/ButtonMap.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
button {
background: #fff;
border: 1px solid#000;
border-radius: 2px;
width: 100%;
height: 30px;
}
Loading