applications updates

This commit is contained in:
Jake Kasper
2025-08-29 10:38:48 -04:00
parent a9f4815f41
commit d8bd41c5d4
2 changed files with 5 additions and 4 deletions

View File

@@ -75,7 +75,7 @@ router.get('/plans', async (req, res, next) => {
STRING_AGG(DISTINCT ls.name, ', ') as section_names, STRING_AGG(DISTINCT ls.name, ', ') as section_names,
SUM(DISTINCT ls.area) as total_section_area, SUM(DISTINCT ls.area) as total_section_area,
COUNT(DISTINCT aps.lawn_section_id) as section_count, 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 ue.custom_name as equipment_name, et.name as equipment_type
FROM application_plans ap FROM application_plans ap
JOIN application_plan_sections aps ON ap.id = aps.plan_id 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 user_equipment ue ON ap.equipment_id = ue.id
LEFT JOIN equipment_types et ON ue.equipment_type_id = et.id LEFT JOIN equipment_types et ON ue.equipment_type_id = et.id
WHERE ${whereClause} 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`, ORDER BY ap.planned_date DESC, ap.created_at DESC`,
queryParams queryParams
); );
@@ -204,6 +204,7 @@ router.get('/plans', async (req, res, next) => {
sectionNames: plan.section_names, // Multiple section names comma-separated sectionNames: plan.section_names, // Multiple section names comma-separated
sectionCount: parseInt(plan.section_count), sectionCount: parseInt(plan.section_count),
totalSectionArea: parseFloat(plan.total_section_area), totalSectionArea: parseFloat(plan.total_section_area),
propertyId: plan.property_id, // Add property ID for frontend to use
propertyName: plan.property_name, propertyName: plan.property_name,
propertyAddress: plan.property_address, propertyAddress: plan.property_address,
equipmentName: plan.equipment_name || plan.equipment_type, equipmentName: plan.equipment_name || plan.equipment_type,

View File

@@ -168,7 +168,7 @@ const Applications = () => {
setExecutingApplication(application); setExecutingApplication(application);
// Get the property ID from the 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 // Try to fetch property details if we have a valid property ID
if (propertyId && (!selectedPropertyDetails || selectedPropertyDetails.id !== propertyId)) { if (propertyId && (!selectedPropertyDetails || selectedPropertyDetails.id !== propertyId)) {
@@ -192,7 +192,7 @@ const Applications = () => {
setViewingApplication(application); setViewingApplication(application);
// Get the property ID from the 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 // Try to fetch property details if we have a valid property ID
if (propertyId && (!selectedPropertyDetails || selectedPropertyDetails.id !== propertyId)) { if (propertyId && (!selectedPropertyDetails || selectedPropertyDetails.id !== propertyId)) {