fixed part role mapping to categories. set a const for categories
This commit is contained in:
+78
-82
@@ -1,111 +1,107 @@
|
||||
import type { Category, Part } from "@/types/gunbuilder";
|
||||
|
||||
export const CATEGORIES: Category[] = [
|
||||
{ id: "lower", name: "Lower Receiver" },
|
||||
{ id: "upper", name: "Upper Receiver" },
|
||||
{ id: "barrel", name: "Barrel" },
|
||||
{ id: "handguard", name: "Handguard" },
|
||||
{ id: "stock", name: "Stock" },
|
||||
{ id: "optic", name: "Optic" },
|
||||
];
|
||||
// LOWER
|
||||
{
|
||||
id: "lower",
|
||||
name: "Stripped Lower Receiver",
|
||||
description: "Serialized lower – the foundation of the build.",
|
||||
},
|
||||
{
|
||||
id: "completeLower",
|
||||
name: "Complete Lower",
|
||||
description: "Factory-built lower with stock, buffer system, and controls.",
|
||||
},
|
||||
{
|
||||
id: "lowerParts",
|
||||
name: "Lower Parts Kit",
|
||||
description: "Pins, springs, and controls for the lower.",
|
||||
},
|
||||
{
|
||||
id: "trigger",
|
||||
name: "Trigger / Fire Control",
|
||||
description: "Single-stage, two-stage, and match triggers.",
|
||||
},
|
||||
{
|
||||
id: "grip",
|
||||
name: "Pistol Grip",
|
||||
description: "Grips that shape how the rifle handles.",
|
||||
},
|
||||
{
|
||||
id: "safety",
|
||||
name: "Safety / Selector",
|
||||
description: "Ambi selectors and control upgrades.",
|
||||
},
|
||||
{
|
||||
id: "buffer",
|
||||
name: "Buffer System",
|
||||
description: "Buffer tube, buffer, spring, and related parts.",
|
||||
},
|
||||
{
|
||||
id: "stock",
|
||||
name: "Stock / Brace",
|
||||
description: "Adjustable, fixed, and minimalist stocks.",
|
||||
},
|
||||
|
||||
export const PARTS: Part[] = [
|
||||
// UPPER
|
||||
{
|
||||
id: "lower-aero-m4e1",
|
||||
name: "M4E1 Stripped Lower Receiver",
|
||||
brand: "Aero Precision",
|
||||
categoryId: "lower",
|
||||
price: 129.99,
|
||||
affiliateUrl: "https://example.com/aero-m4e1",
|
||||
notes: "Forged 7075-T6, threaded bolt catch",
|
||||
id: "upper",
|
||||
name: "Stripped Upper Receiver",
|
||||
description: "The core of the top half of your build.",
|
||||
},
|
||||
{
|
||||
id: "lower-solgw",
|
||||
name: "Loyal 9 Stripped Lower",
|
||||
brand: "Sons of Liberty Gun Works",
|
||||
categoryId: "lower",
|
||||
price: 189.0,
|
||||
affiliateUrl: "https://example.com/solgw-lower",
|
||||
id: "completeUpper",
|
||||
name: "Complete Upper",
|
||||
description: "Pre-assembled uppers ready to pin and shoot.",
|
||||
},
|
||||
{
|
||||
id: "upper-aero-enhanced",
|
||||
name: "Enhanced Upper Receiver",
|
||||
brand: "Aero Precision",
|
||||
categoryId: "upper",
|
||||
price: 149.99,
|
||||
affiliateUrl: "https://example.com/aero-enhanced-upper",
|
||||
id: "bcg",
|
||||
name: "Bolt Carrier Group",
|
||||
description: "The heartbeat of the rifle’s cycling.",
|
||||
},
|
||||
{
|
||||
id: "upper-bcm-m4",
|
||||
name: "M4 Upper Receiver",
|
||||
brand: "BCM",
|
||||
categoryId: "upper",
|
||||
price: 159.99,
|
||||
affiliateUrl: "https://example.com/bcm-m4-upper",
|
||||
id: "barrel",
|
||||
name: "Barrel",
|
||||
description: "Different lengths, profiles, and calibers.",
|
||||
},
|
||||
{
|
||||
id: "barrel-criterion-16",
|
||||
name: "16\" Hybrid Barrel",
|
||||
brand: "Criterion",
|
||||
categoryId: "barrel",
|
||||
price: 279.99,
|
||||
affiliateUrl: "https://example.com/criterion-16",
|
||||
notes: "Mid-length gas, chrome-lined",
|
||||
id: "gasBlock",
|
||||
name: "Gas Block",
|
||||
description: "Standard and adjustable gas blocks.",
|
||||
},
|
||||
{
|
||||
id: "barrel-ba-13-9",
|
||||
name: "13.9\" Hanson Performance Series",
|
||||
brand: "Ballistic Advantage",
|
||||
categoryId: "barrel",
|
||||
price: 209.99,
|
||||
affiliateUrl: "https://example.com/ba-13-9",
|
||||
id: "gasTube",
|
||||
name: "Gas Tube",
|
||||
description: "Carbine, mid, rifle, and more.",
|
||||
},
|
||||
{
|
||||
id: "hg-geissele-mk8",
|
||||
name: "MK8 Rail 13.5\"",
|
||||
brand: "Geissele",
|
||||
categoryId: "handguard",
|
||||
price: 324.99,
|
||||
affiliateUrl: "https://example.com/geissele-mk8",
|
||||
id: "muzzleDevice",
|
||||
name: "Muzzle Device",
|
||||
description: "Brakes, comps, and flash hiders.",
|
||||
},
|
||||
{
|
||||
id: "hg-centurion-c4",
|
||||
name: "C4 M-LOK 12\"",
|
||||
brand: "Centurion Arms",
|
||||
categoryId: "handguard",
|
||||
price: 284.99,
|
||||
affiliateUrl: "https://example.com/centurion-c4",
|
||||
id: "suppressor",
|
||||
name: "Suppressor",
|
||||
description: "Hearing-safe setups and hosts.",
|
||||
},
|
||||
{
|
||||
id: "stock-b5-bravo",
|
||||
name: "BRAVO Stock",
|
||||
brand: "B5 Systems",
|
||||
categoryId: "stock",
|
||||
price: 74.99,
|
||||
affiliateUrl: "https://example.com/b5-bravo",
|
||||
id: "handguard",
|
||||
name: "Handguard / Rail",
|
||||
description: "M-LOK rails and front-end furniture.",
|
||||
},
|
||||
{
|
||||
id: "stock-magpul-sl",
|
||||
name: "MOE SL Carbine Stock",
|
||||
brand: "Magpul",
|
||||
categoryId: "stock",
|
||||
price: 69.99,
|
||||
affiliateUrl: "https://example.com/magpul-sl",
|
||||
id: "chargingHandle",
|
||||
name: "Charging Handle",
|
||||
description: "Standard and ambi charging handles.",
|
||||
},
|
||||
{
|
||||
id: "optic-eotech-exps3",
|
||||
name: "EXPS3 Holographic Sight",
|
||||
brand: "EOTECH",
|
||||
categoryId: "optic",
|
||||
price: 749.0,
|
||||
affiliateUrl: "https://example.com/eotech-exps3",
|
||||
id: "sights",
|
||||
name: "Iron Sights",
|
||||
description: "Backup and primary irons.",
|
||||
},
|
||||
{
|
||||
id: "optic-holosun-509t",
|
||||
name: "HE509T Red Dot",
|
||||
brand: "Holosun",
|
||||
categoryId: "optic",
|
||||
price: 349.99,
|
||||
affiliateUrl: "https://example.com/holosun-509t",
|
||||
id: "optic",
|
||||
name: "Optic",
|
||||
description: "LPVOs, red dots, and magnifiers.",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { CategoryId } from "@/types/gunbuilder";
|
||||
|
||||
// CategoryId -> partRoles
|
||||
export const CATEGORY_TO_PART_ROLES: Record<CategoryId, string[]> = {
|
||||
// CORE / EXISTING
|
||||
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"],
|
||||
|
||||
// NEW LOWER PARTS
|
||||
trigger: ["trigger", "trigger-kit"],
|
||||
grip: ["pistol-grip", "grip"],
|
||||
safety: ["safety", "safety-selector"],
|
||||
completeLower: ["complete-lower"],
|
||||
|
||||
// NEW UPPER PARTS
|
||||
completeUpper: ["complete-upper"],
|
||||
bcg: ["bcg", "bolt-carrier-group"],
|
||||
gasBlock: ["gas-block"],
|
||||
gasTube: ["gas-tube"],
|
||||
muzzleDevice: ["muzzle-device", "compensator", "brake"],
|
||||
suppressor: ["suppressor"],
|
||||
};
|
||||
|
||||
// Invert to get partRole -> CategoryId
|
||||
export const PART_ROLE_TO_CATEGORY: Record<string, CategoryId> = Object
|
||||
.entries(CATEGORY_TO_PART_ROLES)
|
||||
.reduce((acc, [categoryId, roles]) => {
|
||||
for (const role of roles) {
|
||||
acc[role] = categoryId as CategoryId;
|
||||
}
|
||||
return acc;
|
||||
}, {} as Record<string, CategoryId>);
|
||||
Reference in New Issue
Block a user