diff --git a/src/pages/CreateTourPage.tsx b/src/pages/CreateTourPage.tsx index 52b29ac..7b431a0 100644 --- a/src/pages/CreateTourPage.tsx +++ b/src/pages/CreateTourPage.tsx @@ -441,19 +441,20 @@ export default function CreateTourPage() { return; } - // Coordinates required only for local/national tours - if ((tourCategory === 'local' || tourCategory === 'national') && (!meetingLat || !meetingLng)) { - toast({ - title: 'Meeting point coordinates required', - description: 'Please enter coordinates or use your current location.', - variant: 'destructive', - }); - return; - } - + // Coordinates are optional. If one is provided, both must be provided and valid. let lat = 0; let lng = 0; - if (tourCategory === 'local' || tourCategory === 'national') { + let hasCoords = false; + if ((tourCategory === 'local' || tourCategory === 'national') && (meetingLat || meetingLng)) { + if (!meetingLat || !meetingLng) { + toast({ + title: 'Incomplete coordinates', + description: 'Please enter both latitude and longitude, or leave both empty.', + variant: 'destructive', + }); + return; + } + lat = parseFloat(meetingLat); lng = parseFloat(meetingLng); @@ -465,6 +466,8 @@ export default function CreateTourPage() { }); return; } + + hasCoords = true; } // Spot types required only for non-destruction tours @@ -509,7 +512,7 @@ export default function CreateTourPage() { try { // Generate low-precision geohash for city-level location (4 chars = ~39km) - const geohash = ngeohash.encode(lat, lng, 4); + const geohash = hasCoords ? ngeohash.encode(lat, lng, 4) : ''; // Create unique identifier const identifier = title @@ -528,10 +531,13 @@ export default function CreateTourPage() { // Location/geohash only for local/national tours if (tourCategory === 'local' || tourCategory === 'national') { - tags.push(['g', geohash]); tags.push(['location', location.trim()]); tags.push(['meeting-point', meetingPoint.trim()]); - tags.push(['meeting-point-coords', lat.toString(), lng.toString()]); + // Coordinates are optional - only include when provided + if (hasCoords) { + tags.push(['g', geohash]); + tags.push(['meeting-point-coords', lat.toString(), lng.toString()]); + } } // Duration - store in appropriate unit @@ -1022,23 +1028,24 @@ export default function CreateTourPage() {
+ Coordinates are optional. Add them to pin your meeting point on the map. +