From 1c2ecc3de5223dfc9b544b0b02cb2d085e72dfc1 Mon Sep 17 00:00:00 2001 From: wongwh2002 Date: Mon, 22 Jul 2024 23:04:24 +0800 Subject: [PATCH 01/13] added some gmap api thing? --- .env | 1 + package-lock.json | 22 +++++++++++++++++++++- package.json | 1 + src/components/NavBar.tsx | 11 ++++++++++- src/functions/getCusLoc.tsx | 24 ++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 .env create mode 100644 src/functions/getCusLoc.tsx diff --git a/.env b/.env new file mode 100644 index 0000000..db64467 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +GOOGLE_MAPS_API_KEY=AIzaSyDCs25ivx55QjPoixKSzGreSw-feBeJVms \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ff6936c..cf01723 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@anatoliygatt/heart-switch": "^1.0.13", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", + "@vis.gl/react-google-maps": "^1.1.0", "bootstrap": "^5.3.3", "firebase": "^10.12.2", "react": "^18.2.0", @@ -2255,6 +2256,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/google.maps": { + "version": "3.55.11", + "resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.55.11.tgz", + "integrity": "sha512-F3VuPtjKj4UGuyym75pqmgPBOHbT/i7I6/D+4DdtSzbeu2aWZG1ENwpbZOd46uO+PSAz9flJEhxxi+b4MVb4gQ==", + "license": "MIT" + }, "node_modules/@types/node": { "version": "20.12.12", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", @@ -2518,6 +2525,20 @@ "dev": true, "license": "ISC" }, + "node_modules/@vis.gl/react-google-maps": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@vis.gl/react-google-maps/-/react-google-maps-1.1.0.tgz", + "integrity": "sha512-MxDIhCfPRzTQY1c6sS0GFg8Ukl40o13fkIKEaCN0cR1BIrV4LPo+EuCov9WElbe0bOo8MApx5qAbqBKOmLQyKg==", + "license": "MIT", + "dependencies": { + "@types/google.maps": "^3.54.10", + "fast-deep-equal": "^3.1.3" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, "node_modules/@vitejs/plugin-react": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.3.0.tgz", @@ -3304,7 +3325,6 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true, "license": "MIT" }, "node_modules/fast-glob": { diff --git a/package.json b/package.json index 87283d9..8d74193 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@anatoliygatt/heart-switch": "^1.0.13", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", + "@vis.gl/react-google-maps": "^1.1.0", "bootstrap": "^5.3.3", "firebase": "^10.12.2", "react": "^18.2.0", diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index 0e584da..a14e8dc 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -3,6 +3,7 @@ import { useNavigate } from "react-router-dom"; import { auth } from "../config/firebase"; import { Button, Container, Nav, Navbar } from "react-bootstrap"; import { useAuth } from "../context/Auth"; +import { getCusLoc } from "../functions/getCusLoc"; export function NavBar() { let navigate = useNavigate(); @@ -34,7 +35,15 @@ export function NavBar() { <> ) : ( - + <> + + Update Current Location + + + )} diff --git a/src/pages/Favorites.tsx b/src/pages/Favorites.tsx index cd14a46..18d0861 100644 --- a/src/pages/Favorites.tsx +++ b/src/pages/Favorites.tsx @@ -10,6 +10,7 @@ import { doc, increment, updateDoc } from "firebase/firestore"; import { db } from "../config/firebase"; import { deleteWarning } from "../functions/Alert"; import { ConCards } from "../components/ConCards"; +import MapComponent from "../components/MapComponent"; // Import the MapComponent export function FavoritePage() { const { user, isConsumer } = useAuth(); // Auth context // Redirect the user if not authenticated or not a consumer @@ -135,6 +136,8 @@ export function FavoritePage() { {!isLoading && searchFoodList.length == 0 && (

No Results

)} + {/* Display MapComponent at the end of the page */} + ); } diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 0106227..9f74d11 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -9,6 +9,7 @@ import { useNavigate } from "react-router-dom"; import { doc, increment, updateDoc } from "firebase/firestore"; import { db } from "../config/firebase"; import { ConCards } from "../components/ConCards"; +import MapComponent from "../components/MapComponent"; // Import the MapComponent export function Home() { const [foodList, setFoodList] = useState([]); // State for all posted food items @@ -139,9 +140,12 @@ export function Home() { )} {/* Display message if no results found */} - {!isLoading && searchFoodList.length == 0 && ( + {!isLoading && searchFoodList.length === 0 && (

No Results

)} + + {/* Display MapComponent at the end of the page */} + {isConsumer ? : null} ); }