diff --git a/package-lock.json b/package-lock.json
index 87f4dc9..1dbd6d7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1513,6 +1513,26 @@
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz",
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw=="
},
+ "@react-google-maps/api": {
+ "version": "1.10.1",
+ "resolved": "https://registry.npmjs.org/@react-google-maps/api/-/api-1.10.1.tgz",
+ "integrity": "sha512-hb8urUcwZw99Cu3yQnZWUbXjR1Ym/8C21kSX6B02I29l6DXNxDbJ5Jo/T5swhnizPKY7TNhR1oTctC/HY7SQWA==",
+ "requires": {
+ "@react-google-maps/infobox": "1.10.0",
+ "@react-google-maps/marker-clusterer": "1.10.0",
+ "invariant": "2.2.4"
+ }
+ },
+ "@react-google-maps/infobox": {
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/@react-google-maps/infobox/-/infobox-1.10.0.tgz",
+ "integrity": "sha512-MhT2nMmjeG7TCxRv/JdylDyNd/n66ggSQQhTWVjJJTtdB/xqd0T8BHCkBWDN9uF0i0yCZzMFl2P2Y1zJ+xppBg=="
+ },
+ "@react-google-maps/marker-clusterer": {
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/@react-google-maps/marker-clusterer/-/marker-clusterer-1.10.0.tgz",
+ "integrity": "sha512-3GLVgeXNStVcdiLMxzi3cBjr32ctlexLPPGQguwcYd6yPLaCcnVCwyzhV68KvL00xqOAD1c3aABV9EGgY8u6Qw=="
+ },
"@sheerun/mutationobserver-shim": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.3.tgz",
diff --git a/package.json b/package.json
index 84f1acc..fd660c4 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@material-ui/pickers": "^3.2.10",
+ "@react-google-maps/api": "^1.10.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
diff --git a/src/App.js b/src/App.js
index 6764f00..535630e 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,5 +1,6 @@
import React from "react";
import { Router, Switch, Route } from "react-router-dom";
+import PrivateRoute from "./components/PrivateRoute";
import "./App.scss";
import TopBar from "./components/TopBar";
import LogoMain from "./components/Output/logoMain";
@@ -61,9 +62,11 @@ function App(props) {
-
-
-
+ }
+ />
+ } />
diff --git a/src/components/Dialogs/NewRestaurant.js b/src/components/Dialogs/NewRestaurant.js
index 84532ae..a1ec7c1 100644
--- a/src/components/Dialogs/NewRestaurant.js
+++ b/src/components/Dialogs/NewRestaurant.js
@@ -17,6 +17,8 @@ import InputAdornment from "@material-ui/core/InputAdornment";
import ImageUpload from "../Input/ImageUpload";
import validator from "validator";
import { useHistory } from "react-router-dom";
+import InputGoogleMaps from "../Input/InputGoogleMaps";
+import InfoDialog from "../Output/InfoDialog";
// ICONS
import FastfoodIcon from "@material-ui/icons/Fastfood";
import LocationCityIcon from "@material-ui/icons/LocationCity";
@@ -89,6 +91,9 @@ export default function NewRestaurant() {
name: "",
city: "",
adress: "",
+ coordinates: [52.354293, 19.42377],
+ placesId: "",
+ imgURL: "",
hoursFrom: "07:00",
hoursTo: "23:00",
description: "",
@@ -102,6 +107,8 @@ export default function NewRestaurant() {
adressError: false,
descriptionError: false,
charLeft: 400,
+ open: true,
+ response: "",
};
const steps = ["Informacje", "Zdjęcie", "Lokalizacja"];
const [state, setState] = useState(initialState);
@@ -120,14 +127,58 @@ export default function NewRestaurant() {
// HANDLERS
- const handleNextButton = () => {
- if (activeStep === 0) {
- if (validateForm()) {
- setActiveStep(1);
- }
+ const sendForm = () => {
+ // format tags
+ const formattedTags;
+ const data = {
+ name: state.name,
+ city: state.city,
+ adress: state.adress,
+ coordinates: state.coordinates,
+ placesId: state.placesId,
+ imgURL: state.imgURL,
+ workingHours: `${state.hoursFrom} - ${state.hoursTo}`,
+ description: state.description,
+ tags: formattedTags,
+ links: {},
+ phone: request.phone,
+ hidden: request.hidden,
}
};
+ const setCoordinatesAndPlacesID = (coordinates, placesID) => {
+ if (!placesID) {
+ setState({ ...state, coordinates: coordinates });
+ } else {
+ setState({ ...state, coordinates: coordinates, placesId: placesID });
+ }
+ };
+
+ const handleNextButton = () => {
+ switch (activeStep) {
+ case 0:
+ if (validateForm()) {
+ setActiveStep(1);
+ }
+ break;
+ case 1:
+ if (!validator.isEmpty(state.imgURL)) {
+ setActiveStep(2);
+ }
+ break;
+ case 2:
+ setState({ ...state, open: false });
+ sendForm();
+ break;
+ default:
+ break;
+ }
+ };
+
+ const handleImageUploaded = (link) => {
+ setState({ ...state, imgURL: link });
+ };
+
const handleDescriptionChange = (event) => {
let stringLength = event.target.value.length;
let charleft = 400 - stringLength;
@@ -168,9 +219,16 @@ export default function NewRestaurant() {
return (
+ {!state.open && (
+
+ )}