update properties stuff
This commit is contained in:
@@ -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 (
|
||||
<div className="p-6">
|
||||
{/* Header */}
|
||||
@@ -195,8 +208,11 @@ const PropertyDetail = () => {
|
||||
<h1 className="text-2xl font-bold text-gray-900">{property.name}</h1>
|
||||
<p className="text-gray-600 flex items-center gap-1">
|
||||
<MapPinIcon className="h-4 w-4" />
|
||||
{property.address}
|
||||
{property.address || 'No address specified'}
|
||||
</p>
|
||||
{!hasValidCoordinates && (
|
||||
<p className="text-red-600 text-sm">⚠️ Property coordinates not set - using default location</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
@@ -214,8 +230,8 @@ const PropertyDetail = () => {
|
||||
<div className="card p-0 overflow-hidden">
|
||||
<div style={{ height: '600px', width: '100%' }}>
|
||||
<MapContainer
|
||||
center={[property.latitude, property.longitude]}
|
||||
zoom={19}
|
||||
center={mapCenter}
|
||||
zoom={hasValidCoordinates ? 19 : 13}
|
||||
style={{ height: '100%', width: '100%' }}
|
||||
>
|
||||
<TileLayer
|
||||
@@ -223,9 +239,11 @@ const PropertyDetail = () => {
|
||||
url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
|
||||
/>
|
||||
|
||||
<Marker position={[property.latitude, property.longitude]}>
|
||||
<Popup>{property.name}</Popup>
|
||||
</Marker>
|
||||
{hasValidCoordinates && (
|
||||
<Marker position={mapCenter}>
|
||||
<Popup>{property.name}</Popup>
|
||||
</Marker>
|
||||
)}
|
||||
|
||||
{lawnSections.map((section) => (
|
||||
<Polygon
|
||||
|
||||
Reference in New Issue
Block a user