mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 22:31:12 -05:00
feat: Create reusable ManufacturerCard component
This commit is contained in:
115
src/components/manufacturers/ManufacturerCard.tsx
Normal file
115
src/components/manufacturers/ManufacturerCard.tsx
Normal file
@@ -0,0 +1,115 @@
|
||||
import { Factory, MapPin, Star, Globe, FerrisWheel, Ruler, Hammer, Building2 } from 'lucide-react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Company } from '@/types/database';
|
||||
|
||||
interface ManufacturerCardProps {
|
||||
company: Company;
|
||||
}
|
||||
|
||||
export function ManufacturerCard({ company }: ManufacturerCardProps) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleClick = () => {
|
||||
navigate(`/manufacturers/${company.slug}/`);
|
||||
};
|
||||
|
||||
const getCompanyIcon = (type: string) => {
|
||||
switch (type) {
|
||||
case 'manufacturer': return <Factory className="w-5 h-5" />;
|
||||
case 'operator': return <FerrisWheel className="w-5 h-5" />;
|
||||
case 'designer': return <Ruler className="w-5 h-5" />;
|
||||
case 'contractor': return <Hammer className="w-5 h-5" />;
|
||||
default: return <Building2 className="w-5 h-5" />;
|
||||
}
|
||||
};
|
||||
|
||||
const formatCompanyType = (type: string) => {
|
||||
return type.split('_').map(word =>
|
||||
word.charAt(0).toUpperCase() + word.slice(1)
|
||||
).join(' ');
|
||||
};
|
||||
|
||||
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}
|
||||
>
|
||||
<CardHeader className="pb-3">
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex-1">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<Badge variant="outline" className="text-xs">
|
||||
{formatCompanyType(company.company_type)}
|
||||
</Badge>
|
||||
</div>
|
||||
<CardTitle className="text-lg group-hover:text-primary transition-colors line-clamp-2">
|
||||
{company.name}
|
||||
</CardTitle>
|
||||
</div>
|
||||
{company.logo_url && (
|
||||
<div className="w-12 h-12 bg-muted rounded-lg overflow-hidden flex-shrink-0">
|
||||
<img
|
||||
src={company.logo_url}
|
||||
alt={`${company.name} logo`}
|
||||
className="w-full h-full object-cover"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent className="space-y-3">
|
||||
{company.description && (
|
||||
<p className="text-sm text-muted-foreground line-clamp-3">
|
||||
{company.description}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="space-y-2 text-sm">
|
||||
{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>
|
||||
)}
|
||||
|
||||
{company.headquarters_location && (
|
||||
<div className="flex items-center gap-2">
|
||||
<MapPin className="w-3 h-3 text-muted-foreground" />
|
||||
<span className="text-muted-foreground text-xs">
|
||||
{company.headquarters_location}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Ratings Display */}
|
||||
{company.average_rating > 0 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Star className="w-3 h-3 fill-yellow-400 text-yellow-400" />
|
||||
<span className="text-sm font-medium">{company.average_rating.toFixed(1)}</span>
|
||||
<span className="text-xs text-muted-foreground">({company.review_count})</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{company.website_url && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="w-full"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
window.open(company.website_url, '_blank');
|
||||
}}
|
||||
>
|
||||
<Globe className="w-4 h-4 mr-2" />
|
||||
Visit Website
|
||||
</Button>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user