From 4064a20504891e4a39d69b41137e3c734acb50bb Mon Sep 17 00:00:00 2001
From: "Dookarun, Jason J (PG/T - Computer Science)" <jd00795@surrey.ac.uk>
Date: Fri, 21 Apr 2023 15:20:02 +0100
Subject: [PATCH] Code cleanup.

---
 src/App.js | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/src/App.js b/src/App.js
index cdee870..413a26a 100644
--- a/src/App.js
+++ b/src/App.js
@@ -50,25 +50,6 @@ app.get('/parking-locations', async (request, response) => {
     }
 });
 
-
-
-// // function focused on finding nearby parking based on radius
-// app.get('/parking-locations/:postcode', async (request, response) => {
-//     try {
-//       const postcode = request.params.postcode;
-//       const url = `https://api.postcodes.io/postcodes/${encodeURIComponent(postcode)}`;
-//       const { data } = await axios.get(url);
-//       const { latitude, longitude } = data.result;
-//       console.log(`🌐: Successfully retrieved latitude ${latitude} and longitude ${longitude} from postcode ${postcode}.`);
-//       response.send({ latitude, longitude });
-//     } catch (error) {
-//       console.error(`Error retrieving latitude and longitude from postcode ${postcode}: ${error.message}`);
-//       response.status(500).send(`Error retrieving latitude and longitude from postcode ${postcode}: ${error.message}`);
-//     }
-//   });
-  
-
-
 function isAdmin(request, response, next) {
     const authHeader = request.headers.authorization;
     const token = authHeader && authHeader.split(' ')[1];
@@ -95,10 +76,9 @@ app.post('/parking-locations', isAdmin, async (request, response) => {
     try {
       const { Title, Description,city, street_address, postcode, lat, lon, spaces_available, total_spaces } = request.body;
       
-      // Check if street_address already exists in the database
       const existingLocation = await ParkingLocation.findOne({ street_address });
       if (existingLocation) {
-        return response.status(400).json({ error: '⛔️: A parking location with this street address already exists.' });
+        return response.status(400).json({ error: '⛔️: A parking location with this street address already exists. Please try another alternative location. ' });
       }
   
       const parkingLocation = new ParkingLocation({
@@ -120,8 +100,6 @@ app.post('/parking-locations', isAdmin, async (request, response) => {
       response.status(500).json({ error: '⛔️: Failed to add parking to database, please try again later.' });
     }
   });
-  
-
 
 
 app.delete('/parking-locations/:id', isAdmin, async (request, response) => {
-- 
GitLab