mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 23:51:13 -05:00
Fix: Correct filter variable name
This commit is contained in:
@@ -92,14 +92,61 @@ const Operators = () => {
|
|||||||
if (!operators) return [];
|
if (!operators) return [];
|
||||||
|
|
||||||
let filtered = operators.filter(operator => {
|
let filtered = operators.filter(operator => {
|
||||||
|
// Search filter
|
||||||
const matchesSearch = operator.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
const matchesSearch = operator.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||||
(operator.description && operator.description.toLowerCase().includes(searchTerm.toLowerCase()));
|
(operator.description && operator.description.toLowerCase().includes(searchTerm.toLowerCase()));
|
||||||
|
|
||||||
if (filterBy === 'all') return matchesSearch;
|
if (!matchesSearch) return false;
|
||||||
if (filterBy === 'with-rating') return matchesSearch && operator.average_rating > 0;
|
|
||||||
if (filterBy === 'established') return matchesSearch && operator.founded_year;
|
|
||||||
|
|
||||||
return matchesSearch;
|
// 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 true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
@@ -119,7 +166,7 @@ const Operators = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return filtered;
|
return filtered;
|
||||||
}, [operators, searchTerm, sortBy, filterBy]);
|
}, [operators, searchTerm, sortBy, filters]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-background">
|
<div className="min-h-screen bg-background">
|
||||||
|
|||||||
Reference in New Issue
Block a user