asdf
This commit is contained in:
@@ -593,18 +593,22 @@ const ApplicationPlanModal = ({
|
|||||||
|
|
||||||
// Check spreader settings when both product and equipment are selected for granular applications
|
// Check spreader settings when both product and equipment are selected for granular applications
|
||||||
useEffect(() => {
|
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' &&
|
if (planData.applicationType === 'granular' &&
|
||||||
planData.selectedProduct &&
|
planData.selectedProduct &&
|
||||||
planData.equipmentId &&
|
planData.equipmentId) {
|
||||||
!editingPlan) { // Only for new plans, not when editing
|
console.log('Triggering spreader setting check from useEffect');
|
||||||
console.log('Triggering spreader setting check from useEffect:', {
|
|
||||||
product: planData.selectedProduct?.customName || planData.selectedProduct?.name,
|
|
||||||
equipmentId: planData.equipmentId,
|
|
||||||
applicationType: planData.applicationType
|
|
||||||
});
|
|
||||||
checkSpreaderSetting(planData.selectedProduct, planData.equipmentId);
|
checkSpreaderSetting(planData.selectedProduct, planData.equipmentId);
|
||||||
}
|
}
|
||||||
}, [planData.applicationType, planData.selectedProduct, planData.equipmentId, editingPlan]);
|
}, [planData.applicationType, planData.selectedProduct, planData.equipmentId]);
|
||||||
|
|
||||||
// Initialize form with editing data
|
// Initialize form with editing data
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -622,13 +626,22 @@ const ApplicationPlanModal = ({
|
|||||||
productType.toLowerCase().includes('granular') ||
|
productType.toLowerCase().includes('granular') ||
|
||||||
productType.toLowerCase().includes('granule')
|
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:', {
|
console.log('Edit plan - application type detection:', {
|
||||||
productType: productType,
|
productType: productType,
|
||||||
isGranular: isGranular,
|
isGranular: isGranular,
|
||||||
|
equipmentType: equipmentType,
|
||||||
|
isGranularByEquipment: isGranularByEquipment,
|
||||||
applicationType: applicationType,
|
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));
|
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:', {
|
console.log('Spreader setting check skipped - equipment not a spreader:', {
|
||||||
selectedEquipment: selectedEquipment?.customName,
|
selectedEquipment: selectedEquipment?.customName,
|
||||||
category: selectedEquipment?.categoryName
|
category: selectedEquipment?.categoryName
|
||||||
|
|||||||
Reference in New Issue
Block a user