mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 18:31:11 -05:00
Refactor: Convert park filters to multi-select
This commit is contained in:
@@ -18,9 +18,9 @@ import { FilterState, SortState } from './Parks';
|
||||
|
||||
const initialFilters: FilterState = {
|
||||
search: '',
|
||||
parkType: 'all',
|
||||
status: 'all',
|
||||
country: 'all',
|
||||
parkType: [],
|
||||
status: [],
|
||||
country: [],
|
||||
minRating: 0,
|
||||
maxRating: 5,
|
||||
minRides: 0,
|
||||
@@ -98,9 +98,9 @@ export default function OperatorParks() {
|
||||
park.location?.country?.toLowerCase().includes(searchTerm);
|
||||
if (!matchesSearch) return false;
|
||||
}
|
||||
if (filters.parkType !== 'all' && park.park_type !== filters.parkType) return false;
|
||||
if (filters.status !== 'all' && park.status !== filters.status) return false;
|
||||
if (filters.country !== 'all' && park.location?.country !== filters.country) return false;
|
||||
if (filters.parkType.length > 0 && !filters.parkType.includes(park.park_type)) return false;
|
||||
if (filters.status.length > 0 && !filters.status.includes(park.status)) return false;
|
||||
if (filters.country.length > 0 && !filters.country.includes(park.location?.country || '')) return false;
|
||||
|
||||
const rating = park.average_rating || 0;
|
||||
if (rating < filters.minRating || rating > filters.maxRating) return false;
|
||||
|
||||
@@ -18,9 +18,9 @@ import { FilterState, SortState } from './Parks';
|
||||
|
||||
const initialFilters: FilterState = {
|
||||
search: '',
|
||||
parkType: 'all',
|
||||
status: 'all',
|
||||
country: 'all',
|
||||
parkType: [],
|
||||
status: [],
|
||||
country: [],
|
||||
minRating: 0,
|
||||
maxRating: 5,
|
||||
minRides: 0,
|
||||
@@ -98,9 +98,9 @@ export default function OwnerParks() {
|
||||
park.location?.country?.toLowerCase().includes(searchTerm);
|
||||
if (!matchesSearch) return false;
|
||||
}
|
||||
if (filters.parkType !== 'all' && park.park_type !== filters.parkType) return false;
|
||||
if (filters.status !== 'all' && park.status !== filters.status) return false;
|
||||
if (filters.country !== 'all' && park.location?.country !== filters.country) return false;
|
||||
if (filters.parkType.length > 0 && !filters.parkType.includes(park.park_type)) return false;
|
||||
if (filters.status.length > 0 && !filters.status.includes(park.status)) return false;
|
||||
if (filters.country.length > 0 && !filters.country.includes(park.location?.country || '')) return false;
|
||||
|
||||
const rating = park.average_rating || 0;
|
||||
if (rating < filters.minRating || rating > filters.maxRating) return false;
|
||||
|
||||
@@ -39,9 +39,9 @@ import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
|
||||
export interface FilterState {
|
||||
search: string;
|
||||
parkType: string;
|
||||
status: string;
|
||||
country: string;
|
||||
parkType: string[];
|
||||
status: string[];
|
||||
country: string[];
|
||||
states?: string[];
|
||||
cities?: string[];
|
||||
operators?: string[];
|
||||
@@ -65,9 +65,9 @@ export interface SortState {
|
||||
|
||||
const initialFilters: FilterState = {
|
||||
search: '',
|
||||
parkType: 'all',
|
||||
status: 'all',
|
||||
country: 'all',
|
||||
parkType: [],
|
||||
status: [],
|
||||
country: [],
|
||||
states: [],
|
||||
cities: [],
|
||||
operators: [],
|
||||
@@ -158,17 +158,17 @@ export default function Parks() {
|
||||
}
|
||||
|
||||
// Park type filter
|
||||
if (filters.parkType !== 'all' && park.park_type !== filters.parkType) {
|
||||
if (filters.parkType.length > 0 && !filters.parkType.includes(park.park_type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Status filter
|
||||
if (filters.status !== 'all' && park.status !== filters.status) {
|
||||
if (filters.status.length > 0 && !filters.status.includes(park.status)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Country filter
|
||||
if (filters.country !== 'all' && park.location?.country !== filters.country) {
|
||||
if (filters.country.length > 0 && !filters.country.includes(park.location?.country || '')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -291,9 +291,9 @@ export default function Parks() {
|
||||
const activeFilterCount = useMemo(() => {
|
||||
let count = 0;
|
||||
if (filters.search) count++;
|
||||
if (filters.parkType !== 'all') count++;
|
||||
if (filters.status !== 'all') count++;
|
||||
if (filters.country !== 'all') count++;
|
||||
if (filters.parkType.length > 0) count++;
|
||||
if (filters.status.length > 0) count++;
|
||||
if (filters.country.length > 0) count++;
|
||||
if (filters.minRating > 0 || filters.maxRating < 5) count++;
|
||||
if (filters.minRides > 0 || filters.maxRides < 1000) count++;
|
||||
if (filters.openingYearStart || filters.openingYearEnd) count++;
|
||||
|
||||
Reference in New Issue
Block a user