Refactor code structure and remove redundant changes

This commit is contained in:
pacnpal
2025-11-09 16:31:34 -05:00
parent 2884bc23ce
commit eb68cf40c6
1080 changed files with 27361 additions and 56687 deletions

View File

@@ -0,0 +1,128 @@
import { Card, CardContent } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Star, MapPin, Ruler, FerrisWheel } from 'lucide-react';
import { CompanyWithStats } from '@/types/database';
import { useNavigate } from 'react-router-dom';
import { getCloudflareImageUrl } from '@/lib/cloudflareImageUtils';
interface DesignerCardProps {
company: CompanyWithStats;
}
export function DesignerCard({ company }: DesignerCardProps) {
const navigate = useNavigate();
const handleClick = () => {
navigate(`/designers/${company.slug}/`);
};
const getCompanyIcon = () => {
return <Ruler className="w-8 h-8 text-muted-foreground" />;
};
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 hover:border-primary/30 transition-all duration-300 cursor-pointer hover:scale-[1.02] relative before:absolute before:inset-0 before:rounded-lg before:p-[1px] before:bg-gradient-to-br before:from-primary/20 before:via-transparent before:to-accent/20 before:-z-10 before:opacity-0 hover:before:opacity-100 before:transition-opacity before:duration-300"
onClick={handleClick}
>
{/* Header Image/Logo Section */}
<div className="relative aspect-[3/2] bg-gradient-to-br from-primary/20 via-secondary/20 to-accent/20 flex items-center justify-center overflow-hidden">
{/* Background Gradient Overlay */}
<div className="absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent opacity-80 group-hover:opacity-60 transition-opacity duration-300" />
{/* Company Type Badge */}
<div className="absolute top-3 right-3">
<Badge variant="secondary" className="text-xs bg-background/80 backdrop-blur-sm border border-border/50">
Designer
</Badge>
</div>
{/* Logo or Icon */}
<div className="relative z-10 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="relative">
<div className="absolute inset-0 rounded-full bg-primary/20 blur-xl animate-pulse" />
<div className="relative w-16 h-16 rounded-full bg-gradient-to-br from-primary/30 to-secondary/30 flex items-center justify-center border border-primary/20">
<Ruler className="w-8 h-8 text-primary/70" />
</div>
</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="font-bold text-base group-hover:text-primary transition-all duration-300 line-clamp-2 break-words group-hover:drop-shadow-[0_0_8px_rgba(139,92,246,0.5)]">
{company.name}
</h3>
</div>
{/* Company Details */}
<div className="space-y-1 text-sm">
{/* Founded Year */}
{company.founded_year && (
<div className="flex items-center gap-2">
<span className="text-muted-foreground">Founded:</span>
<span className="font-medium">{company.founded_year}</span>
</div>
)}
{/* Location */}
{company.headquarters_location && (
<div className="flex items-center gap-1 min-w-0">
<MapPin className="w-3 h-3 flex-shrink-0 text-muted-foreground" />
<span className="text-muted-foreground truncate">{company.headquarters_location}</span>
</div>
)}
</div>
{/* Stats Display */}
<div className="flex items-center justify-between text-sm">
<div className="flex flex-wrap gap-3 gap-y-1">
{company.ride_count && company.ride_count > 0 && (
<div className="flex items-center gap-1">
<FerrisWheel className="w-4 h-4 text-primary/70 flex-shrink-0" />
<span className="font-medium">{company.ride_count}</span>
<span className="text-muted-foreground">designs</span>
</div>
)}
{company.coaster_count && company.coaster_count > 0 && (
<div className="flex items-center gap-1">
<span className="font-medium">{company.coaster_count}</span>
<span className="text-muted-foreground">coasters</span>
</div>
)}
{company.model_count && company.model_count > 0 && (
<div className="flex items-center gap-1">
<span className="font-medium">{company.model_count}</span>
<span className="text-muted-foreground">concepts</span>
</div>
)}
</div>
{company.average_rating && 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 && company.review_count > 0 && (
<span className="text-muted-foreground">({company.review_count})</span>
)}
</div>
)}
</div>
</CardContent>
</Card>
);
}

