2025-06-30 13:34:27 -04:00
|
|
|
// Minimal, future-proof category mapping for builder logic
|
2025-06-30 13:02:19 -04:00
|
|
|
export const categoryToComponentType: Record<string, string> = {
|
2025-06-30 13:34:27 -04:00
|
|
|
"Muzzle Devices": "Muzzle Device",
|
|
|
|
|
"Receiver Parts": "Lower Receiver",
|
|
|
|
|
"Barrel Parts": "Barrel",
|
|
|
|
|
"Stock Parts": "Stock",
|
|
|
|
|
"Bolt Parts": "Bolt Carrier Group",
|
|
|
|
|
"Triggers Parts": "Trigger",
|
|
|
|
|
"Sights": "Accessories"
|
2025-06-30 13:02:19 -04:00
|
|
|
};
|
|
|
|
|
|
2025-06-30 13:34:27 -04:00
|
|
|
// Map category to builder component type, with fallback heuristics
|
|
|
|
|
export function mapToBuilderType(category: string): string {
|
|
|
|
|
if (categoryToComponentType[category]) {
|
|
|
|
|
return categoryToComponentType[category];
|
|
|
|
|
}
|
|
|
|
|
// Fallback: guess based on keywords
|
|
|
|
|
if (category?.toLowerCase().includes('barrel')) return 'Barrel';
|
|
|
|
|
if (category?.toLowerCase().includes('stock')) return 'Stock';
|
|
|
|
|
if (category?.toLowerCase().includes('bolt')) return 'Bolt Carrier Group';
|
|
|
|
|
if (category?.toLowerCase().includes('trigger')) return 'Trigger';
|
|
|
|
|
if (category?.toLowerCase().includes('sight') || category?.toLowerCase().includes('optic')) return 'Accessories';
|
|
|
|
|
// Log for future mapping
|
|
|
|
|
console.warn('Unmapped category:', category);
|
|
|
|
|
return 'Accessories';
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-30 13:02:19 -04:00
|
|
|
// List of standardized builder component types (from component_type.csv)
|
|
|
|
|
export const standardizedComponentTypes = [
|
|
|
|
|
"Upper Receiver",
|
|
|
|
|
"Barrel",
|
|
|
|
|
"Muzzle Device",
|
|
|
|
|
"Lower Receiver",
|
|
|
|
|
"Safety",
|
|
|
|
|
"Trigger",
|
|
|
|
|
"Gas Tube",
|
|
|
|
|
"Gas Block",
|
|
|
|
|
"Grips",
|
|
|
|
|
"Handguards",
|
|
|
|
|
"Charging Handle",
|
|
|
|
|
"Bolt Carrier Group",
|
|
|
|
|
"Magazine",
|
|
|
|
|
"Buffer Assembly",
|
|
|
|
|
"Buffer Tube",
|
|
|
|
|
"Foregrips",
|
|
|
|
|
"Lower Parts Kit",
|
|
|
|
|
"Accessories"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Builder category hierarchy for filters
|
|
|
|
|
export const builderCategories = [
|
|
|
|
|
{
|
|
|
|
|
id: "upper-parts",
|
|
|
|
|
name: "Upper Parts",
|
|
|
|
|
subcategories: [
|
|
|
|
|
{ id: "complete-upper", name: "Complete Upper Receiver" },
|
|
|
|
|
{ id: "stripped-upper", name: "Stripped Upper Receiver" },
|
|
|
|
|
{ id: "barrel", name: "Barrel" },
|
|
|
|
|
{ id: "gas-block", name: "Gas Block" },
|
|
|
|
|
{ id: "gas-tube", name: "Gas Tube" },
|
|
|
|
|
{ id: "handguard", name: "Handguard / Rail" },
|
|
|
|
|
{ id: "bcg", name: "Bolt Carrier Group (BCG)" },
|
|
|
|
|
{ id: "charging-handle", name: "Charging Handle" },
|
|
|
|
|
{ id: "muzzle-device", name: "Muzzle Device" },
|
|
|
|
|
{ id: "forward-assist", name: "Forward Assist" },
|
|
|
|
|
{ id: "dust-cover", name: "Dust Cover" }
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "lower-parts",
|
|
|
|
|
name: "Lower Parts",
|
|
|
|
|
subcategories: [
|
|
|
|
|
{ id: "complete-lower", name: "Complete Lower Receiver" },
|
|
|
|
|
{ id: "stripped-lower", name: "Stripped Lower Receiver" },
|
|
|
|
|
{ id: "lower-parts-kit", name: "Lower Parts Kit" },
|
|
|
|
|
{ id: "trigger", name: "Trigger / Fire Control Group" },
|
|
|
|
|
{ id: "buffer-tube", name: "Buffer Tube Assembly" },
|
|
|
|
|
{ id: "buffer-spring", name: "Buffer & Spring" },
|
|
|
|
|
{ id: "stock", name: "Stock / Brace" },
|
|
|
|
|
{ id: "pistol-grip", name: "Pistol Grip" },
|
|
|
|
|
{ id: "trigger-guard", name: "Trigger Guard" },
|
|
|
|
|
{ id: "ambi-controls", name: "Ambidextrous Controls" }
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "accessories",
|
|
|
|
|
name: "Accessories",
|
|
|
|
|
subcategories: [
|
|
|
|
|
{ id: "optics", name: "Optics & Sights" },
|
|
|
|
|
{ id: "sling-mounts", name: "Sling Mounts / QD Points" },
|
|
|
|
|
{ id: "slings", name: "Slings" },
|
|
|
|
|
{ id: "grips-bipods", name: "Vertical Grips / Bipods" },
|
|
|
|
|
{ id: "lights", name: "Weapon Lights" },
|
|
|
|
|
{ id: "magazines", name: "Magazines" },
|
|
|
|
|
{ id: "optic-mounts", name: "Optic Mounts / Rings" },
|
|
|
|
|
{ id: "suppressors", name: "Suppressors / Adapters" }
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "kits-bundles",
|
|
|
|
|
name: "Kits / Bundles",
|
|
|
|
|
subcategories: [
|
|
|
|
|
{ id: "rifle-kit", name: "Rifle Kit" },
|
|
|
|
|
{ id: "pistol-kit", name: "Pistol Kit" },
|
|
|
|
|
{ id: "upper-kit", name: "Upper Build Kit" },
|
|
|
|
|
{ id: "lower-kit", name: "Lower Build Kit" },
|
|
|
|
|
{ id: "kit-80", name: "80% Build Kit" },
|
|
|
|
|
{ id: "receiver-set", name: "Matched Receiver Set" }
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Example subcategory mapping (expand as needed)
|
|
|
|
|
export const subcategoryMapping: Record<string, string> = {
|
|
|
|
|
"Rifle Barrels": "barrel",
|
|
|
|
|
"Bolt Carrier Groups": "bcg",
|
|
|
|
|
"Handguards & Rails": "handguard",
|
|
|
|
|
"Suppressors": "suppressors",
|
|
|
|
|
"Receivers": "complete-upper", // or "stripped-upper" if you want to split
|
|
|
|
|
"Triggers": "trigger",
|
|
|
|
|
"Rifle Stocks": "stock",
|
|
|
|
|
"Buttstocks": "stock",
|
|
|
|
|
// ...add more mappings as needed
|
|
|
|
|
};
|