import { Category } from "@/types"; import { Button } from "@/components/ui/button"; import { Laptop, Shirt, Home, Dumbbell, Book, Gamepad2, Smartphone, Camera, Headphones, Watch } from "lucide-react"; interface CategoryNavProps { categories: Category[]; selectedCategory: string; onCategorySelect: (categoryId: string) => void; } const getCategoryIcon = (iconName?: string) => { const iconMap: { [key: string]: React.ComponentType } = { 'fa-laptop': Laptop, 'fa-tshirt': Shirt, 'fa-home': Home, 'fa-dumbbell': Dumbbell, 'fa-book': Book, 'fa-gamepad': Gamepad2, 'fa-mobile': Smartphone, 'fa-camera': Camera, 'fa-headphones': Headphones, 'fa-clock': Watch, }; const IconComponent = iconName ? iconMap[iconName] || Laptop : Laptop; return IconComponent; }; const getDefaultIcon = (categoryName: string) => { const name = categoryName.toLowerCase(); if (name.includes('electronics') || name.includes('tech')) return Laptop; if (name.includes('fashion') || name.includes('clothing')) return Shirt; if (name.includes('home') || name.includes('furniture')) return Home; if (name.includes('sports') || name.includes('fitness')) return Dumbbell; if (name.includes('books') || name.includes('education')) return Book; if (name.includes('gaming') || name.includes('games')) return Gamepad2; if (name.includes('mobile') || name.includes('phone')) return Smartphone; if (name.includes('camera') || name.includes('photo')) return Camera; if (name.includes('audio') || name.includes('music')) return Headphones; if (name.includes('watch') || name.includes('time')) return Watch; return Laptop; }; export default function CategoryNav({ categories, selectedCategory, onCategorySelect }: CategoryNavProps) { // Ensure categories is an array const categoryList = Array.isArray(categories) ? categories : []; return (
{/* Modern Pill Chips Layout */}
{/* All Categories Chip */} {/* Category Chips */} {categoryList.map((category) => { const IconComponent = category.icon ? getCategoryIcon(category.icon) : getDefaultIcon(category.name); const isSelected = selectedCategory === category.id; return ( ); })}
); }