diff --git a/backend/src/routes/applications.js b/backend/src/routes/applications.js index 8a0124c..f012f01 100644 --- a/backend/src/routes/applications.js +++ b/backend/src/routes/applications.js @@ -123,10 +123,23 @@ router.get('/plans', async (req, res, next) => { // Only get spreader settings for granular applications with equipment if (plan.equipment_name && productsResult.rows.length > 0) { const firstProduct = productsResult.rows[0]; + console.log('Checking spreader settings for plan:', { + planId: plan.id, + equipmentName: plan.equipment_name, + productInfo: { + productId: firstProduct.product_id, + userProductId: firstProduct.user_product_id, + sharedName: firstProduct.shared_name, + customProductType: firstProduct.custom_product_type + } + }); + const productType = firstProduct.shared_name ? (await pool.query('SELECT product_type FROM products WHERE id = $1', [firstProduct.product_id])).rows[0]?.product_type : firstProduct.custom_product_type; + console.log('Detected product type:', productType); + if (productType === 'granular') { // Get equipment ID const equipmentResult = await pool.query( @@ -134,6 +147,13 @@ router.get('/plans', async (req, res, next) => { [plan.equipment_name, req.user.id] ); + console.log('Equipment lookup result:', { + equipmentName: plan.equipment_name, + userId: req.user.id, + foundEquipment: equipmentResult.rows.length > 0, + equipmentId: equipmentResult.rows[0]?.id + }); + if (equipmentResult.rows.length > 0) { const equipmentId = equipmentResult.rows[0].id; spreaderSetting = await getSpreaderSettingsForEquipment( @@ -142,6 +162,13 @@ router.get('/plans', async (req, res, next) => { firstProduct.user_product_id, req.user.id ); + + console.log('Spreader setting lookup result:', { + equipmentId, + productId: firstProduct.product_id, + userProductId: firstProduct.user_product_id, + setting: spreaderSetting + }); } } }