From 5926e2933eed460c90b0c5ce876c69ac69eb4f18 Mon Sep 17 00:00:00 2001 From: Jake Kasper Date: Thu, 21 Aug 2025 17:36:40 -0400 Subject: [PATCH] update properties stuff --- .../src/components/Properties/PropertyForm.js | 5 ++- .../src/pages/Properties/PropertyDetail.js | 32 +++++++++++++++---- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/Properties/PropertyForm.js b/frontend/src/components/Properties/PropertyForm.js index 178901f..ef6f538 100644 --- a/frontend/src/components/Properties/PropertyForm.js +++ b/frontend/src/components/Properties/PropertyForm.js @@ -1,8 +1,7 @@ -import React, { useState, useEffect, useRef } from 'react'; +import React, { useState, useRef } from 'react'; import { MapContainer, TileLayer, Marker, Popup, useMapEvents } from 'react-leaflet'; import { Icon } from 'leaflet'; import 'leaflet/dist/leaflet.css'; -import toast from 'react-hot-toast'; // Fix for default markers in react-leaflet delete Icon.Default.prototype._getIconUrl; @@ -14,7 +13,7 @@ Icon.Default.mergeOptions({ // Component to handle map clicks and update marker position function LocationMarker({ position, setPosition }) { - const map = useMapEvents({ + useMapEvents({ click(e) { setPosition([e.latlng.lat, e.latlng.lng]); }, diff --git a/frontend/src/pages/Properties/PropertyDetail.js b/frontend/src/pages/Properties/PropertyDetail.js index 43cac9c..60ef76d 100644 --- a/frontend/src/pages/Properties/PropertyDetail.js +++ b/frontend/src/pages/Properties/PropertyDetail.js @@ -92,7 +92,7 @@ const PropertyDetail = () => { useEffect(() => { fetchPropertyDetails(); - }, [id]); + }, [id]); // eslint-disable-line react-hooks/exhaustive-deps const fetchPropertyDetails = async () => { try { @@ -180,6 +180,19 @@ const PropertyDetail = () => { ); } + // Validate coordinates and provide fallbacks + const hasValidCoordinates = property && + property.latitude !== undefined && + property.longitude !== undefined && + property.latitude !== null && + property.longitude !== null && + !isNaN(property.latitude) && + !isNaN(property.longitude); + + const mapCenter = hasValidCoordinates + ? [property.latitude, property.longitude] + : [40.7128, -74.0060]; // Default to NYC + return (
{/* Header */} @@ -195,8 +208,11 @@ const PropertyDetail = () => {

{property.name}

- {property.address} + {property.address || 'No address specified'}

+ {!hasValidCoordinates && ( +

⚠️ Property coordinates not set - using default location

+ )}