From 0b549ae642dc2bc508ba66236693c595acabf264 Mon Sep 17 00:00:00 2001 From: Jake Kasper Date: Tue, 26 Aug 2025 14:23:01 -0400 Subject: [PATCH] asdf --- .../src/pages/Applications/Applications.js | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/frontend/src/pages/Applications/Applications.js b/frontend/src/pages/Applications/Applications.js index 1ca30b2..ca7e39c 100644 --- a/frontend/src/pages/Applications/Applications.js +++ b/frontend/src/pages/Applications/Applications.js @@ -593,18 +593,22 @@ const ApplicationPlanModal = ({ // Check spreader settings when both product and equipment are selected for granular applications useEffect(() => { + console.log('Spreader setting useEffect triggered:', { + applicationType: planData.applicationType, + hasSelectedProduct: !!planData.selectedProduct, + hasEquipmentId: !!planData.equipmentId, + productName: planData.selectedProduct?.customName || planData.selectedProduct?.name, + equipmentId: planData.equipmentId, + isEditing: !!editingPlan + }); + if (planData.applicationType === 'granular' && planData.selectedProduct && - planData.equipmentId && - !editingPlan) { // Only for new plans, not when editing - console.log('Triggering spreader setting check from useEffect:', { - product: planData.selectedProduct?.customName || planData.selectedProduct?.name, - equipmentId: planData.equipmentId, - applicationType: planData.applicationType - }); + planData.equipmentId) { + console.log('Triggering spreader setting check from useEffect'); checkSpreaderSetting(planData.selectedProduct, planData.equipmentId); } - }, [planData.applicationType, planData.selectedProduct, planData.equipmentId, editingPlan]); + }, [planData.applicationType, planData.selectedProduct, planData.equipmentId]); // Initialize form with editing data useEffect(() => { @@ -622,13 +626,22 @@ const ApplicationPlanModal = ({ productType.toLowerCase().includes('granular') || productType.toLowerCase().includes('granule') ); - applicationType = isGranular ? 'granular' : 'liquid'; + + // Also check equipment type as fallback for granular detection + const equipmentType = editingPlan.equipment?.categoryName?.toLowerCase() || ''; + const isGranularByEquipment = equipmentType.includes('spreader') || equipmentType.includes('granular'); + + // If we can't determine from product type, use equipment type + applicationType = (isGranular || (!productType && isGranularByEquipment)) ? 'granular' : 'liquid'; console.log('Edit plan - application type detection:', { productType: productType, isGranular: isGranular, + equipmentType: equipmentType, + isGranularByEquipment: isGranularByEquipment, applicationType: applicationType, - productName: firstProduct.productName + productName: firstProduct.productName, + fullProduct: firstProduct }); } @@ -722,7 +735,18 @@ const ApplicationPlanModal = ({ } const selectedEquipment = equipment.find(eq => eq.id === parseInt(equipmentId)); - if (!selectedEquipment || selectedEquipment.categoryName !== 'Spreader') { + if (!selectedEquipment) { + console.log('Spreader setting check skipped - equipment not found:', { + equipmentId: equipmentId + }); + return; + } + + // Check if equipment is spreader-related (more flexible matching) + const categoryName = selectedEquipment.categoryName?.toLowerCase() || ''; + const isSpreaderEquipment = categoryName.includes('spreader') || categoryName.includes('granular'); + + if (!isSpreaderEquipment) { console.log('Spreader setting check skipped - equipment not a spreader:', { selectedEquipment: selectedEquipment?.customName, category: selectedEquipment?.categoryName