View File

@@ -0,0 +1,194 @@
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 { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
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 DesignerFilterState {
personType: string;
countries: string[];
minRating: number;
maxRating: number;
minReviewCount: number;
maxReviewCount: number;
foundedDateFrom: Date | null;
foundedDateTo: Date | null;
hasRating: boolean;
hasFoundedDate: boolean;
isIndividual: boolean;
}
export const defaultDesignerFilters: DesignerFilterState = {
personType: 'all',
countries: [],
minRating: 0,
maxRating: 5,
minReviewCount: 0,
maxReviewCount: 1000,
foundedDateFrom: null,
foundedDateTo: null,
hasRating: false,
hasFoundedDate: false,
isIndividual: false,
};
interface DesignerFiltersProps {
filters: DesignerFilterState;
onFiltersChange: (filters: DesignerFilterState) => void;
designers: Company[];
}
export function DesignerFilters({ filters, onFiltersChange, designers }: DesignerFiltersProps) {
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 maxReviewCount = useMemo(() => {
return Math.max(...designers.map(d => d.review_count || 0), 1000);
}, [designers]);
const resetFilters = () => {
onFiltersChange({ ...defaultDesignerFilters, maxReviewCount });
};
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<h3 className="text-lg font-semibold">Filter Designers</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">
<div className="space-y-2">
<Label>Entity Type</Label>
<Select
value={filters.personType}
onValueChange={(value) => onFiltersChange({ ...filters, personType: value })}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">All Types</SelectItem>
<SelectItem value="company">Companies</SelectItem>
<SelectItem value="individual">Individuals</SelectItem>
</SelectContent>
</Select>
</div>
<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}
/>
</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 className="flex items-center space-x-2">
<Checkbox
id="isIndividual"
checked={filters.isIndividual}
onCheckedChange={(checked) =>
onFiltersChange({ ...filters, isIndividual: checked as boolean })
}
/>
<Label htmlFor="isIndividual" className="cursor-pointer">
Individual designers only
</Label>
</div>
</div>
</FilterSection>
</div>
);
}

View File

@@ -0,0 +1,115 @@
import { MapPin, Star, Ruler, Calendar, Palette } 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 DesignerListViewProps {
designers: Company[];
onDesignerClick: (designer: Company) => void;
}
export function DesignerListView({ designers, onDesignerClick }: DesignerListViewProps) {
return (
<div className="space-y-3">
{designers.map((designer, index) => (
<Card
key={designer.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={() => onDesignerClick(designer)}
>
<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">
{designer.logo_url ? (
<img
src={designer.logo_url}
alt={designer.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">
<Ruler 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">
{designer.name}
</h3>
{designer.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">{designer.headquarters_location}</span>
</div>
)}
</div>
{/* Rating */}
{designer.average_rating && designer.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">{designer.average_rating.toFixed(1)}</span>
{designer.review_count && designer.review_count > 0 && (
<span className="text-xs text-muted-foreground">({designer.review_count})</span>
)}
</div>
)}
</div>
{/* Description */}
{designer.description && (
<p className="text-sm text-muted-foreground group-hover:text-foreground/80 transition-colors duration-300 line-clamp-2">
{designer.description}
</p>
)}
{/* Tags */}
<div className="flex items-center gap-2 flex-wrap">
<Badge variant="outline" className="text-xs backdrop-blur-sm border-primary/20 group-hover:border-primary/40 transition-colors duration-300">
<Palette className="w-3 h-3 mr-1" />
Designer
</Badge>
{designer.founded_year && (
<Badge variant="outline" className="text-xs backdrop-blur-sm border-accent/20 group-hover:border-accent/40 transition-colors duration-300">
<Calendar className="w-3 h-3 mr-1" />
Est. {designer.founded_year}
</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"
>
<Palette 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>
);
}