"use client"; import { useMemo } from "react"; import Link from "next/link"; import { useParams } from "next/navigation"; import { CATEGORIES, PARTS } from "@/data/gunbuilderParts"; import type { CategoryId } from "@/types/gunbuilder"; import { getPricingHistory, getRetailerOffers } from "./data"; import { PricingHistoryGraph } from "@/components/PricingHistoryGraph"; import { RetailersList } from "@/components/RetailersList"; export default function PartDetailPage() { const params = useParams(); const categoryId = params.categoryId as CategoryId; const partId = params.partId as string; const category = useMemo( () => CATEGORIES.find((c) => c.id === categoryId), [categoryId], ); const part = useMemo( () => PARTS.find((p) => p.id === partId && p.categoryId === categoryId), [partId, categoryId], ); // Get pricing history and retailer offers // TODO: Replace with API calls when endpoints are ready const pricingHistory = useMemo( () => (part ? getPricingHistory(part.id, part.price) : []), [part], ); const retailerOffers = useMemo( () => part ? getRetailerOffers(part.id, part.price, part.affiliateUrl) : [], [part], ); if (!category || !part) { return ( Product Not Found Return to Gunbuilder ); } return ( {/* Header */} ← Back to {category.name} Shadow Standard {part.brand} {part.name} {category.name} • Product Details {/* Product Details */} {/* Main Content */} {/* Product Information */} {/* Product Info */} Product Information Brand {part.brand} Model {part.name} Category {category.name} {part.notes && ( Details {part.notes} )} {/* Product Image */} Product Image {/* Retailers List */} {retailerOffers.length > 0 && ( )} {/* Sidebar */} ); }
Shadow Standard
{category.name} • Product Details
Product Image