asdfafd
This commit is contained in:
@@ -11,22 +11,14 @@ const ApplicationViewModal = ({ application, propertyDetails, onClose }) => {
|
||||
|
||||
// Calculate coverage percentage based on GPS tracking and equipment specifications
|
||||
const calculateCoverage = (application, log) => {
|
||||
console.log('calculateCoverage called with:', { application, log });
|
||||
console.log('GPS track points:', log?.gpsTrack?.points?.length || 0);
|
||||
console.log('GPS track structure:', log?.gpsTrack);
|
||||
|
||||
if (!log?.gpsTrack?.points || log.gpsTrack.points.length < 2) {
|
||||
console.log('No GPS points or insufficient points for coverage calculation');
|
||||
return 0; // No movement = no coverage
|
||||
}
|
||||
|
||||
const totalDistance = log.gpsTrack.totalDistance || 0;
|
||||
const plannedArea = application.totalSectionArea || 0;
|
||||
|
||||
console.log('Total distance:', totalDistance, 'Planned area:', plannedArea);
|
||||
|
||||
if (totalDistance === 0 || plannedArea === 0) {
|
||||
console.log('Zero distance or area, returning 0 coverage');
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -70,22 +62,10 @@ const ApplicationViewModal = ({ application, propertyDetails, onClose }) => {
|
||||
|
||||
// Try to fetch application logs to get GPS tracking data
|
||||
try {
|
||||
console.log('Fetching logs for planId:', application.id);
|
||||
// Add cache-busting parameter to force fresh request
|
||||
const logsResponse = await applicationsAPI.getLogs({
|
||||
planId: application.id,
|
||||
_t: Date.now()
|
||||
});
|
||||
console.log('Logs response:', logsResponse);
|
||||
const logsResponse = await applicationsAPI.getLogs({ planId: application.id });
|
||||
const logs = logsResponse.data.data.logs;
|
||||
console.log('Parsed logs:', logs);
|
||||
if (logs && logs.length > 0) {
|
||||
console.log('Setting application log to:', logs[0]);
|
||||
console.log('Log GPS track property:', logs[0].gpsTrack);
|
||||
console.log('Full log object keys:', Object.keys(logs[0]));
|
||||
setApplicationLog(logs[0]); // Get the most recent log
|
||||
} else {
|
||||
console.log('No logs found in response');
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('No application logs found:', error);
|
||||
@@ -234,7 +214,9 @@ const ApplicationViewModal = ({ application, propertyDetails, onClose }) => {
|
||||
<div className="grid grid-cols-2 lg:grid-cols-5 gap-4">
|
||||
<div className="bg-blue-50 p-3 rounded-lg">
|
||||
<div className="text-sm text-blue-600 font-medium">Average Speed</div>
|
||||
<div className="text-xl font-bold text-blue-900">{applicationLog.averageSpeed?.toFixed(1)} mph</div>
|
||||
<div className="text-xl font-bold text-blue-900">
|
||||
{(applicationLog.gpsTrack?.averageSpeed || applicationLog.averageSpeed || 0).toFixed(1)} mph
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-green-50 p-3 rounded-lg">
|
||||
<div className="text-sm text-green-600 font-medium">GPS Points</div>
|
||||
|
||||
Reference in New Issue
Block a user