asdfasf
This commit is contained in:
@@ -124,13 +124,56 @@ const History = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get unique values for filter options
|
// Get unique values for filter options - dynamically filter based on other applied filters
|
||||||
|
const getFilteredApplicationsForOptions = () => {
|
||||||
|
return completedApplications.filter(app => {
|
||||||
|
// Apply all filters except products to get dynamic product list
|
||||||
|
if (dateFilter !== 'all') {
|
||||||
|
const appDate = new Date(app.plannedDate);
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
switch (dateFilter) {
|
||||||
|
case 'today':
|
||||||
|
if (appDate.toDateString() !== now.toDateString()) return false;
|
||||||
|
break;
|
||||||
|
case 'week':
|
||||||
|
const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
|
||||||
|
if (appDate < weekAgo) return false;
|
||||||
|
break;
|
||||||
|
case 'month':
|
||||||
|
const monthAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
|
||||||
|
if (appDate < monthAgo) return false;
|
||||||
|
break;
|
||||||
|
case 'custom':
|
||||||
|
if (dateRangeStart) {
|
||||||
|
const startDate = new Date(dateRangeStart);
|
||||||
|
startDate.setHours(0, 0, 0, 0);
|
||||||
|
if (appDate < startDate) return false;
|
||||||
|
}
|
||||||
|
if (dateRangeEnd) {
|
||||||
|
const endDate = new Date(dateRangeEnd);
|
||||||
|
endDate.setHours(23, 59, 59, 999);
|
||||||
|
if (appDate > endDate) return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statusFilter !== 'all' && app.status !== statusFilter) return false;
|
||||||
|
if (propertyFilter !== 'all' && app.propertyName !== propertyFilter) return false;
|
||||||
|
if (applicationTypeFilter !== 'all' && app.applicationType !== applicationTypeFilter) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const filteredForOptions = getFilteredApplicationsForOptions();
|
||||||
const uniqueProperties = [...new Set(completedApplications.map(app => app.propertyName))].filter(Boolean);
|
const uniqueProperties = [...new Set(completedApplications.map(app => app.propertyName))].filter(Boolean);
|
||||||
const uniqueProducts = [...new Set(
|
const uniqueProducts = [...new Set(
|
||||||
completedApplications.flatMap(app =>
|
filteredForOptions.flatMap(app =>
|
||||||
app.products ? app.products.map(p => p.productName) : []
|
app.products ? app.products.map(p => p.productName) : []
|
||||||
)
|
)
|
||||||
)].filter(Boolean);
|
)].filter(Boolean).sort();
|
||||||
|
|
||||||
// Filter applications based on all filters
|
// Filter applications based on all filters
|
||||||
const filteredApplications = completedApplications.filter(app => {
|
const filteredApplications = completedApplications.filter(app => {
|
||||||
@@ -151,6 +194,18 @@ const History = () => {
|
|||||||
const monthAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
|
const monthAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
|
||||||
if (appDate < monthAgo) return false;
|
if (appDate < monthAgo) return false;
|
||||||
break;
|
break;
|
||||||
|
case 'custom':
|
||||||
|
if (dateRangeStart) {
|
||||||
|
const startDate = new Date(dateRangeStart);
|
||||||
|
startDate.setHours(0, 0, 0, 0);
|
||||||
|
if (appDate < startDate) return false;
|
||||||
|
}
|
||||||
|
if (dateRangeEnd) {
|
||||||
|
const endDate = new Date(dateRangeEnd);
|
||||||
|
endDate.setHours(23, 59, 59, 999);
|
||||||
|
if (appDate > endDate) return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +220,9 @@ const History = () => {
|
|||||||
if (!app.products || !app.products.some(p => selectedProducts.includes(p.productName))) return false;
|
if (!app.products || !app.products.some(p => selectedProducts.includes(p.productName))) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Application type filter
|
||||||
|
if (applicationTypeFilter !== 'all' && app.applicationType !== applicationTypeFilter) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user