watering
This commit is contained in:
@@ -376,7 +376,15 @@ router.post('/', async (req, res, next) => {
|
||||
// General fields
|
||||
purchaseDate,
|
||||
purchasePrice,
|
||||
notes
|
||||
notes,
|
||||
// Sprinkler specific fields
|
||||
sprinklerMount,
|
||||
sprinklerHeadType,
|
||||
sprinklerGpm,
|
||||
sprinklerThrowFeet,
|
||||
sprinklerDegrees,
|
||||
sprinklerLengthFeet,
|
||||
sprinklerWidthFeet
|
||||
} = req.body;
|
||||
|
||||
// Validate required fields
|
||||
|
||||
@@ -90,12 +90,6 @@ const Layout = ({ children }) => {
|
||||
icon: CloudIcon,
|
||||
iconSolid: CloudIconSolid,
|
||||
},
|
||||
{
|
||||
name: 'Watering',
|
||||
href: '/watering',
|
||||
icon: CloudIcon,
|
||||
iconSolid: CloudIconSolid,
|
||||
},
|
||||
];
|
||||
|
||||
const adminNavigation = [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { MapContainer, TileLayer, Polygon, Marker, Circle, Rectangle, useMapEvents } from 'react-leaflet';
|
||||
import { MapContainer, TileLayer, Polygon, Marker, Circle, Rectangle, useMapEvents, useMap } from 'react-leaflet';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import { propertiesAPI, wateringAPI, equipmentAPI } from '../../services/api';
|
||||
import toast from 'react-hot-toast';
|
||||
@@ -112,6 +112,12 @@ const Watering = () => {
|
||||
return [39.8,-98.6];
|
||||
}, [selectedProperty, sections]);
|
||||
|
||||
const CenterOnChange = ({ center }) => {
|
||||
const map = useMap();
|
||||
useEffect(() => { if (center && Array.isArray(center)) map.setView(center); }, [center, map]);
|
||||
return null;
|
||||
};
|
||||
|
||||
const startGuidance = () => {
|
||||
if (points.length === 0) { toast.error('Add at least one point'); return; }
|
||||
if (!navigator.geolocation) { toast.error('GPS not available'); return; }
|
||||
@@ -274,6 +280,7 @@ const Watering = () => {
|
||||
</div>
|
||||
</div>
|
||||
<MapContainer center={center} zoom={18} style={{height:'100%', width:'100%'}}>
|
||||
<CenterOnChange center={center} />
|
||||
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
|
||||
{sections.map((s)=> (
|
||||
<Polygon key={s.id} positions={s.polygonData?.coordinates?.[0]||[]} pathOptions={{ color:'#16a34a', weight:2, fillOpacity:0.1 }} />
|
||||
|
||||
Reference in New Issue
Block a user