Refactor manufacturers page

This commit is contained in:
gpt-engineer-app[bot]
2025-09-29 13:53:05 +00:00
parent 706088d454
commit 5407763162
4 changed files with 152 additions and 35 deletions

View File

@@ -3,7 +3,7 @@ import { Header } from '@/components/layout/Header';
import { Input } from '@/components/ui/input';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { Badge } from '@/components/ui/badge';
import { Search, Filter, SlidersHorizontal, Factory } from 'lucide-react';
import { Search, SlidersHorizontal, Factory } from 'lucide-react';
import { Company } from '@/types/database';
import { supabase } from '@/integrations/supabase/client';
import { ManufacturerCard } from '@/components/manufacturers/ManufacturerCard';
@@ -13,11 +13,11 @@ export default function Manufacturers() {
const [loading, setLoading] = useState(true);
const [searchQuery, setSearchQuery] = useState('');
const [sortBy, setSortBy] = useState('name');
const [filterType, setFilterType] = useState('all');
useEffect(() => {
fetchCompanies();
}, [sortBy, filterType]);
}, [sortBy]);
const fetchCompanies = async () => {
try {
@@ -25,10 +25,8 @@ export default function Manufacturers() {
.from('companies')
.select('*');
// Apply filters
if (filterType !== 'all') {
query = query.eq('company_type', filterType);
}
// Filter only manufacturers
query = query.eq('company_type', 'manufacturer');
// Apply sorting
switch (sortBy) {
@@ -55,13 +53,6 @@ export default function Manufacturers() {
);
const companyTypes = [
{ value: 'all', label: 'All Types' },
{ value: 'manufacturer', label: 'Manufacturers' },
{ value: 'operator', label: 'Operators' },
{ value: 'designer', label: 'Designers' },
{ value: 'contractor', label: 'Contractors' }
];
if (loading) {
return (
@@ -90,14 +81,13 @@ export default function Manufacturers() {
<div className="mb-8">
<div className="flex items-center gap-3 mb-4">
<Factory className="w-10 h-10 text-primary" />
<h1 className="text-4xl font-bold">Manufacturers & Companies</h1>
<h1 className="text-4xl font-bold">Manufacturers</h1>
</div>
<p className="text-lg text-muted-foreground">
Explore the companies behind your favorite rides and attractions
Explore the manufacturers behind your favorite rides and attractions
</p>
<div className="flex items-center gap-2 mt-2">
<Badge variant="secondary">{filteredCompanies.length} companies found</Badge>
<Badge variant="outline">{companies.filter(c => c.company_type === 'manufacturer').length} manufacturers</Badge>
<Badge variant="secondary">{filteredCompanies.length} manufacturers found</Badge>
</div>
</div>
@@ -107,7 +97,7 @@ export default function Manufacturers() {
<div className="relative flex-1">
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-4 h-4" />
<Input
placeholder="Search companies by name, location, or description..."
placeholder="Search manufacturers by name, location, or description..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="pl-10"
@@ -125,19 +115,6 @@ export default function Manufacturers() {
</SelectContent>
</Select>
<Select value={filterType} onValueChange={setFilterType}>
<SelectTrigger className="w-[160px]">
<Filter className="w-4 h-4 mr-2" />
<SelectValue />
</SelectTrigger>
<SelectContent>
{companyTypes.map(type => (
<SelectItem key={type.value} value={type.value}>
{type.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
</div>
@@ -152,9 +129,9 @@ export default function Manufacturers() {
) : (
<div className="text-center py-12">
<Factory className="w-16 h-16 mb-4 mx-auto text-muted-foreground" />
<h3 className="text-xl font-semibold mb-2">No companies found</h3>
<h3 className="text-xl font-semibold mb-2">No manufacturers found</h3>
<p className="text-muted-foreground">
Try adjusting your search criteria or filters
Try adjusting your search criteria
</p>
</div>
)}