mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-30 18:26:59 -05:00
Compare commits
5 Commits
ef312618f5
...
ba1c0625b0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba1c0625b0 | ||
|
|
575ccd013b | ||
|
|
832f53a126 | ||
|
|
c48509efc4 | ||
|
|
477844310f |
@@ -82,16 +82,14 @@ export function ParkFilters({ filters, onFiltersChange, parks }: ParkFiltersProp
|
|||||||
return (propertyOwners || []).map(p => ({ label: p.name, value: p.id }));
|
return (propertyOwners || []).map(p => ({ label: p.name, value: p.id }));
|
||||||
}, [propertyOwners]);
|
}, [propertyOwners]);
|
||||||
|
|
||||||
const parkTypes = [
|
const parkTypes: MultiSelectOption[] = [
|
||||||
{ value: 'all', label: 'All Types' },
|
{ value: 'theme_park', label: 'Theme Park' },
|
||||||
{ value: 'theme_park', label: 'Theme Parks' },
|
{ value: 'amusement_park', label: 'Amusement Park' },
|
||||||
{ value: 'amusement_park', label: 'Amusement Parks' },
|
{ value: 'water_park', label: 'Water Park' },
|
||||||
{ value: 'water_park', label: 'Water Parks' },
|
|
||||||
{ value: 'family_entertainment', label: 'Family Entertainment' }
|
{ value: 'family_entertainment', label: 'Family Entertainment' }
|
||||||
];
|
];
|
||||||
|
|
||||||
const statusOptions = [
|
const statusOptions: MultiSelectOption[] = [
|
||||||
{ value: 'all', label: 'All Status' },
|
|
||||||
{ value: 'operating', label: 'Operating' },
|
{ value: 'operating', label: 'Operating' },
|
||||||
{ value: 'seasonal', label: 'Seasonal' },
|
{ value: 'seasonal', label: 'Seasonal' },
|
||||||
{ value: 'under_construction', label: 'Under Construction' },
|
{ value: 'under_construction', label: 'Under Construction' },
|
||||||
@@ -113,9 +111,9 @@ export function ParkFilters({ filters, onFiltersChange, parks }: ParkFiltersProp
|
|||||||
const resetFilters = () => {
|
const resetFilters = () => {
|
||||||
onFiltersChange({
|
onFiltersChange({
|
||||||
search: '',
|
search: '',
|
||||||
parkType: 'all',
|
parkType: [],
|
||||||
status: 'all',
|
status: [],
|
||||||
country: 'all',
|
country: [],
|
||||||
states: [],
|
states: [],
|
||||||
cities: [],
|
cities: [],
|
||||||
operators: [],
|
operators: [],
|
||||||
@@ -145,66 +143,29 @@ export function ParkFilters({ filters, onFiltersChange, parks }: ParkFiltersProp
|
|||||||
|
|
||||||
<FilterSection title="Basic Filters">
|
<FilterSection title="Basic Filters">
|
||||||
<div className="grid grid-cols-1 gap-4">
|
<div className="grid grid-cols-1 gap-4">
|
||||||
{/* Park Type */}
|
<FilterMultiSelectCombobox
|
||||||
<div className="space-y-2">
|
label="Park Type"
|
||||||
<Label>Park Type</Label>
|
options={parkTypes}
|
||||||
<Select
|
value={filters.parkType}
|
||||||
value={filters.parkType}
|
onChange={(value) => onFiltersChange({ ...filters, parkType: value })}
|
||||||
onValueChange={(value) => onFiltersChange({ ...filters, parkType: value })}
|
placeholder="Select park types"
|
||||||
>
|
/>
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{parkTypes.map(type => (
|
|
||||||
<SelectItem key={type.value} value={type.value}>
|
|
||||||
{type.label}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Status */}
|
<FilterMultiSelectCombobox
|
||||||
<div className="space-y-2">
|
label="Status"
|
||||||
<Label>Status</Label>
|
options={statusOptions}
|
||||||
<Select
|
value={filters.status}
|
||||||
value={filters.status}
|
onChange={(value) => onFiltersChange({ ...filters, status: value })}
|
||||||
onValueChange={(value) => onFiltersChange({ ...filters, status: value })}
|
placeholder="Select status"
|
||||||
>
|
/>
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{statusOptions.map(status => (
|
|
||||||
<SelectItem key={status.value} value={status.value}>
|
|
||||||
{status.label}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Country */}
|
<FilterMultiSelectCombobox
|
||||||
<div className="space-y-2">
|
label="Country"
|
||||||
<Label>Country</Label>
|
options={countryOptions}
|
||||||
<Select
|
value={filters.country}
|
||||||
value={filters.country}
|
onChange={(value) => onFiltersChange({ ...filters, country: value })}
|
||||||
onValueChange={(value) => onFiltersChange({ ...filters, country: value })}
|
placeholder="Select countries"
|
||||||
>
|
/>
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value="all">All Countries</SelectItem>
|
|
||||||
{Array.from(new Set(locations?.map(l => l.country).filter(Boolean) || [])).sort().map(country => (
|
|
||||||
<SelectItem key={country} value={country}>
|
|
||||||
{country}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<FilterMultiSelectCombobox
|
<FilterMultiSelectCombobox
|
||||||
label="States/Provinces"
|
label="States/Provinces"
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ export function ParkSortOptions({ sort, onSortChange }: ParkSortOptionsProps) {
|
|||||||
const sortOptions = [
|
const sortOptions = [
|
||||||
{ value: 'name', label: 'Name' },
|
{ value: 'name', label: 'Name' },
|
||||||
{ value: 'rating', label: 'Rating' },
|
{ value: 'rating', label: 'Rating' },
|
||||||
{ value: 'rides', label: 'Ride Count' },
|
{ value: 'rides', label: 'Rides' },
|
||||||
{ value: 'coasters', label: 'Coaster Count' },
|
{ value: 'coasters', label: 'Coasters' },
|
||||||
{ value: 'reviews', label: 'Review Count' },
|
{ value: 'reviews', label: 'Reviews' },
|
||||||
{ value: 'opening', label: 'Opening Date' },
|
{ value: 'opening', label: 'Opening' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const toggleDirection = () => {
|
const toggleDirection = () => {
|
||||||
@@ -26,19 +26,19 @@ export function ParkSortOptions({ sort, onSortChange }: ParkSortOptionsProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-2 flex-1">
|
<div className="flex gap-2">
|
||||||
<Select
|
<Select
|
||||||
value={sort.field}
|
value={sort.field}
|
||||||
onValueChange={(field) => onSortChange({ ...sort, field })}
|
onValueChange={(field) => onSortChange({ ...sort, field })}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="flex-1 bg-muted/50 border-border/50">
|
<SelectTrigger className="w-[160px] bg-muted/50 border-border/50">
|
||||||
<ArrowUpDown className="w-4 h-4 mr-2" />
|
<ArrowUpDown className="w-4 h-4 mr-2" />
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{sortOptions.map(option => (
|
{sortOptions.map(option => (
|
||||||
<SelectItem key={option.value} value={option.value}>
|
<SelectItem key={option.value} value={option.value}>
|
||||||
Sort by {option.label}
|
{option.label}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import { Button } from '@/components/ui/button';
|
|||||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||||
import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible';
|
import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Search, SlidersHorizontal, Ruler, Plus, ChevronDown, Filter } from 'lucide-react';
|
import { Search, SlidersHorizontal, Ruler, Plus, ChevronDown, Filter, PanelLeftClose, PanelLeftOpen } from 'lucide-react';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
import { DesignerFilters, DesignerFilterState, defaultDesignerFilters } from '@/components/designers/DesignerFilters';
|
import { DesignerFilters, DesignerFilterState, defaultDesignerFilters } from '@/components/designers/DesignerFilters';
|
||||||
import { Company } from '@/types/database';
|
import { Company } from '@/types/database';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
@@ -33,6 +34,10 @@ export default function Designers() {
|
|||||||
const [filters, setFilters] = useState<DesignerFilterState>(defaultDesignerFilters);
|
const [filters, setFilters] = useState<DesignerFilterState>(defaultDesignerFilters);
|
||||||
const [showFilters, setShowFilters] = useState(false);
|
const [showFilters, setShowFilters] = useState(false);
|
||||||
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
||||||
|
const [sidebarCollapsed, setSidebarCollapsed] = useState(() => {
|
||||||
|
const saved = localStorage.getItem('designers-sidebar-collapsed');
|
||||||
|
return saved ? JSON.parse(saved) : false;
|
||||||
|
});
|
||||||
|
|
||||||
const handleCreateSubmit = async (data: any) => {
|
const handleCreateSubmit = async (data: any) => {
|
||||||
try {
|
try {
|
||||||
@@ -52,6 +57,10 @@ export default function Designers() {
|
|||||||
fetchCompanies();
|
fetchCompanies();
|
||||||
}, [sortBy]);
|
}, [sortBy]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem('designers-sidebar-collapsed', JSON.stringify(sidebarCollapsed));
|
||||||
|
}, [sidebarCollapsed]);
|
||||||
|
|
||||||
const fetchCompanies = async () => {
|
const fetchCompanies = async () => {
|
||||||
try {
|
try {
|
||||||
let query = supabase
|
let query = supabase
|
||||||
@@ -140,6 +149,22 @@ export default function Designers() {
|
|||||||
{/* Search and Filters */}
|
{/* Search and Filters */}
|
||||||
<div className="mb-6 space-y-4">
|
<div className="mb-6 space-y-4">
|
||||||
<div className="flex flex-col lg:flex-row gap-4">
|
<div className="flex flex-col lg:flex-row gap-4">
|
||||||
|
{/* Desktop: Filter toggle on the left */}
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => setSidebarCollapsed(!sidebarCollapsed)}
|
||||||
|
className="shrink-0 gap-2 hidden lg:flex"
|
||||||
|
title={sidebarCollapsed ? "Show filters" : "Hide filters"}
|
||||||
|
>
|
||||||
|
{sidebarCollapsed ? (
|
||||||
|
<PanelLeftOpen className="w-4 h-4" />
|
||||||
|
) : (
|
||||||
|
<PanelLeftClose className="w-4 h-4" />
|
||||||
|
)}
|
||||||
|
<span>Filters</span>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* Search bar takes remaining space */}
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4" />
|
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4" />
|
||||||
@@ -152,18 +177,20 @@ export default function Designers() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Sort controls - more compact */}
|
||||||
<div className="flex gap-2 w-full lg:w-auto">
|
<div className="flex gap-2 w-full lg:w-auto">
|
||||||
<Select value={sortBy} onValueChange={setSortBy}>
|
<Select value={sortBy} onValueChange={setSortBy}>
|
||||||
<SelectTrigger className="w-[180px] h-10">
|
<SelectTrigger className="w-[160px] h-10">
|
||||||
<SlidersHorizontal className="h-4 w-4 mr-2" />
|
<SlidersHorizontal className="h-4 w-4 mr-2" />
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="name">Name A-Z</SelectItem>
|
<SelectItem value="name">Name</SelectItem>
|
||||||
<SelectItem value="founded">Founded (Newest)</SelectItem>
|
<SelectItem value="founded">Founded</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
|
{/* Mobile filter toggle */}
|
||||||
<Button
|
<Button
|
||||||
variant={showFilters ? "default" : "outline"}
|
variant={showFilters ? "default" : "outline"}
|
||||||
onClick={() => setShowFilters(!showFilters)}
|
onClick={() => setShowFilters(!showFilters)}
|
||||||
@@ -193,15 +220,28 @@ export default function Designers() {
|
|||||||
{/* Main Content Area with Sidebar */}
|
{/* Main Content Area with Sidebar */}
|
||||||
<div className="flex flex-col lg:flex-row gap-6">
|
<div className="flex flex-col lg:flex-row gap-6">
|
||||||
{/* Desktop Filter Sidebar */}
|
{/* Desktop Filter Sidebar */}
|
||||||
<aside className="hidden lg:block lg:w-[340px] xl:w-[380px] 2xl:w-[420px] flex-shrink-0">
|
{!sidebarCollapsed && (
|
||||||
<div className="sticky top-24">
|
<aside className="hidden lg:block flex-shrink-0 transition-all duration-300 lg:w-[340px] xl:w-[380px] 2xl:w-[420px]">
|
||||||
<Card>
|
<div className="sticky top-24">
|
||||||
<CardContent className="pt-6">
|
<Card>
|
||||||
<DesignerFilters filters={filters} onFiltersChange={setFilters} designers={companies} />
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
</CardContent>
|
<CardTitle className="text-base">Filters</CardTitle>
|
||||||
</Card>
|
<Button
|
||||||
</div>
|
variant="ghost"
|
||||||
</aside>
|
size="sm"
|
||||||
|
onClick={() => setSidebarCollapsed(true)}
|
||||||
|
title="Hide filters"
|
||||||
|
>
|
||||||
|
<PanelLeftClose className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<DesignerFilters filters={filters} onFiltersChange={setFilters} designers={companies} />
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Results Area */}
|
{/* Results Area */}
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import { Button } from '@/components/ui/button';
|
|||||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||||
import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible';
|
import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Search, SlidersHorizontal, Factory, Plus, ChevronDown, Filter } from 'lucide-react';
|
import { Search, SlidersHorizontal, Factory, Plus, ChevronDown, Filter, PanelLeftClose, PanelLeftOpen } from 'lucide-react';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
import { ManufacturerFilters, ManufacturerFilterState, defaultManufacturerFilters } from '@/components/manufacturers/ManufacturerFilters';
|
import { ManufacturerFilters, ManufacturerFilterState, defaultManufacturerFilters } from '@/components/manufacturers/ManufacturerFilters';
|
||||||
import { Company } from '@/types/database';
|
import { Company } from '@/types/database';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
@@ -33,12 +34,20 @@ export default function Manufacturers() {
|
|||||||
const [filters, setFilters] = useState<ManufacturerFilterState>(defaultManufacturerFilters);
|
const [filters, setFilters] = useState<ManufacturerFilterState>(defaultManufacturerFilters);
|
||||||
const [showFilters, setShowFilters] = useState(false);
|
const [showFilters, setShowFilters] = useState(false);
|
||||||
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
||||||
|
const [sidebarCollapsed, setSidebarCollapsed] = useState(() => {
|
||||||
|
const saved = localStorage.getItem('manufacturers-sidebar-collapsed');
|
||||||
|
return saved ? JSON.parse(saved) : false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchCompanies();
|
fetchCompanies();
|
||||||
}, [sortBy]);
|
}, [sortBy]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem('manufacturers-sidebar-collapsed', JSON.stringify(sidebarCollapsed));
|
||||||
|
}, [sidebarCollapsed]);
|
||||||
|
|
||||||
const fetchCompanies = async () => {
|
const fetchCompanies = async () => {
|
||||||
try {
|
try {
|
||||||
let query = supabase
|
let query = supabase
|
||||||
@@ -153,6 +162,22 @@ export default function Manufacturers() {
|
|||||||
{/* Search and Filters */}
|
{/* Search and Filters */}
|
||||||
<div className="mb-6 space-y-4">
|
<div className="mb-6 space-y-4">
|
||||||
<div className="flex flex-col lg:flex-row gap-4">
|
<div className="flex flex-col lg:flex-row gap-4">
|
||||||
|
{/* Desktop: Filter toggle on the left */}
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => setSidebarCollapsed(!sidebarCollapsed)}
|
||||||
|
className="shrink-0 gap-2 hidden lg:flex"
|
||||||
|
title={sidebarCollapsed ? "Show filters" : "Hide filters"}
|
||||||
|
>
|
||||||
|
{sidebarCollapsed ? (
|
||||||
|
<PanelLeftOpen className="w-4 h-4" />
|
||||||
|
) : (
|
||||||
|
<PanelLeftClose className="w-4 h-4" />
|
||||||
|
)}
|
||||||
|
<span>Filters</span>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* Search bar takes remaining space */}
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4" />
|
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4" />
|
||||||
@@ -165,18 +190,20 @@ export default function Manufacturers() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Sort controls - more compact */}
|
||||||
<div className="flex gap-2 w-full lg:w-auto">
|
<div className="flex gap-2 w-full lg:w-auto">
|
||||||
<Select value={sortBy} onValueChange={setSortBy}>
|
<Select value={sortBy} onValueChange={setSortBy}>
|
||||||
<SelectTrigger className="w-[180px] h-10">
|
<SelectTrigger className="w-[160px] h-10">
|
||||||
<SlidersHorizontal className="h-4 w-4 mr-2" />
|
<SlidersHorizontal className="h-4 w-4 mr-2" />
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="name">Name A-Z</SelectItem>
|
<SelectItem value="name">Name</SelectItem>
|
||||||
<SelectItem value="founded">Founded (Newest)</SelectItem>
|
<SelectItem value="founded">Founded</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
|
{/* Mobile filter toggle */}
|
||||||
<Button
|
<Button
|
||||||
variant={showFilters ? "default" : "outline"}
|
variant={showFilters ? "default" : "outline"}
|
||||||
onClick={() => setShowFilters(!showFilters)}
|
onClick={() => setShowFilters(!showFilters)}
|
||||||
@@ -206,15 +233,28 @@ export default function Manufacturers() {
|
|||||||
{/* Main Content Area with Sidebar */}
|
{/* Main Content Area with Sidebar */}
|
||||||
<div className="flex flex-col lg:flex-row gap-6">
|
<div className="flex flex-col lg:flex-row gap-6">
|
||||||
{/* Desktop Filter Sidebar */}
|
{/* Desktop Filter Sidebar */}
|
||||||
<aside className="hidden lg:block lg:w-[340px] xl:w-[380px] 2xl:w-[420px] flex-shrink-0">
|
{!sidebarCollapsed && (
|
||||||
<div className="sticky top-24">
|
<aside className="hidden lg:block flex-shrink-0 transition-all duration-300 lg:w-[340px] xl:w-[380px] 2xl:w-[420px]">
|
||||||
<Card>
|
<div className="sticky top-24">
|
||||||
<CardContent className="pt-6">
|
<Card>
|
||||||
<ManufacturerFilters filters={filters} onFiltersChange={setFilters} manufacturers={companies} />
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
</CardContent>
|
<CardTitle className="text-base">Filters</CardTitle>
|
||||||
</Card>
|
<Button
|
||||||
</div>
|
variant="ghost"
|
||||||
</aside>
|
size="sm"
|
||||||
|
onClick={() => setSidebarCollapsed(true)}
|
||||||
|
title="Hide filters"
|
||||||
|
>
|
||||||
|
<PanelLeftClose className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<ManufacturerFilters filters={filters} onFiltersChange={setFilters} manufacturers={companies} />
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Results Area */}
|
{/* Results Area */}
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ import { FilterState, SortState } from './Parks';
|
|||||||
|
|
||||||
const initialFilters: FilterState = {
|
const initialFilters: FilterState = {
|
||||||
search: '',
|
search: '',
|
||||||
parkType: 'all',
|
parkType: [],
|
||||||
status: 'all',
|
status: [],
|
||||||
country: 'all',
|
country: [],
|
||||||
minRating: 0,
|
minRating: 0,
|
||||||
maxRating: 5,
|
maxRating: 5,
|
||||||
minRides: 0,
|
minRides: 0,
|
||||||
@@ -98,9 +98,9 @@ export default function OperatorParks() {
|
|||||||
park.location?.country?.toLowerCase().includes(searchTerm);
|
park.location?.country?.toLowerCase().includes(searchTerm);
|
||||||
if (!matchesSearch) return false;
|
if (!matchesSearch) return false;
|
||||||
}
|
}
|
||||||
if (filters.parkType !== 'all' && park.park_type !== filters.parkType) return false;
|
if (filters.parkType.length > 0 && !filters.parkType.includes(park.park_type)) return false;
|
||||||
if (filters.status !== 'all' && park.status !== filters.status) return false;
|
if (filters.status.length > 0 && !filters.status.includes(park.status)) return false;
|
||||||
if (filters.country !== 'all' && park.location?.country !== filters.country) return false;
|
if (filters.country.length > 0 && !filters.country.includes(park.location?.country || '')) return false;
|
||||||
|
|
||||||
const rating = park.average_rating || 0;
|
const rating = park.average_rating || 0;
|
||||||
if (rating < filters.minRating || rating > filters.maxRating) return false;
|
if (rating < filters.minRating || rating > filters.maxRating) return false;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Header } from '@/components/layout/Header';
|
import { Header } from '@/components/layout/Header';
|
||||||
@@ -8,8 +8,9 @@ import { Badge } from '@/components/ui/badge';
|
|||||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||||
import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible';
|
import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Search, Filter, Building, Plus, ChevronDown } from 'lucide-react';
|
import { Search, Filter, Building, Plus, ChevronDown, PanelLeftClose, PanelLeftOpen } from 'lucide-react';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
import OperatorCard from '@/components/operators/OperatorCard';
|
import OperatorCard from '@/components/operators/OperatorCard';
|
||||||
import { OperatorForm } from '@/components/admin/OperatorForm';
|
import { OperatorForm } from '@/components/admin/OperatorForm';
|
||||||
@@ -32,6 +33,14 @@ const Operators = () => {
|
|||||||
const [filters, setFilters] = useState<OperatorFilterState>(defaultOperatorFilters);
|
const [filters, setFilters] = useState<OperatorFilterState>(defaultOperatorFilters);
|
||||||
const [showFilters, setShowFilters] = useState(false);
|
const [showFilters, setShowFilters] = useState(false);
|
||||||
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
||||||
|
const [sidebarCollapsed, setSidebarCollapsed] = useState(() => {
|
||||||
|
const saved = localStorage.getItem('operators-sidebar-collapsed');
|
||||||
|
return saved ? JSON.parse(saved) : false;
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem('operators-sidebar-collapsed', JSON.stringify(sidebarCollapsed));
|
||||||
|
}, [sidebarCollapsed]);
|
||||||
|
|
||||||
const { data: operators, isLoading } = useQuery({
|
const { data: operators, isLoading } = useQuery({
|
||||||
queryKey: ['operators'],
|
queryKey: ['operators'],
|
||||||
@@ -210,6 +219,22 @@ const Operators = () => {
|
|||||||
{/* Search and Filters */}
|
{/* Search and Filters */}
|
||||||
<div className="mb-6 space-y-4">
|
<div className="mb-6 space-y-4">
|
||||||
<div className="flex flex-col lg:flex-row gap-4">
|
<div className="flex flex-col lg:flex-row gap-4">
|
||||||
|
{/* Desktop: Filter toggle on the left */}
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => setSidebarCollapsed(!sidebarCollapsed)}
|
||||||
|
className="shrink-0 gap-2 hidden lg:flex"
|
||||||
|
title={sidebarCollapsed ? "Show filters" : "Hide filters"}
|
||||||
|
>
|
||||||
|
{sidebarCollapsed ? (
|
||||||
|
<PanelLeftOpen className="w-4 h-4" />
|
||||||
|
) : (
|
||||||
|
<PanelLeftClose className="w-4 h-4" />
|
||||||
|
)}
|
||||||
|
<span>Filters</span>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* Search bar takes remaining space */}
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4" />
|
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4" />
|
||||||
@@ -222,19 +247,21 @@ const Operators = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Sort controls - more compact */}
|
||||||
<div className="flex gap-2 w-full lg:w-auto">
|
<div className="flex gap-2 w-full lg:w-auto">
|
||||||
<Select value={sortBy} onValueChange={setSortBy}>
|
<Select value={sortBy} onValueChange={setSortBy}>
|
||||||
<SelectTrigger className="w-[180px] h-10">
|
<SelectTrigger className="w-[160px] h-10">
|
||||||
<SelectValue placeholder="Sort by" />
|
<SelectValue placeholder="Sort by" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="name">Name</SelectItem>
|
<SelectItem value="name">Name</SelectItem>
|
||||||
<SelectItem value="rating">Rating</SelectItem>
|
<SelectItem value="rating">Rating</SelectItem>
|
||||||
<SelectItem value="founded">Founded Year</SelectItem>
|
<SelectItem value="founded">Founded</SelectItem>
|
||||||
<SelectItem value="reviews">Review Count</SelectItem>
|
<SelectItem value="reviews">Reviews</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
|
{/* Mobile filter toggle */}
|
||||||
<Button
|
<Button
|
||||||
variant={showFilters ? "default" : "outline"}
|
variant={showFilters ? "default" : "outline"}
|
||||||
onClick={() => setShowFilters(!showFilters)}
|
onClick={() => setShowFilters(!showFilters)}
|
||||||
@@ -264,15 +291,28 @@ const Operators = () => {
|
|||||||
{/* Main Content Area with Sidebar */}
|
{/* Main Content Area with Sidebar */}
|
||||||
<div className="flex flex-col lg:flex-row gap-6">
|
<div className="flex flex-col lg:flex-row gap-6">
|
||||||
{/* Desktop Filter Sidebar */}
|
{/* Desktop Filter Sidebar */}
|
||||||
<aside className="hidden lg:block lg:w-[340px] xl:w-[380px] 2xl:w-[420px] flex-shrink-0">
|
{!sidebarCollapsed && (
|
||||||
<div className="sticky top-24">
|
<aside className="hidden lg:block flex-shrink-0 transition-all duration-300 lg:w-[340px] xl:w-[380px] 2xl:w-[420px]">
|
||||||
<Card>
|
<div className="sticky top-24">
|
||||||
<CardContent className="pt-6">
|
<Card>
|
||||||
<OperatorFilters filters={filters} onFiltersChange={setFilters} operators={operators || []} />
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
</CardContent>
|
<CardTitle className="text-base">Filters</CardTitle>
|
||||||
</Card>
|
<Button
|
||||||
</div>
|
variant="ghost"
|
||||||
</aside>
|
size="sm"
|
||||||
|
onClick={() => setSidebarCollapsed(true)}
|
||||||
|
title="Hide filters"
|
||||||
|
>
|
||||||
|
<PanelLeftClose className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<OperatorFilters filters={filters} onFiltersChange={setFilters} operators={operators || []} />
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Results Area */}
|
{/* Results Area */}
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ import { FilterState, SortState } from './Parks';
|
|||||||
|
|
||||||
const initialFilters: FilterState = {
|
const initialFilters: FilterState = {
|
||||||
search: '',
|
search: '',
|
||||||
parkType: 'all',
|
parkType: [],
|
||||||
status: 'all',
|
status: [],
|
||||||
country: 'all',
|
country: [],
|
||||||
minRating: 0,
|
minRating: 0,
|
||||||
maxRating: 5,
|
maxRating: 5,
|
||||||
minRides: 0,
|
minRides: 0,
|
||||||
@@ -98,9 +98,9 @@ export default function OwnerParks() {
|
|||||||
park.location?.country?.toLowerCase().includes(searchTerm);
|
park.location?.country?.toLowerCase().includes(searchTerm);
|
||||||
if (!matchesSearch) return false;
|
if (!matchesSearch) return false;
|
||||||
}
|
}
|
||||||
if (filters.parkType !== 'all' && park.park_type !== filters.parkType) return false;
|
if (filters.parkType.length > 0 && !filters.parkType.includes(park.park_type)) return false;
|
||||||
if (filters.status !== 'all' && park.status !== filters.status) return false;
|
if (filters.status.length > 0 && !filters.status.includes(park.status)) return false;
|
||||||
if (filters.country !== 'all' && park.location?.country !== filters.country) return false;
|
if (filters.country.length > 0 && !filters.country.includes(park.location?.country || '')) return false;
|
||||||
|
|
||||||
const rating = park.average_rating || 0;
|
const rating = park.average_rating || 0;
|
||||||
if (rating < filters.minRating || rating > filters.maxRating) return false;
|
if (rating < filters.minRating || rating > filters.maxRating) return false;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { useState, useEffect, useMemo } from 'react';
|
import { useState, useEffect, useMemo } from 'react';
|
||||||
import { Header } from '@/components/layout/Header';
|
import { Header } from '@/components/layout/Header';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible';
|
import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
@@ -17,7 +18,9 @@ import {
|
|||||||
Sliders,
|
Sliders,
|
||||||
X,
|
X,
|
||||||
FerrisWheel,
|
FerrisWheel,
|
||||||
Plus
|
Plus,
|
||||||
|
PanelLeftClose,
|
||||||
|
PanelLeftOpen
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { Park } from '@/types/database';
|
import { Park } from '@/types/database';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
@@ -36,9 +39,9 @@ import { useAuthModal } from '@/hooks/useAuthModal';
|
|||||||
|
|
||||||
export interface FilterState {
|
export interface FilterState {
|
||||||
search: string;
|
search: string;
|
||||||
parkType: string;
|
parkType: string[];
|
||||||
status: string;
|
status: string[];
|
||||||
country: string;
|
country: string[];
|
||||||
states?: string[];
|
states?: string[];
|
||||||
cities?: string[];
|
cities?: string[];
|
||||||
operators?: string[];
|
operators?: string[];
|
||||||
@@ -62,9 +65,9 @@ export interface SortState {
|
|||||||
|
|
||||||
const initialFilters: FilterState = {
|
const initialFilters: FilterState = {
|
||||||
search: '',
|
search: '',
|
||||||
parkType: 'all',
|
parkType: [],
|
||||||
status: 'all',
|
status: [],
|
||||||
country: 'all',
|
country: [],
|
||||||
states: [],
|
states: [],
|
||||||
cities: [],
|
cities: [],
|
||||||
operators: [],
|
operators: [],
|
||||||
@@ -94,6 +97,10 @@ export default function Parks() {
|
|||||||
const [viewMode, setViewMode] = useState<'grid' | 'list'>('grid');
|
const [viewMode, setViewMode] = useState<'grid' | 'list'>('grid');
|
||||||
const [showFilters, setShowFilters] = useState(false);
|
const [showFilters, setShowFilters] = useState(false);
|
||||||
const [isAddParkModalOpen, setIsAddParkModalOpen] = useState(false);
|
const [isAddParkModalOpen, setIsAddParkModalOpen] = useState(false);
|
||||||
|
const [sidebarCollapsed, setSidebarCollapsed] = useState(() => {
|
||||||
|
const saved = localStorage.getItem('parks-sidebar-collapsed');
|
||||||
|
return saved ? JSON.parse(saved) : false;
|
||||||
|
});
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
@@ -104,6 +111,10 @@ export default function Parks() {
|
|||||||
fetchParks();
|
fetchParks();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem('parks-sidebar-collapsed', JSON.stringify(sidebarCollapsed));
|
||||||
|
}, [sidebarCollapsed]);
|
||||||
|
|
||||||
const fetchParks = async () => {
|
const fetchParks = async () => {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -147,17 +158,17 @@ export default function Parks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Park type filter
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status filter
|
// Status filter
|
||||||
if (filters.status !== 'all' && park.status !== filters.status) {
|
if (filters.status.length > 0 && !filters.status.includes(park.status)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Country filter
|
// Country filter
|
||||||
if (filters.country !== 'all' && park.location?.country !== filters.country) {
|
if (filters.country.length > 0 && !filters.country.includes(park.location?.country || '')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,9 +291,9 @@ export default function Parks() {
|
|||||||
const activeFilterCount = useMemo(() => {
|
const activeFilterCount = useMemo(() => {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
if (filters.search) count++;
|
if (filters.search) count++;
|
||||||
if (filters.parkType !== 'all') count++;
|
if (filters.parkType.length > 0) count++;
|
||||||
if (filters.status !== 'all') count++;
|
if (filters.status.length > 0) count++;
|
||||||
if (filters.country !== 'all') count++;
|
if (filters.country.length > 0) count++;
|
||||||
if (filters.minRating > 0 || filters.maxRating < 5) count++;
|
if (filters.minRating > 0 || filters.maxRating < 5) count++;
|
||||||
if (filters.minRides > 0 || filters.maxRides < 1000) count++;
|
if (filters.minRides > 0 || filters.maxRides < 1000) count++;
|
||||||
if (filters.openingYearStart || filters.openingYearEnd) count++;
|
if (filters.openingYearStart || filters.openingYearEnd) count++;
|
||||||
@@ -395,6 +406,27 @@ export default function Parks() {
|
|||||||
{/* Search and Controls */}
|
{/* Search and Controls */}
|
||||||
<div className="mb-6 space-y-4">
|
<div className="mb-6 space-y-4">
|
||||||
<div className="flex flex-col lg:flex-row gap-4">
|
<div className="flex flex-col lg:flex-row gap-4">
|
||||||
|
{/* Desktop: Filter toggle on the left */}
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => setSidebarCollapsed(!sidebarCollapsed)}
|
||||||
|
className="shrink-0 gap-2 hidden lg:flex"
|
||||||
|
title={sidebarCollapsed ? "Show filters" : "Hide filters"}
|
||||||
|
>
|
||||||
|
{sidebarCollapsed ? (
|
||||||
|
<PanelLeftOpen className="w-4 h-4" />
|
||||||
|
) : (
|
||||||
|
<PanelLeftClose className="w-4 h-4" />
|
||||||
|
)}
|
||||||
|
<span>Filters</span>
|
||||||
|
{activeFilterCount > 0 && (
|
||||||
|
<Badge variant="secondary" className="ml-1">
|
||||||
|
{activeFilterCount}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* Search bar takes remaining space */}
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<ParkSearch
|
<ParkSearch
|
||||||
value={filters.search}
|
value={filters.search}
|
||||||
@@ -402,12 +434,14 @@ export default function Parks() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex gap-2 flex-1">
|
{/* Sort controls - more compact */}
|
||||||
|
<div className="flex gap-2">
|
||||||
<ParkSortOptions
|
<ParkSortOptions
|
||||||
sort={sort}
|
sort={sort}
|
||||||
onSortChange={setSort}
|
onSortChange={setSort}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* Mobile filter toggle */}
|
||||||
<Button
|
<Button
|
||||||
variant={showFilters ? "default" : "outline"}
|
variant={showFilters ? "default" : "outline"}
|
||||||
onClick={() => setShowFilters(!showFilters)}
|
onClick={() => setShowFilters(!showFilters)}
|
||||||
@@ -457,19 +491,32 @@ export default function Parks() {
|
|||||||
{/* Main Content Area with Sidebar */}
|
{/* Main Content Area with Sidebar */}
|
||||||
<div className="flex flex-col lg:flex-row gap-6">
|
<div className="flex flex-col lg:flex-row gap-6">
|
||||||
{/* Desktop Filter Sidebar */}
|
{/* Desktop Filter Sidebar */}
|
||||||
<aside className="hidden lg:block lg:w-[340px] xl:w-[380px] 2xl:w-[420px] flex-shrink-0">
|
{!sidebarCollapsed && (
|
||||||
<div className="sticky top-24">
|
<aside className="hidden lg:block flex-shrink-0 transition-all duration-300 lg:w-[340px] xl:w-[380px] 2xl:w-[420px]">
|
||||||
<Card>
|
<div className="sticky top-24">
|
||||||
<CardContent className="pt-6">
|
<Card>
|
||||||
<ParkFilters
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
filters={filters}
|
<CardTitle className="text-base">Filters</CardTitle>
|
||||||
onFiltersChange={setFilters}
|
<Button
|
||||||
parks={parks}
|
variant="ghost"
|
||||||
/>
|
size="sm"
|
||||||
</CardContent>
|
onClick={() => setSidebarCollapsed(true)}
|
||||||
</Card>
|
title="Hide filters"
|
||||||
</div>
|
>
|
||||||
</aside>
|
<PanelLeftClose className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<ParkFilters
|
||||||
|
filters={filters}
|
||||||
|
onFiltersChange={setFilters}
|
||||||
|
parks={parks}
|
||||||
|
/>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Results Area */}
|
{/* Results Area */}
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ import { Badge } from '@/components/ui/badge';
|
|||||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Filter, SlidersHorizontal, FerrisWheel, Plus, ChevronDown } from 'lucide-react';
|
import { Filter, SlidersHorizontal, FerrisWheel, Plus, ChevronDown, PanelLeftClose, PanelLeftOpen } from 'lucide-react';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
import { AutocompleteSearch } from '@/components/search/AutocompleteSearch';
|
import { AutocompleteSearch } from '@/components/search/AutocompleteSearch';
|
||||||
import { RideCard } from '@/components/rides/RideCard';
|
import { RideCard } from '@/components/rides/RideCard';
|
||||||
import { RideForm } from '@/components/admin/RideForm';
|
import { RideForm } from '@/components/admin/RideForm';
|
||||||
@@ -32,11 +33,19 @@ export default function Rides() {
|
|||||||
const [filters, setFilters] = useState<RideFilterState>(defaultRideFilters);
|
const [filters, setFilters] = useState<RideFilterState>(defaultRideFilters);
|
||||||
const [showFilters, setShowFilters] = useState(false);
|
const [showFilters, setShowFilters] = useState(false);
|
||||||
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
||||||
|
const [sidebarCollapsed, setSidebarCollapsed] = useState(() => {
|
||||||
|
const saved = localStorage.getItem('rides-sidebar-collapsed');
|
||||||
|
return saved ? JSON.parse(saved) : false;
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchRides();
|
fetchRides();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem('rides-sidebar-collapsed', JSON.stringify(sidebarCollapsed));
|
||||||
|
}, [sidebarCollapsed]);
|
||||||
|
|
||||||
const fetchRides = async () => {
|
const fetchRides = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await supabase
|
const { data } = await supabase
|
||||||
@@ -160,6 +169,22 @@ export default function Rides() {
|
|||||||
{/* Search and Filters */}
|
{/* Search and Filters */}
|
||||||
<div className="mb-8 space-y-4">
|
<div className="mb-8 space-y-4">
|
||||||
<div className="flex flex-col md:flex-row gap-4">
|
<div className="flex flex-col md:flex-row gap-4">
|
||||||
|
{/* Desktop: Filter toggle on the left */}
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => setSidebarCollapsed(!sidebarCollapsed)}
|
||||||
|
className="shrink-0 gap-2 hidden lg:flex"
|
||||||
|
title={sidebarCollapsed ? "Show filters" : "Hide filters"}
|
||||||
|
>
|
||||||
|
{sidebarCollapsed ? (
|
||||||
|
<PanelLeftOpen className="w-4 h-4" />
|
||||||
|
) : (
|
||||||
|
<PanelLeftClose className="w-4 h-4" />
|
||||||
|
)}
|
||||||
|
<span>Filters</span>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* Search bar takes remaining space */}
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<AutocompleteSearch
|
<AutocompleteSearch
|
||||||
placeholder="Search rides by name, park, or manufacturer..."
|
placeholder="Search rides by name, park, or manufacturer..."
|
||||||
@@ -169,21 +194,24 @@ export default function Rides() {
|
|||||||
showRecentSearches={false}
|
showRecentSearches={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Sort controls - more compact */}
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Select value={sortBy} onValueChange={setSortBy}>
|
<Select value={sortBy} onValueChange={setSortBy}>
|
||||||
<SelectTrigger className="w-[180px]">
|
<SelectTrigger className="w-[160px]">
|
||||||
<SlidersHorizontal className="w-4 h-4 mr-2" />
|
<SlidersHorizontal className="w-4 h-4 mr-2" />
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="name">Name A-Z</SelectItem>
|
<SelectItem value="name">Name</SelectItem>
|
||||||
<SelectItem value="rating">Highest Rated</SelectItem>
|
<SelectItem value="rating">Rating</SelectItem>
|
||||||
<SelectItem value="speed">Fastest</SelectItem>
|
<SelectItem value="speed">Speed</SelectItem>
|
||||||
<SelectItem value="height">Tallest</SelectItem>
|
<SelectItem value="height">Height</SelectItem>
|
||||||
<SelectItem value="reviews">Most Reviews</SelectItem>
|
<SelectItem value="reviews">Reviews</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
|
{/* Mobile filter toggle */}
|
||||||
<Button
|
<Button
|
||||||
variant={showFilters ? "default" : "outline"}
|
variant={showFilters ? "default" : "outline"}
|
||||||
onClick={() => setShowFilters(!showFilters)}
|
onClick={() => setShowFilters(!showFilters)}
|
||||||
@@ -213,15 +241,28 @@ export default function Rides() {
|
|||||||
{/* Main Content Area with Sidebar */}
|
{/* Main Content Area with Sidebar */}
|
||||||
<div className="flex flex-col lg:flex-row gap-6">
|
<div className="flex flex-col lg:flex-row gap-6">
|
||||||
{/* Desktop Filter Sidebar */}
|
{/* Desktop Filter Sidebar */}
|
||||||
<aside className="hidden lg:block lg:w-[340px] xl:w-[380px] 2xl:w-[420px] flex-shrink-0">
|
{!sidebarCollapsed && (
|
||||||
<div className="sticky top-24">
|
<aside className="hidden lg:block flex-shrink-0 transition-all duration-300 lg:w-[340px] xl:w-[380px] 2xl:w-[420px]">
|
||||||
<Card>
|
<div className="sticky top-24">
|
||||||
<CardContent className="pt-6">
|
<Card>
|
||||||
<RideFilters filters={filters} onFiltersChange={setFilters} rides={rides} />
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
</CardContent>
|
<CardTitle className="text-base">Filters</CardTitle>
|
||||||
</Card>
|
<Button
|
||||||
</div>
|
variant="ghost"
|
||||||
</aside>
|
size="sm"
|
||||||
|
onClick={() => setSidebarCollapsed(true)}
|
||||||
|
title="Hide filters"
|
||||||
|
>
|
||||||
|
<PanelLeftClose className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<RideFilters filters={filters} onFiltersChange={setFilters} rides={rides} />
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Results Area */}
|
{/* Results Area */}
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
|
|||||||
Reference in New Issue
Block a user