Fix: Correct filter variable name

This commit is contained in:
gpt-engineer-app[bot]
2025-10-28 15:00:06 +00:00
parent cedd33cc34
commit 27864d99a6

View File

@@ -92,14 +92,61 @@ const Operators = () => {
if (!operators) return [];
let filtered = operators.filter(operator => {
// Search filter
const matchesSearch = operator.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
(operator.description && operator.description.toLowerCase().includes(searchTerm.toLowerCase()));
if (filterBy === 'all') return matchesSearch;
if (filterBy === 'with-rating') return matchesSearch && operator.average_rating > 0;
if (filterBy === 'established') return matchesSearch && operator.founded_year;
if (!matchesSearch) return false;
// Country filter
if (filters.countries.length > 0) {
if (!operator.headquarters_location || !filters.countries.some(c => operator.headquarters_location?.includes(c))) {
return false;
}
}
// Rating filter
const rating = operator.average_rating || 0;
if (rating < filters.minRating || rating > filters.maxRating) {
return false;
}
// Review count filter
const reviewCount = operator.review_count || 0;
if (reviewCount < filters.minReviewCount || reviewCount > filters.maxReviewCount) {
return false;
}
// Park count filter
const parkCount = operator.park_count || 0;
if (parkCount < filters.minParkCount || parkCount > filters.maxParkCount) {
return false;
}
// Founded date filter
if (filters.foundedDateFrom || filters.foundedDateTo) {
if (!operator.founded_year) {
return false;
}
if (filters.foundedDateFrom && operator.founded_year < filters.foundedDateFrom.getFullYear()) {
return false;
}
if (filters.foundedDateTo && operator.founded_year > filters.foundedDateTo.getFullYear()) {
return false;
}
}
// Has rating filter
if (filters.hasRating && !operator.average_rating) {
return false;
}
// Has founded date filter
if (filters.hasFoundedDate && !operator.founded_year) {
return false;
}
return matchesSearch;
return true;
});
// Sort
@@ -119,7 +166,7 @@ const Operators = () => {
});
return filtered;
}, [operators, searchTerm, sortBy, filterBy]);
}, [operators, searchTerm, sortBy, filters]);
return (
<div className="min-h-screen bg-background">