fasfdsf
This commit is contained in:
@@ -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 && (
|
||||
<div className="mb-4">
|
||||
<div className="flex items-center text-sm text-gray-600 mb-2">
|
||||
<BeakerIcon className="h-4 w-4 mr-2" />
|
||||
Products Applied:
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{application.products.map((product, index) => (
|
||||
{application.productDetails.map((product, index) => (
|
||||
<span
|
||||
key={index}
|
||||
className="px-2 py-1 bg-gray-100 text-gray-700 rounded text-xs"
|
||||
>
|
||||
{product.productName} ({product.rateAmount} {product.rateUnit})
|
||||
{product.name} ({product.rateAmount} {product.rateUnit})
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user