aga
This commit is contained in:
@@ -275,15 +275,21 @@ const ApplicationPlanModal = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build payload with correct field names and handle xor validation
|
||||||
const payload = {
|
const payload = {
|
||||||
productId: currentProductForSettings.isShared ? currentProductForSettings.id : null,
|
|
||||||
userProductId: !currentProductForSettings.isShared ? currentProductForSettings.id : null,
|
|
||||||
equipmentId: parseInt(selectedEquipmentId),
|
equipmentId: parseInt(selectedEquipmentId),
|
||||||
setting1: parseFloat(spreaderFormData.setting),
|
settingValue: spreaderFormData.setting.toString(), // Must be string according to schema
|
||||||
rateDescription: spreaderFormData.rateDescription || null,
|
rateDescription: spreaderFormData.rateDescription || null,
|
||||||
notes: spreaderFormData.notes || 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', {
|
const response = await fetch('/api/product-spreader-settings', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user