From 288131693a8eb87f7bd8ffae78007c136e2ea415 Mon Sep 17 00:00:00 2001 From: Jake Kasper Date: Thu, 28 Aug 2025 08:39:29 -0500 Subject: [PATCH] fasfdsf --- frontend/src/pages/History/History.js | 43 ++++++++------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/frontend/src/pages/History/History.js b/frontend/src/pages/History/History.js index 1e73769..7931dff 100644 --- a/frontend/src/pages/History/History.js +++ b/frontend/src/pages/History/History.js @@ -99,14 +99,6 @@ const History = () => { const archivedPlans = archivedResponse.data.data.plans || []; const allHistoryApplications = [...completedPlans, ...archivedPlans]; - // Debug: Log the structure of applications - console.log('fetchHistoryData - completedPlans:', completedPlans); - console.log('fetchHistoryData - first application:', completedPlans[0]); - if (completedPlans[0]) { - console.log('fetchHistoryData - application fields:', Object.keys(completedPlans[0])); - console.log('fetchHistoryData - application products:', completedPlans[0].products); - console.log('fetchHistoryData - application applicationType:', completedPlans[0].applicationType); - } // Fetch application logs for additional details const logsResponse = await applicationsAPI.getLogs(); @@ -170,7 +162,7 @@ const History = () => { if (statusFilter !== 'all' && app.status !== statusFilter) return false; if (propertyFilter !== 'all' && app.propertyName !== propertyFilter) return false; - if (applicationTypeFilter !== 'all' && app.applicationType !== applicationTypeFilter) return false; + if (applicationTypeFilter !== 'all' && getApplicationType(app) !== applicationTypeFilter) return false; return true; }); @@ -178,32 +170,21 @@ const History = () => { const filteredForOptions = getFilteredApplicationsForOptions(); - // Debug logging - console.log('Debug History filters:'); - console.log('completedApplications:', completedApplications.length); - console.log('sample application:', completedApplications[0]); - console.log('filteredForOptions:', filteredForOptions.length); - console.log('dateFilter:', dateFilter, 'dateRangeStart:', dateRangeStart, 'dateRangeEnd:', dateRangeEnd); - console.log('applicationTypeFilter:', applicationTypeFilter); - const uniqueProperties = [...new Set(completedApplications.map(app => app.propertyName))].filter(Boolean); const uniqueProducts = [...new Set( filteredForOptions.flatMap(app => - app.products ? app.products.map(p => p.productName) : [] + app.productDetails ? app.productDetails.map(p => p.name) : [] ) )].filter(Boolean).sort(); - console.log('uniqueProducts found:', uniqueProducts); + // Get application type from first product in productDetails + const getApplicationType = (app) => { + if (!app.productDetails || app.productDetails.length === 0) return null; + return app.productDetails[0].type; // granular or liquid + }; // Filter applications based on all filters const filteredApplications = completedApplications.filter(app => { - // Debug logging for first app - if (completedApplications.indexOf(app) === 0) { - console.log('Filtering first app:', app); - console.log('App planned date:', app.plannedDate); - console.log('App application type:', app.applicationType); - console.log('App products:', app.products); - } // Date filter if (dateFilter !== 'all') { @@ -245,11 +226,11 @@ const History = () => { // Product filter - multi-select if (selectedProducts.length > 0) { - if (!app.products || !app.products.some(p => selectedProducts.includes(p.productName))) return false; + if (!app.productDetails || !app.productDetails.some(p => selectedProducts.includes(p.name))) return false; } // Application type filter - if (applicationTypeFilter !== 'all' && app.applicationType !== applicationTypeFilter) return false; + if (applicationTypeFilter !== 'all' && getApplicationType(app) !== applicationTypeFilter) return false; return true; }); @@ -635,19 +616,19 @@ const History = () => { )} {/* Products */} - {application.products && application.products.length > 0 && ( + {application.productDetails && application.productDetails.length > 0 && (
Products Applied:
- {application.products.map((product, index) => ( + {application.productDetails.map((product, index) => ( - {product.productName} ({product.rateAmount} {product.rateUnit}) + {product.name} ({product.rateAmount} {product.rateUnit}) ))}