Refactor Categories

This commit is contained in:
Dosseh91
2025-12-17 22:56:12 +01:00
committed by GitHub
parent 86b0cc87ec
commit fc11f69c36

View File

@@ -1,52 +1,79 @@
import { Link } from 'react-router-dom'; import { Link } from "react-router-dom";
import { Tag } from "lucide-react";
interface Category { const categories = [
id: string; {
name: string; key: "real-estate",
description?: string; title: "Real Estate",
} description: "Homes, apartments, land, and commercial properties",
},
const categories: Category[] = [ {
{ id: 'apartments', name: 'Apartments' }, key: "vehicles",
{ id: 'houses', name: 'Houses' }, title: "Vehicles",
{ id: 'commercial', name: 'Commercial' }, description: "Cars, motorcycles, boats, and other vehicles",
{ id: 'land', name: 'Land' }, },
{ id: 'luxury', name: 'Luxury' } {
key: "electronics",
title: "Electronics",
description: "Computers, phones, TVs, and other electronic devices",
},
{
key: "furniture",
title: "Furniture",
description: "Home and office furniture, decor, and appliances",
},
{
key: "jobs",
title: "Jobs",
description: "Job listings and career opportunities",
},
{
key: "services",
title: "Services",
description: "Professional services and skilled trades",
},
]; ];
const Categories = () => { export default function Categories() {
return ( return (
<div style={{ padding: '2rem' }}> <div className="container mx-auto px-4 py-16">
<h1>Categories</h1> <h1 className="text-3xl font-bold text-center mb-4">
Browse by Category
</h1>
<p className="text-center text-gray-600 mb-12">
Explore our wide range of categories to find exactly what you're looking for
</p>
<div <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
style={{ {categories.map((category) => (
display: 'grid',
gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))',
gap: '1rem',
marginTop: '1.5rem'
}}
>
{categories.map(category => (
<Link <Link
key={category.id} key={category.key}
to={`/categories/${category.id}`} to={`/listings?category=${category.key}`}
style={{ className="group bg-white border rounded-xl p-6 flex justify-between items-center hover:shadow-lg transition"
textDecoration: 'none',
border: '1px solid #e5e7eb',
padding: '1rem',
borderRadius: '8px',
color: 'inherit'
}}
> >
<h3>{category.name}</h3> <div className="flex gap-4">
{category.description && <p>{category.description}</p>} <div className="w-12 h-12 rounded-full bg-gray-100 flex items-center justify-center">
<Tag className="text-gray-600" />
</div>
<div>
<h3 className="text-lg font-semibold group-hover:text-teal-600">
{category.title}
</h3>
<p className="text-gray-600 text-sm">
{category.description}
</p>
</div>
</div>
<span className="text-gray-400 group-hover:text-teal-600 text-xl">
</span>
</Link> </Link>
))} ))}
</div> </div>
</div> </div>
); );
}; }
export default Categories; export default Categories;