"use client"; import { useMemo, useState } from "react"; import Link from "next/link"; import { useParams } from "next/navigation"; import { CATEGORIES, PARTS } from "@/data/gunbuilderParts"; import type { CategoryId } from "@/types/gunbuilder"; type ViewMode = "card" | "list"; export default function CategoryPage() { const params = useParams(); const categoryId = params.categoryId as CategoryId; const [viewMode, setViewMode] = useState("card"); const category = useMemo( () => CATEGORIES.find((c) => c.id === categoryId), [categoryId], ); const parts = useMemo( () => PARTS.filter((p) => p.categoryId === categoryId), [categoryId], ); if (!category) { return (

Category Not Found

Return to Gunbuilder
); } return (
{/* Header */}
← Back to Gunbuilder

Shadow Standard

{category.name} Parts

Browse all available {category.name.toLowerCase()} options for your build.

{parts.length > 0 && (
)}
{/* Parts Grid/List */}
{parts.length === 0 ? (

No parts available for this category yet.

) : viewMode === "card" ? (
{parts.map((part) => (
{part.brand} — {part.name}
{part.notes && (

{part.notes}

)}
${part.price.toFixed(2)}
View Details
))}
) : (
{parts.map((part) => (
{part.brand} — {part.name}
{part.notes && (

{part.notes}

)}
${part.price.toFixed(2)}
View Details
))}
)}
); }