diff --git a/public/city-select.html b/public/city-select.html new file mode 100644 index 0000000..2cf4144 --- /dev/null +++ b/public/city-select.html @@ -0,0 +1,322 @@ + + + + + + Select City - Water Station Tracker + + + +
+
+

💧 Water Station Tracker

+

Select a city to view water stations

+
+ +
+ +
+
Loading cities...
+
+ +
+

Add New City

+
+
+ + +
+ +
+
+ + +
+ + + + \ No newline at end of file diff --git a/public/dashboard.html b/public/dashboard.html index e1c1a9f..9210f36 100644 --- a/public/dashboard.html +++ b/public/dashboard.html @@ -37,6 +37,21 @@ gap: 1rem; } + .city-selector { + background: rgba(255,255,255,0.2); + color: white; + border: 1px solid rgba(255,255,255,0.3); + padding: 0.5rem 1rem; + border-radius: 20px; + font-size: 0.9rem; + cursor: pointer; + text-decoration: none; + } + + .city-selector:hover { + background: rgba(255,255,255,0.3); + } + .user-info { font-size: 0.9rem; } @@ -304,9 +319,10 @@
+ Change City
@@ -389,8 +405,20 @@ let addMode = false; let tempMarker = null; let user = null; + let currentCity = null; function initDashboard() { + // Get city name from URL + const pathParts = window.location.pathname.split('/'); + currentCity = pathParts[2]; + + if (!currentCity) { + window.location.href = '/city-select'; + return; + } + + document.getElementById('cityName').textContent = currentCity.charAt(0).toUpperCase() + currentCity.slice(1); + checkAuth(); initMap(); loadStations(); @@ -449,9 +477,12 @@ async function loadStations() { try { - const response = await fetch('/api/stations'); + const response = await fetch(`/api/cities/${currentCity}/stations`); const data = await response.json(); stations = data; + if (data.length > 0) { + document.getElementById('cityName').textContent = data[0].city_name; + } displayStations(); populateStationList(); fitMapToStations(); @@ -654,7 +685,7 @@ }; try { - const response = await fetch('/api/stations', { + const response = await fetch(`/api/cities/${currentCity}/stations`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/public/index.html b/public/index.html index a9fc687..d04a387 100644 --- a/public/index.html +++ b/public/index.html @@ -127,10 +127,11 @@

💧 Water Stations

-

Salem

+

Loading...

Login + All Cities
@@ -158,8 +159,22 @@