mowing history
This commit is contained in:
@@ -12,7 +12,6 @@ const Mowing = () => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [showPlanModal, setShowPlanModal] = useState(false);
|
||||
const [execPlan, setExecPlan] = useState(null);
|
||||
const [sessions, setSessions] = useState([]);
|
||||
const [viewSession, setViewSession] = useState(null);
|
||||
|
||||
const fetchPlans = async () => {
|
||||
@@ -20,11 +19,6 @@ const Mowing = () => {
|
||||
setLoading(true);
|
||||
const r = await mowingAPI.getPlans();
|
||||
setPlans(r.data.data.plans || []);
|
||||
// also load recent sessions
|
||||
try {
|
||||
const s = await mowingAPI.getLogs();
|
||||
setSessions(s.data?.data?.logs || []);
|
||||
} catch {}
|
||||
} catch (e) {
|
||||
toast.error('Failed to load mowing plans');
|
||||
} finally {
|
||||
@@ -75,29 +69,6 @@ const Mowing = () => {
|
||||
{p.notes && (
|
||||
<p className="text-sm text-gray-500 mt-1 italic">"{p.notes}"</p>
|
||||
)}
|
||||
|
||||
{/* Recent sessions for this property */}
|
||||
{sessions.filter(s => s.property_id === p.property_id).length > 0 && (
|
||||
<div className="mt-3">
|
||||
<h4 className="text-sm font-semibold text-gray-800 mb-2">Recent Sessions</h4>
|
||||
<div className="divide-y border rounded-md">
|
||||
{sessions.filter(s => s.property_id === p.property_id).slice(0,3).map(s => (
|
||||
<div key={s.id} className="flex items-center justify-between p-2 text-sm">
|
||||
<div className="text-gray-700">
|
||||
{new Date(s.created_at || s.session_date).toLocaleString()} • {(s.average_speed_mph || s.averageSpeed || 0).toFixed?.(1) || Number(s.averageSpeed || 0).toFixed(1)} mph • {Math.round(((s.total_distance_meters || s.gpsTrack?.totalDistance || 0) * 3.28084) || 0)} ft
|
||||
</div>
|
||||
<button
|
||||
className="p-1 text-indigo-600 hover:text-indigo-800 hover:bg-indigo-50 rounded"
|
||||
title="View session"
|
||||
onClick={()=> setViewSession(s)}
|
||||
>
|
||||
<EyeIcon className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<p className="text-sm font-medium text-gray-900">{p.planned_date ? new Date(p.planned_date).toLocaleDateString() : 'No date'}</p>
|
||||
@@ -127,40 +98,7 @@ const Mowing = () => {
|
||||
<MowingExecutionModal plan={execPlan} onClose={()=> setExecPlan(null)} onComplete={fetchPlans} />
|
||||
)}
|
||||
|
||||
{/* Recent Sessions */}
|
||||
<div className="mt-8">
|
||||
<h2 className="text-lg font-semibold mb-3">Recent Sessions</h2>
|
||||
<div className="bg-white rounded-lg shadow overflow-hidden">
|
||||
<div className="grid grid-cols-6 gap-4 p-4 border-b text-sm font-medium text-gray-600">
|
||||
<div>Property</div>
|
||||
<div>Mower</div>
|
||||
<div>Cut Height</div>
|
||||
<div>Avg Speed</div>
|
||||
<div>Distance</div>
|
||||
<div>Actions</div>
|
||||
</div>
|
||||
{sessions.length === 0 ? (
|
||||
<div className="p-4 text-gray-600">No sessions yet.</div>
|
||||
) : sessions.map((s) => (
|
||||
<div key={s.id} className="grid grid-cols-6 gap-4 p-4 border-b text-sm items-center">
|
||||
<div className="font-medium">{s.property_name}</div>
|
||||
<div>{s.equipment_name || '—'}</div>
|
||||
<div>{Number(s.cut_height_inches || 0).toFixed(2)}"</div>
|
||||
<div>{(s.average_speed_mph || s.averageSpeed || 0).toFixed?.(1) || Number(s.averageSpeed || 0).toFixed(1)} mph</div>
|
||||
<div>{Math.round(((s.total_distance_meters || s.gpsTrack?.totalDistance || 0) * 3.28084) || 0)} ft</div>
|
||||
<div className="flex justify-end">
|
||||
<button
|
||||
className="p-1 text-indigo-600 hover:text-indigo-800 hover:bg-indigo-50 rounded"
|
||||
title="View session"
|
||||
onClick={()=> setViewSession(s)}
|
||||
>
|
||||
<EyeIcon className="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{/* Recent Sessions section removed as requested */}
|
||||
|
||||
{viewSession && (
|
||||
<MowingSessionViewModal session={viewSession} onClose={()=> setViewSession(null)} />
|
||||
|
||||
Reference in New Issue
Block a user