asdf
This commit is contained in:
@@ -112,6 +112,10 @@ const MowingExecutionModal = ({ plan, onClose, onComplete }) => {
|
|||||||
}
|
}
|
||||||
} catch {}
|
} 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 = {
|
const payload = {
|
||||||
propertyId: plan.property_id,
|
propertyId: plan.property_id,
|
||||||
lawnSectionIds: sections.map(s=>s.id),
|
lawnSectionIds: sections.map(s=>s.id),
|
||||||
@@ -119,12 +123,15 @@ const MowingExecutionModal = ({ plan, onClose, onComplete }) => {
|
|||||||
cutHeightInches: plan.cut_height_inches,
|
cutHeightInches: plan.cut_height_inches,
|
||||||
direction: plan.direction,
|
direction: plan.direction,
|
||||||
gpsTrack: { points: gpsTrack, totalDistance: Math.round(totalDistance*100)/100, duration: durationSeconds, averageSpeed: Math.round(averageSpeed*100)/100 },
|
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,
|
durationSeconds,
|
||||||
totalDistanceMeters: Math.round(totalDistance*100)/100,
|
totalDistanceMeters: totalMeters,
|
||||||
areaCoveredSqft,
|
|
||||||
notes: ''
|
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.createLog(payload);
|
||||||
await mowingAPI.updatePlanStatus(plan.id, 'completed');
|
await mowingAPI.updatePlanStatus(plan.id, 'completed');
|
||||||
toast.success('Mowing session saved');
|
toast.success('Mowing session saved');
|
||||||
|
|||||||
Reference in New Issue
Block a user