From d8bd41c5d44119b1cac74cd9d367609e3d3ddbd4 Mon Sep 17 00:00:00 2001 From: Jake Kasper Date: Fri, 29 Aug 2025 10:38:48 -0400 Subject: [PATCH] applications updates --- backend/src/routes/applications.js | 5 +++-- frontend/src/pages/Applications/Applications.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/src/routes/applications.js b/backend/src/routes/applications.js index 8af992f..8ae7d5c 100644 --- a/backend/src/routes/applications.js +++ b/backend/src/routes/applications.js @@ -75,7 +75,7 @@ router.get('/plans', async (req, res, next) => { STRING_AGG(DISTINCT ls.name, ', ') as section_names, SUM(DISTINCT ls.area) as total_section_area, COUNT(DISTINCT aps.lawn_section_id) as section_count, - p.name as property_name, p.address as property_address, + p.id as property_id, p.name as property_name, p.address as property_address, ue.custom_name as equipment_name, et.name as equipment_type FROM application_plans ap JOIN application_plan_sections aps ON ap.id = aps.plan_id @@ -84,7 +84,7 @@ router.get('/plans', async (req, res, next) => { LEFT JOIN user_equipment ue ON ap.equipment_id = ue.id LEFT JOIN equipment_types et ON ue.equipment_type_id = et.id WHERE ${whereClause} - GROUP BY ap.id, p.name, p.address, ue.custom_name, et.name + GROUP BY ap.id, p.id, p.name, p.address, ue.custom_name, et.name ORDER BY ap.planned_date DESC, ap.created_at DESC`, queryParams ); @@ -204,6 +204,7 @@ router.get('/plans', async (req, res, next) => { sectionNames: plan.section_names, // Multiple section names comma-separated sectionCount: parseInt(plan.section_count), totalSectionArea: parseFloat(plan.total_section_area), + propertyId: plan.property_id, // Add property ID for frontend to use propertyName: plan.property_name, propertyAddress: plan.property_address, equipmentName: plan.equipment_name || plan.equipment_type, diff --git a/frontend/src/pages/Applications/Applications.js b/frontend/src/pages/Applications/Applications.js index b85fd9b..bcd53a4 100644 --- a/frontend/src/pages/Applications/Applications.js +++ b/frontend/src/pages/Applications/Applications.js @@ -168,7 +168,7 @@ const Applications = () => { setExecutingApplication(application); // Get the property ID from the application - const propertyId = application.property?.id || application.section?.propertyId; + const propertyId = application.propertyId; // Try to fetch property details if we have a valid property ID if (propertyId && (!selectedPropertyDetails || selectedPropertyDetails.id !== propertyId)) { @@ -192,7 +192,7 @@ const Applications = () => { setViewingApplication(application); // Get the property ID from the application - const propertyId = application.property?.id || application.section?.propertyId; + const propertyId = application.propertyId; // Try to fetch property details if we have a valid property ID if (propertyId && (!selectedPropertyDetails || selectedPropertyDetails.id !== propertyId)) {