fixed part role mapping to categories. set a const for categories
This commit is contained in:
@@ -4,6 +4,7 @@ import { useEffect, useMemo, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { CATEGORIES } from "@/data/gunbuilderParts";
|
||||
import { CATEGORY_TO_PART_ROLES } from "@/data/partRoleMappings";
|
||||
import type { CategoryId, Part } from "@/types/gunbuilder";
|
||||
|
||||
type ViewMode = "card" | "list";
|
||||
@@ -22,18 +23,6 @@ type GunbuilderProductFromApi = {
|
||||
const API_BASE_URL =
|
||||
process.env.NEXT_PUBLIC_API_BASE_URL ?? "http://localhost:8080";
|
||||
|
||||
const CATEGORY_TO_PART_ROLES: Record<CategoryId, string[]> = {
|
||||
upper: ["upper-receiver"],
|
||||
barrel: ["barrel"],
|
||||
handguard: ["handguard"],
|
||||
chargingHandle: ["charging-handle"],
|
||||
buffer: ["buffer-kit"],
|
||||
lowerParts: ["lower-parts-kit"],
|
||||
sights: ["sight"],
|
||||
lower: ["lower-receiver"],
|
||||
optic: ["optic"],
|
||||
stock: ["stock"],
|
||||
};
|
||||
|
||||
// sort options
|
||||
type SortOption = "relevance" | "price-asc" | "price-desc" | "brand-asc";
|
||||
@@ -80,10 +69,11 @@ export default function CategoryPage() {
|
||||
|
||||
async function fetchCategoryParts() {
|
||||
try {
|
||||
setLoading(true);
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
const roles = CATEGORY_TO_PART_ROLES[categoryId] ?? [];
|
||||
// FIX: determine which backend partRoles map to this category
|
||||
const roles = CATEGORY_TO_PART_ROLES[categoryId] ?? [];
|
||||
|
||||
const search = new URLSearchParams();
|
||||
search.set("platform", "AR-15");
|
||||
|
||||
Reference in New Issue
Block a user