asdf
This commit is contained in:
@@ -112,6 +112,10 @@ const MowingExecutionModal = ({ plan, onClose, onComplete }) => {
|
||||
}
|
||||
} catch {}
|
||||
|
||||
// Ensure positive, non-zero totals for backend validation
|
||||
const totalMeters = Math.max(Math.round(totalDistance*100)/100, 0.01);
|
||||
const avgMph = Math.max(averageSpeed, 0.1);
|
||||
|
||||
const payload = {
|
||||
propertyId: plan.property_id,
|
||||
lawnSectionIds: sections.map(s=>s.id),
|
||||
@@ -119,12 +123,15 @@ const MowingExecutionModal = ({ plan, onClose, onComplete }) => {
|
||||
cutHeightInches: plan.cut_height_inches,
|
||||
direction: plan.direction,
|
||||
gpsTrack: { points: gpsTrack, totalDistance: Math.round(totalDistance*100)/100, duration: durationSeconds, averageSpeed: Math.round(averageSpeed*100)/100 },
|
||||
averageSpeed: Math.max(averageSpeed, 0.1),
|
||||
averageSpeed: avgMph,
|
||||
durationSeconds,
|
||||
totalDistanceMeters: Math.round(totalDistance*100)/100,
|
||||
areaCoveredSqft,
|
||||
totalDistanceMeters: totalMeters,
|
||||
notes: ''
|
||||
};
|
||||
// Only include areaCoveredSqft if we computed a number
|
||||
if (typeof areaCoveredSqft === 'number' && !Number.isNaN(areaCoveredSqft) && areaCoveredSqft > 0) {
|
||||
payload.areaCoveredSqft = areaCoveredSqft;
|
||||
}
|
||||
await mowingAPI.createLog(payload);
|
||||
await mowingAPI.updatePlanStatus(plan.id, 'completed');
|
||||
toast.success('Mowing session saved');
|
||||
|
||||
Reference in New Issue
Block a user