asdf
This commit is contained in:
@@ -16,6 +16,7 @@ const ApplicationExecutionModal = ({ application, propertyDetails, onClose, onCo
|
||||
const [averageSpeed, setAverageSpeed] = useState(0);
|
||||
const [sections, setSections] = useState([]);
|
||||
const [mapCenter, setMapCenter] = useState(null);
|
||||
const [planDetails, setPlanDetails] = useState(null);
|
||||
|
||||
// Debug: Log the application data to understand structure
|
||||
useEffect(() => {
|
||||
@@ -37,20 +38,23 @@ const ApplicationExecutionModal = ({ application, propertyDetails, onClose, onCo
|
||||
try {
|
||||
// First try to get detailed plan information from the API
|
||||
const planResponse = await applicationsAPI.getPlan(application.id);
|
||||
const planDetails = planResponse.data.data.plan;
|
||||
const fetchedPlanDetails = planResponse.data.data.plan;
|
||||
|
||||
console.log('Fetched plan details:', planDetails);
|
||||
console.log('Plan details sections:', planDetails.sections);
|
||||
console.log('Fetched plan details:', fetchedPlanDetails);
|
||||
console.log('Plan details sections:', fetchedPlanDetails.sections);
|
||||
|
||||
if (planDetails.sections && planDetails.sections.length > 0) {
|
||||
setSections(planDetails.sections);
|
||||
// Store the plan details for use in completeApplication
|
||||
setPlanDetails(fetchedPlanDetails);
|
||||
|
||||
if (fetchedPlanDetails.sections && fetchedPlanDetails.sections.length > 0) {
|
||||
setSections(fetchedPlanDetails.sections);
|
||||
|
||||
// Calculate center from section coordinates
|
||||
let totalLat = 0;
|
||||
let totalLng = 0;
|
||||
let pointCount = 0;
|
||||
|
||||
planDetails.sections.forEach(section => {
|
||||
fetchedPlanDetails.sections.forEach(section => {
|
||||
let polygonData = section.polygonData;
|
||||
if (typeof polygonData === 'string') {
|
||||
try {
|
||||
@@ -78,7 +82,7 @@ const ApplicationExecutionModal = ({ application, propertyDetails, onClose, onCo
|
||||
}
|
||||
|
||||
// Fallback: If we have property details, use those sections
|
||||
if ((!planDetails.sections || planDetails.sections.length === 0) && propertyDetails?.sections) {
|
||||
if ((!fetchedPlanDetails.sections || fetchedPlanDetails.sections.length === 0) && propertyDetails?.sections) {
|
||||
const applicationSectionIds = application.sections?.map(s => s.id) || [];
|
||||
const relevantSections = propertyDetails.sections.filter(section =>
|
||||
applicationSectionIds.includes(section.id)
|
||||
@@ -206,11 +210,16 @@ const ApplicationExecutionModal = ({ application, propertyDetails, onClose, onCo
|
||||
const endTime = new Date();
|
||||
const duration = startTime ? (endTime - startTime) / 1000 : 0; // seconds
|
||||
|
||||
// Ensure we have valid section data from fetched plan details
|
||||
// Debug logging for plan details
|
||||
console.log('Complete Application - Plan Details:', planDetails);
|
||||
console.log('Complete Application - Equipment:', planDetails?.equipment);
|
||||
console.log('Complete Application - Products:', planDetails?.products);
|
||||
|
||||
// Ensure we have valid data from fetched plan details
|
||||
const validSectionId = sections.length > 0 ? sections[0].id : null;
|
||||
const validEquipmentId = application.equipment?.id;
|
||||
const validProducts = application.products && application.products.length > 0 ?
|
||||
application.products.map(product => ({
|
||||
const validEquipmentId = planDetails?.equipment?.id;
|
||||
const validProducts = planDetails?.products && planDetails.products.length > 0 ?
|
||||
planDetails.products.map(product => ({
|
||||
productId: product.productId,
|
||||
userProductId: product.userProductId,
|
||||
rateAmount: product.rateAmount,
|
||||
|
||||
Reference in New Issue
Block a user