From 706088d4543ef68032144054a22ca2a8cfe10ac2 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 13:48:38 +0000 Subject: [PATCH] feat: Create reusable ManufacturerCard component --- .../manufacturers/ManufacturerCard.tsx | 115 ++++++++++++++++++ src/pages/Manufacturers.tsx | 93 +------------- 2 files changed, 118 insertions(+), 90 deletions(-) create mode 100644 src/components/manufacturers/ManufacturerCard.tsx diff --git a/src/components/manufacturers/ManufacturerCard.tsx b/src/components/manufacturers/ManufacturerCard.tsx new file mode 100644 index 00000000..a8572948 --- /dev/null +++ b/src/components/manufacturers/ManufacturerCard.tsx @@ -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 ; + case 'operator': return ; + case 'designer': return ; + case 'contractor': return ; + default: return ; + } + }; + + const formatCompanyType = (type: string) => { + return type.split('_').map(word => + word.charAt(0).toUpperCase() + word.slice(1) + ).join(' '); + }; + + return ( + + + + + + + {formatCompanyType(company.company_type)} + + + + {company.name} + + + {company.logo_url && ( + + + + )} + + + + + {company.description && ( + + {company.description} + + )} + + + {company.founded_year && ( + + Founded: + {company.founded_year} + + )} + + {company.headquarters_location && ( + + + + {company.headquarters_location} + + + )} + + + {/* Ratings Display */} + {company.average_rating > 0 && ( + + + {company.average_rating.toFixed(1)} + ({company.review_count}) + + )} + + {company.website_url && ( + { + e.stopPropagation(); + window.open(company.website_url, '_blank'); + }} + > + + Visit Website + + )} + + + ); +} \ No newline at end of file diff --git a/src/pages/Manufacturers.tsx b/src/pages/Manufacturers.tsx index 24b68e87..1c4bc5c1 100644 --- a/src/pages/Manufacturers.tsx +++ b/src/pages/Manufacturers.tsx @@ -1,14 +1,12 @@ import { useState, useEffect } from 'react'; import { Header } from '@/components/layout/Header'; -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; -import { Button } from '@/components/ui/button'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Badge } from '@/components/ui/badge'; -import { Search, Filter, SlidersHorizontal, Globe, MapPin, Factory, FerrisWheel, Ruler, Hammer, Building2 } from 'lucide-react'; +import { Search, Filter, SlidersHorizontal, Factory } from 'lucide-react'; import { Company } from '@/types/database'; import { supabase } from '@/integrations/supabase/client'; -import { useNavigate } from 'react-router-dom'; +import { ManufacturerCard } from '@/components/manufacturers/ManufacturerCard'; export default function Manufacturers() { const [companies, setCompanies] = useState([]); @@ -16,7 +14,6 @@ export default function Manufacturers() { const [searchQuery, setSearchQuery] = useState(''); const [sortBy, setSortBy] = useState('name'); const [filterType, setFilterType] = useState('all'); - const navigate = useNavigate(); useEffect(() => { fetchCompanies(); @@ -57,21 +54,6 @@ export default function Manufacturers() { company.description?.toLowerCase().includes(searchQuery.toLowerCase()) ); - const getCompanyIcon = (type: string) => { - switch (type) { - case 'manufacturer': return ; - case 'operator': return ; - case 'designer': return ; - case 'contractor': return ; - default: return ; - } - }; - - const formatCompanyType = (type: string) => { - return type.split('_').map(word => - word.charAt(0).toUpperCase() + word.slice(1) - ).join(' '); - }; const companyTypes = [ { value: 'all', label: 'All Types' }, @@ -164,76 +146,7 @@ export default function Manufacturers() { {filteredCompanies.length > 0 ? ( {filteredCompanies.map((company) => ( - - - - - - {getCompanyIcon(company.company_type)} - - {formatCompanyType(company.company_type)} - - - - {company.name} - - - {company.logo_url && ( - - - - )} - - - - - {company.description && ( - - {company.description} - - )} - - - {company.founded_year && ( - - Founded: - {company.founded_year} - - )} - - {company.headquarters_location && ( - - - - {company.headquarters_location} - - - )} - - - {company.website_url && ( - { - e.stopPropagation(); - window.open(company.website_url, '_blank'); - }} - > - - Visit Website - - )} - - + ))} ) : (
+ {company.description} +
- {company.description} -