mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 05:11:14 -05:00
Refactor code structure and remove redundant changes
This commit is contained in:
129
src-old/components/operators/OperatorCard.tsx
Normal file
129
src-old/components/operators/OperatorCard.tsx
Normal file
@@ -0,0 +1,129 @@
|
||||
import React from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Building, Star, MapPin } from 'lucide-react';
|
||||
import { CompanyWithStats } from '@/types/database';
|
||||
import { getCloudflareImageUrl } from '@/lib/cloudflareImageUtils';
|
||||
|
||||
interface OperatorCardProps {
|
||||
company: CompanyWithStats;
|
||||
}
|
||||
|
||||
const OperatorCard = ({ company }: OperatorCardProps) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleClick = () => {
|
||||
navigate(`/operators/${company.slug}`);
|
||||
};
|
||||
|
||||
const getCompanyIcon = () => {
|
||||
return <Building className="w-5 h-5" />;
|
||||
};
|
||||
|
||||
return (
|
||||
<Card
|
||||
className="group overflow-hidden border-border/50 bg-gradient-to-br from-card via-card to-card/80 hover:shadow-2xl hover:shadow-primary/20 transition-all duration-300 cursor-pointer hover:scale-[1.02]"
|
||||
onClick={handleClick}
|
||||
>
|
||||
{/* Logo/Image Section */}
|
||||
<div className="aspect-[3/2] relative bg-gradient-to-br from-primary/20 via-primary/10 to-transparent overflow-hidden">
|
||||
{(company.card_image_url || company.card_image_id) ? (
|
||||
<img
|
||||
src={company.card_image_url || getCloudflareImageUrl(company.card_image_id || '', 'card')}
|
||||
srcSet={company.card_image_id ? `
|
||||
${getCloudflareImageUrl(company.card_image_id, 'cardthumb')} 600w,
|
||||
${getCloudflareImageUrl(company.card_image_id, 'card')} 1200w
|
||||
` : undefined}
|
||||
sizes="(max-width: 640px) 600px, 1200px"
|
||||
alt={company.name}
|
||||
className="w-full h-full object-cover group-hover:scale-110 transition-transform duration-500"
|
||||
loading="lazy"
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-background/80 via-transparent to-transparent" />
|
||||
|
||||
{/* Park Operator Badge */}
|
||||
<div className="absolute top-3 right-3 z-10">
|
||||
<Badge variant="outline" className="bg-background/80 backdrop-blur-sm">
|
||||
Park Operator
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
{/* Logo Display */}
|
||||
<div className="absolute inset-0 flex items-center justify-center">
|
||||
{company.logo_url ? (
|
||||
<div className="w-12 h-12 md:w-16 md:h-16 bg-background/90 rounded-xl overflow-hidden shadow-lg backdrop-blur-sm border border-border/50">
|
||||
<img
|
||||
src={company.logo_url}
|
||||
alt={`${company.name} logo`}
|
||||
className="w-full h-full object-contain p-2"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-12 h-12 text-muted-foreground/30">
|
||||
{getCompanyIcon()}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<CardContent className="p-2.5 space-y-1.5 border-t border-border/30">
|
||||
{/* Company Name */}
|
||||
<div className="space-y-0.5 min-w-0">
|
||||
<h3 className="text-base font-semibold group-hover:text-primary transition-colors line-clamp-2 break-words">
|
||||
{company.name}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
{/* Company Info */}
|
||||
<div className="flex flex-wrap gap-3 gap-y-1 text-sm">
|
||||
{company.founded_year && (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-muted-foreground">Founded:</span>
|
||||
<span className="font-medium">{company.founded_year}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{company.headquarters_location && (
|
||||
<div className="flex items-center gap-1 min-w-0">
|
||||
<MapPin className="w-3 h-3 flex-shrink-0" />
|
||||
<span className="text-muted-foreground truncate">
|
||||
{company.headquarters_location}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Park Count Stats */}
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex flex-wrap gap-3 gap-y-1">
|
||||
{company.park_count && company.park_count > 0 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Building className="w-4 h-4 text-primary/70 flex-shrink-0" />
|
||||
<span className="font-medium">{company.park_count}</span>
|
||||
<span className="text-muted-foreground">parks</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{company.average_rating != null && company.average_rating > 0 && (
|
||||
<div className="inline-flex items-center gap-1">
|
||||
<Star className="w-4 h-4 fill-yellow-500 text-yellow-500" />
|
||||
<span className="font-semibold">{company.average_rating.toFixed(1)}</span>
|
||||
{company.review_count != null && company.review_count > 0 && (
|
||||
<span className="text-muted-foreground">({company.review_count})</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default OperatorCard;
|
||||
175
src-old/components/operators/OperatorFilters.tsx
Normal file
175
src-old/components/operators/OperatorFilters.tsx
Normal file
@@ -0,0 +1,175 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { RotateCcw } from 'lucide-react';
|
||||
import { supabase } from '@/lib/supabaseClient';
|
||||
import { FilterRangeSlider } from '@/components/filters/FilterRangeSlider';
|
||||
import { FilterDateRangePicker } from '@/components/filters/FilterDateRangePicker';
|
||||
import { FilterSection } from '@/components/filters/FilterSection';
|
||||
import { FilterMultiSelectCombobox } from '@/components/filters/FilterMultiSelectCombobox';
|
||||
import { MultiSelectOption } from '@/components/ui/multi-select-combobox';
|
||||
import { Company } from '@/types/database';
|
||||
|
||||
export interface OperatorFilterState {
|
||||
countries: string[];
|
||||
minRating: number;
|
||||
maxRating: number;
|
||||
minReviewCount: number;
|
||||
maxReviewCount: number;
|
||||
minParkCount: number;
|
||||
maxParkCount: number;
|
||||
foundedDateFrom: Date | null;
|
||||
foundedDateTo: Date | null;
|
||||
hasRating: boolean;
|
||||
hasFoundedDate: boolean;
|
||||
}
|
||||
|
||||
export const defaultOperatorFilters: OperatorFilterState = {
|
||||
countries: [],
|
||||
minRating: 0,
|
||||
maxRating: 5,
|
||||
minReviewCount: 0,
|
||||
maxReviewCount: 1000,
|
||||
minParkCount: 0,
|
||||
maxParkCount: 100,
|
||||
foundedDateFrom: null,
|
||||
foundedDateTo: null,
|
||||
hasRating: false,
|
||||
hasFoundedDate: false,
|
||||
};
|
||||
|
||||
interface OperatorFiltersProps {
|
||||
filters: OperatorFilterState;
|
||||
onFiltersChange: (filters: OperatorFilterState) => void;
|
||||
operators: (Company & { park_count?: number })[];
|
||||
}
|
||||
|
||||
export function OperatorFilters({ filters, onFiltersChange, operators }: OperatorFiltersProps) {
|
||||
const { data: locations } = useQuery({
|
||||
queryKey: ['filter-locations'],
|
||||
queryFn: async () => {
|
||||
const { data } = await supabase
|
||||
.from('locations')
|
||||
.select('country')
|
||||
.not('country', 'is', null);
|
||||
return data || [];
|
||||
},
|
||||
staleTime: 5 * 60 * 1000,
|
||||
});
|
||||
|
||||
const countryOptions: MultiSelectOption[] = useMemo(() => {
|
||||
const countries = new Set(locations?.map(l => l.country).filter(Boolean) || []);
|
||||
return Array.from(countries).sort().map(c => ({ label: c, value: c }));
|
||||
}, [locations]);
|
||||
|
||||
const maxParkCount = useMemo(() => {
|
||||
return Math.max(...operators.map(o => o.park_count || 0), 100);
|
||||
}, [operators]);
|
||||
|
||||
const maxReviewCount = useMemo(() => {
|
||||
return Math.max(...operators.map(o => o.review_count || 0), 1000);
|
||||
}, [operators]);
|
||||
|
||||
const resetFilters = () => {
|
||||
onFiltersChange({ ...defaultOperatorFilters, maxParkCount, maxReviewCount });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-lg font-semibold">Filter Operators</h3>
|
||||
<Button variant="ghost" size="sm" onClick={resetFilters}>
|
||||
<RotateCcw className="w-4 h-4 mr-2" />
|
||||
Reset
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<FilterSection title="Basic Filters">
|
||||
<div className="grid grid-cols-1 gap-4">
|
||||
<FilterMultiSelectCombobox
|
||||
label="Headquarters Country"
|
||||
options={countryOptions}
|
||||
value={filters.countries}
|
||||
onChange={(value) => onFiltersChange({ ...filters, countries: value })}
|
||||
placeholder="Select countries"
|
||||
/>
|
||||
<FilterDateRangePicker
|
||||
label="Founded Date"
|
||||
fromDate={filters.foundedDateFrom}
|
||||
toDate={filters.foundedDateTo}
|
||||
onFromChange={(date) => onFiltersChange({ ...filters, foundedDateFrom: date || null })}
|
||||
onToChange={(date) => onFiltersChange({ ...filters, foundedDateTo: date || null })}
|
||||
fromPlaceholder="From year"
|
||||
toPlaceholder="To year"
|
||||
/>
|
||||
</div>
|
||||
</FilterSection>
|
||||
|
||||
<Separator />
|
||||
|
||||
<FilterSection title="Statistics">
|
||||
<div className="grid grid-cols-1 gap-4">
|
||||
<FilterRangeSlider
|
||||
label="Rating"
|
||||
value={[filters.minRating, filters.maxRating]}
|
||||
onChange={([min, max]) => onFiltersChange({ ...filters, minRating: min, maxRating: max })}
|
||||
min={0}
|
||||
max={5}
|
||||
step={0.1}
|
||||
formatValue={(v) => `${v.toFixed(1)} stars`}
|
||||
/>
|
||||
<FilterRangeSlider
|
||||
label="Review Count"
|
||||
value={[filters.minReviewCount, filters.maxReviewCount]}
|
||||
onChange={([min, max]) => onFiltersChange({ ...filters, minReviewCount: min, maxReviewCount: max })}
|
||||
min={0}
|
||||
max={maxReviewCount}
|
||||
step={10}
|
||||
/>
|
||||
<FilterRangeSlider
|
||||
label="Park Count"
|
||||
value={[filters.minParkCount, filters.maxParkCount]}
|
||||
onChange={([min, max]) => onFiltersChange({ ...filters, minParkCount: min, maxParkCount: max })}
|
||||
min={0}
|
||||
max={maxParkCount}
|
||||
step={1}
|
||||
/>
|
||||
</div>
|
||||
</FilterSection>
|
||||
|
||||
<Separator />
|
||||
|
||||
<FilterSection title="Other Options">
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
id="hasRating"
|
||||
checked={filters.hasRating}
|
||||
onCheckedChange={(checked) =>
|
||||
onFiltersChange({ ...filters, hasRating: checked as boolean })
|
||||
}
|
||||
/>
|
||||
<Label htmlFor="hasRating" className="cursor-pointer">
|
||||
Has rating
|
||||
</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
id="hasFoundedDate"
|
||||
checked={filters.hasFoundedDate}
|
||||
onCheckedChange={(checked) =>
|
||||
onFiltersChange({ ...filters, hasFoundedDate: checked as boolean })
|
||||
}
|
||||
/>
|
||||
<Label htmlFor="hasFoundedDate" className="cursor-pointer">
|
||||
Has founded date
|
||||
</Label>
|
||||
</div>
|
||||
</div>
|
||||
</FilterSection>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
117
src-old/components/operators/OperatorListView.tsx
Normal file
117
src-old/components/operators/OperatorListView.tsx
Normal file
@@ -0,0 +1,117 @@
|
||||
import { MapPin, Star, Building2, Calendar, Globe } from 'lucide-react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Company } from '@/types/database';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface OperatorListViewProps {
|
||||
operators: (Company & { park_count?: number })[];
|
||||
onOperatorClick: (operator: Company) => void;
|
||||
}
|
||||
|
||||
export function OperatorListView({ operators, onOperatorClick }: OperatorListViewProps) {
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
{operators.map((operator, index) => (
|
||||
<Card
|
||||
key={operator.id}
|
||||
className={cn(
|
||||
"group overflow-hidden cursor-pointer",
|
||||
"border-border/40 bg-gradient-to-br from-card via-card/95 to-card/90",
|
||||
"hover:border-primary/30 hover:shadow-2xl hover:shadow-primary/5",
|
||||
"transition-all duration-500 animate-fade-in-up"
|
||||
)}
|
||||
style={{ animationDelay: `${index * 50}ms` }}
|
||||
onClick={() => onOperatorClick(operator)}
|
||||
>
|
||||
<CardContent className="p-0">
|
||||
<div className="flex flex-col sm:flex-row">
|
||||
{/* Logo */}
|
||||
<div className="w-full h-32 sm:w-32 sm:h-auto md:w-40 flex-shrink-0 self-stretch relative overflow-hidden bg-gradient-to-br from-muted/50 to-muted/30">
|
||||
{operator.logo_url ? (
|
||||
<img
|
||||
src={operator.logo_url}
|
||||
alt={operator.name}
|
||||
className="w-full h-full object-contain p-4 group-hover:scale-110 transition-transform duration-700"
|
||||
/>
|
||||
) : (
|
||||
<div className="w-full h-full flex items-center justify-center">
|
||||
<Building2 className="w-12 h-12 text-muted-foreground/40" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="flex-1 p-4 md:p-6 flex flex-col justify-between min-h-[128px]">
|
||||
<div className="space-y-3">
|
||||
{/* Header */}
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="flex-1 min-w-0">
|
||||
<h3 className="font-bold text-lg md:text-xl group-hover:text-primary transition-colors duration-300 line-clamp-1 mb-1.5">
|
||||
{operator.name}
|
||||
</h3>
|
||||
|
||||
{operator.headquarters_location && (
|
||||
<div className="flex items-center text-sm text-muted-foreground group-hover:text-foreground transition-colors duration-300">
|
||||
<MapPin className="w-3.5 h-3.5 mr-1.5 flex-shrink-0" />
|
||||
<span className="line-clamp-1">{operator.headquarters_location}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Rating */}
|
||||
{operator.average_rating && operator.average_rating > 0 && (
|
||||
<div className="flex items-center gap-1.5 ml-4 flex-shrink-0 bg-yellow-400/10 px-3 py-1.5 rounded-full group-hover:bg-yellow-400/20 transition-colors duration-300">
|
||||
<Star className="w-4 h-4 fill-yellow-400 text-yellow-400" />
|
||||
<span className="font-semibold text-foreground">{operator.average_rating.toFixed(1)}</span>
|
||||
{operator.review_count && operator.review_count > 0 && (
|
||||
<span className="text-xs text-muted-foreground">({operator.review_count})</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
{operator.description && (
|
||||
<p className="text-sm text-muted-foreground group-hover:text-foreground/80 transition-colors duration-300 line-clamp-2">
|
||||
{operator.description}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Tags */}
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
{operator.founded_year && (
|
||||
<Badge variant="outline" className="text-xs backdrop-blur-sm border-primary/20 group-hover:border-primary/40 transition-colors duration-300">
|
||||
<Calendar className="w-3 h-3 mr-1" />
|
||||
Founded {operator.founded_year}
|
||||
</Badge>
|
||||
)}
|
||||
{operator.park_count !== undefined && operator.park_count > 0 && (
|
||||
<Badge variant="outline" className="text-xs backdrop-blur-sm border-accent/20 group-hover:border-accent/40 transition-colors duration-300">
|
||||
<Building2 className="w-3 h-3 mr-1" />
|
||||
{operator.park_count} {operator.park_count === 1 ? 'park' : 'parks'}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex items-center justify-end mt-4 pt-3 border-t border-border/50">
|
||||
<Button
|
||||
size="sm"
|
||||
className="bg-gradient-to-r from-primary to-secondary hover:shadow-lg hover:shadow-primary/20 hover:scale-105 transition-all duration-300 flex-shrink-0"
|
||||
>
|
||||
<Globe className="w-3.5 h-3.5 mr-1.5" />
|
||||
<span className="hidden sm:inline">View Details</span>
|
||||
<span className="sm:hidden">View</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user