diff --git a/frontend/src/components/Applications/ApplicationPlanModal.js b/frontend/src/components/Applications/ApplicationPlanModal.js index c9d4b01..f1a3ca6 100644 --- a/frontend/src/components/Applications/ApplicationPlanModal.js +++ b/frontend/src/components/Applications/ApplicationPlanModal.js @@ -275,15 +275,21 @@ const ApplicationPlanModal = ({ return; } + // Build payload with correct field names and handle xor validation const payload = { - productId: currentProductForSettings.isShared ? currentProductForSettings.id : null, - userProductId: !currentProductForSettings.isShared ? currentProductForSettings.id : null, equipmentId: parseInt(selectedEquipmentId), - setting1: parseFloat(spreaderFormData.setting), + settingValue: spreaderFormData.setting.toString(), // Must be string according to schema rateDescription: spreaderFormData.rateDescription || null, notes: spreaderFormData.notes || null }; + // Add either productId OR userProductId, not both (xor validation) + if (currentProductForSettings.isShared) { + payload.productId = currentProductForSettings.id; + } else { + payload.userProductId = currentProductForSettings.id; + } + const response = await fetch('/api/product-spreader-settings', { method: 'POST', headers: {