fixed part role mapping to categories. set a const for categories

This commit is contained in:
2025-12-02 21:13:17 -05:00
parent c51ce862a9
commit 4b823f49cf
196 changed files with 2820 additions and 164 deletions
+40
View File
@@ -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>);