diff --git a/.replit b/.replit index ccae3d04..5586ae74 100644 --- a/.replit +++ b/.replit @@ -45,7 +45,3 @@ externalPort = 3001 [[ports]] localPort = 37623 externalPort = 3002 - -[[ports]] -localPort = 46475 -externalPort = 3003 diff --git a/src/components/admin/LocationSearch.tsx b/src/components/admin/LocationSearch.tsx index 19b192bd..c6afb2e4 100644 --- a/src/components/admin/LocationSearch.tsx +++ b/src/components/admin/LocationSearch.tsx @@ -146,18 +146,23 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className const latitude = parseFloat(result.lat); const longitude = parseFloat(result.lon); - const city = result.address.city || result.address.town || result.address.village; + // Safely access address properties with fallback + const address = result.address || {}; + const city = address.city || address.town || address.village; + const state = address.state || ''; + const country = address.country || 'Unknown'; + const locationName = city - ? `${city}, ${result.address.state || ''} ${result.address.country}`.trim() + ? `${city}, ${state} ${country}`.trim() : result.display_name; // Build location data object (no database operations) const locationData: SelectedLocation = { name: locationName, city: city || undefined, - state_province: result.address.state || undefined, - country: result.address.country || '', - postal_code: result.address.postcode || undefined, + state_province: state || undefined, + country: country, + postal_code: address.postcode || undefined, latitude, longitude, timezone: undefined, // Will be set by server during approval if needed diff --git a/supabase/functions/detect-location/index.ts b/supabase/functions/detect-location/index.ts index 18a56217..7604bc6f 100644 --- a/supabase/functions/detect-location/index.ts +++ b/supabase/functions/detect-location/index.ts @@ -259,7 +259,7 @@ serve(async (req) => { requestId: tracking.requestId }); - endRequest(tracking, 200); + endRequest(tracking); return new Response( JSON.stringify({ ...result, requestId: tracking.requestId }), @@ -284,7 +284,7 @@ serve(async (req) => { requestId: tracking.requestId }); - endRequest(tracking, 500, errorMessage); + endRequest(tracking); // Return default (metric) with 500 status to indicate error occurred // This allows proper error monitoring while still providing fallback data