fixing role ,apping. added accessories to ui
This commit is contained in:
+21
-21
@@ -1,9 +1,9 @@
|
||||
import type { Category } from "@/types/gunbuilder";
|
||||
|
||||
export const CATEGORY_SLUGS = {
|
||||
export const CATEGORY_SLUGS: Record<string, string> = {
|
||||
lower: "lower",
|
||||
"complete-lower": "complete-lower",
|
||||
"lower-parts": "lower-parts",
|
||||
completeLower: "complete-lower",
|
||||
lowerParts: "lower-parts",
|
||||
trigger: "trigger",
|
||||
grip: "grip",
|
||||
safety: "safety",
|
||||
@@ -11,32 +11,32 @@ export const CATEGORY_SLUGS = {
|
||||
stock: "stock",
|
||||
|
||||
upper: "upper",
|
||||
"complete-upper": "complete-upper",
|
||||
completeUpper: "complete-upper",
|
||||
barrel: "barrel",
|
||||
handguard: "handguard",
|
||||
"gas-block": "gas-block",
|
||||
"gas-tube": "gas-tube",
|
||||
"muzzle-device": "muzzle-device",
|
||||
gasBlock: "gas-block",
|
||||
gasTube: "gas-tube",
|
||||
muzzleDevice: "muzzle-device",
|
||||
bcg: "bcg",
|
||||
sights: "sights",
|
||||
"charging-handle": "charging-handle",
|
||||
chargingHandle: "charging-handle",
|
||||
suppressor: "suppressor",
|
||||
optic: "optic",
|
||||
|
||||
magazine: "magazine",
|
||||
"weapon-light": "weapon-light",
|
||||
weaponLight: "weapon-light",
|
||||
foregrip: "foregrip",
|
||||
bipod: "bipod",
|
||||
sling: "sling",
|
||||
"rail-accessory": "rail-accessory",
|
||||
railAccessory: "rail-accessory",
|
||||
tools: "tools",
|
||||
} as const;
|
||||
};
|
||||
|
||||
export const CATEGORIES: Category[] = [
|
||||
// Lower group
|
||||
{ id: "lower", name: "Stripped Lowers", group: "lower", slug: CATEGORY_SLUGS.lower },
|
||||
{ id: "complete-lower", name: "Complete Lower", group: "lower", slug: CATEGORY_SLUGS["complete-lower"] },
|
||||
{ id: "lower-parts", name: "Lower Parts Kit", group: "lower", slug: CATEGORY_SLUGS["lower-parts"] },
|
||||
{ id: "completeLower", name: "Complete Lower", group: "lower", slug: CATEGORY_SLUGS.completeLower },
|
||||
{ id: "lowerParts", name: "Lower Parts Kit", group: "lower", slug: CATEGORY_SLUGS.lowerParts },
|
||||
{ id: "trigger", name: "Trigger / Fire Control", group: "lower", slug: CATEGORY_SLUGS.trigger },
|
||||
{ id: "grip", name: "Pistol Grip", group: "lower", slug: CATEGORY_SLUGS.grip },
|
||||
{ id: "safety", name: "Safety / Selector", group: "lower", slug: CATEGORY_SLUGS.safety },
|
||||
@@ -45,24 +45,24 @@ export const CATEGORIES: Category[] = [
|
||||
|
||||
// Upper group
|
||||
{ id: "upper", name: "Stripped Upper", group: "upper", slug: CATEGORY_SLUGS.upper },
|
||||
{ id: "complete-upper", name: "Complete Upper", group: "upper", slug: CATEGORY_SLUGS["complete-upper"] },
|
||||
{ id: "completeUpper", name: "Complete Upper", group: "upper", slug: CATEGORY_SLUGS.completeUpper },
|
||||
{ id: "barrel", name: "Barrels", group: "upper", slug: CATEGORY_SLUGS.barrel },
|
||||
{ id: "handguard", name: "Handguards / Rails", group: "upper", slug: CATEGORY_SLUGS.handguard },
|
||||
{ id: "gas-block", name: "Gas Block", group: "upper", slug: CATEGORY_SLUGS["gas-block"] },
|
||||
{ id: "gas-tube", name: "Gas Tube", group: "upper", slug: CATEGORY_SLUGS["gas-tube"] },
|
||||
{ id: "muzzle-device", name: "Muzzle Device", group: "upper", slug: CATEGORY_SLUGS["muzzle-device"] },
|
||||
{ id: "gasBlock", name: "Gas Block", group: "upper", slug: CATEGORY_SLUGS.gasBlock },
|
||||
{ id: "gasTube", name: "Gas Tube", group: "upper", slug: CATEGORY_SLUGS.gasTube },
|
||||
{ id: "muzzleDevice", name: "Muzzle Device", group: "upper", slug: CATEGORY_SLUGS.muzzleDevice },
|
||||
{ id: "sights", name: "Iron Sights", group: "upper", slug: CATEGORY_SLUGS.sights },
|
||||
{ id: "bcg", name: "Bolt Carrier Group", group: "upper", slug: CATEGORY_SLUGS.bcg },
|
||||
{ id: "charging-handle", name: "Charging Handle", group: "upper", slug: CATEGORY_SLUGS["charging-handle"] },
|
||||
{ id: "chargingHandle", name: "Charging Handle", group: "upper", slug: CATEGORY_SLUGS.chargingHandle },
|
||||
{ id: "suppressor", name: "Suppressors", group: "upper", slug: CATEGORY_SLUGS.suppressor },
|
||||
{ id: "optic", name: "Optics", group: "upper", slug: CATEGORY_SLUGS.optic },
|
||||
|
||||
// Accessories
|
||||
// Accessories (platform-agnostic)
|
||||
{ id: "magazine", name: "Magazines", group: "accessories", slug: CATEGORY_SLUGS.magazine },
|
||||
{ id: "weapon-light", name: "Weapon Lights & Lasers", group: "accessories", slug: CATEGORY_SLUGS["weapon-light"] },
|
||||
{ id: "weaponLight", name: "Weapon Lights & Lasers", group: "accessories", slug: CATEGORY_SLUGS.weaponLight },
|
||||
{ id: "foregrip", name: "Vertical / Angled Grips", group: "accessories", slug: CATEGORY_SLUGS.foregrip },
|
||||
{ id: "bipod", name: "Bipods", group: "accessories", slug: CATEGORY_SLUGS.bipod },
|
||||
{ id: "sling", name: "Slings & Mounts", group: "accessories", slug: CATEGORY_SLUGS.sling },
|
||||
{ id: "rail-accessory", name: "Rail Accessories", group: "accessories", slug: CATEGORY_SLUGS["rail-accessory"] },
|
||||
{ id: "railAccessory", name: "Rail Accessories", group: "accessories", slug: CATEGORY_SLUGS.railAccessory },
|
||||
{ id: "tools", name: "Tools & Maintenance", group: "accessories", slug: CATEGORY_SLUGS.tools },
|
||||
];
|
||||
+24
-85
@@ -1,102 +1,41 @@
|
||||
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_STRIPPED"],
|
||||
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
|
||||
upper: ["upper-receiver", "upper"],
|
||||
completeUpper: ["complete-upper"],
|
||||
bcg: ["bcg", "bolt-carrier-group"],
|
||||
barrel: ["barrel"],
|
||||
gasBlock: ["gas-block"],
|
||||
gasTube: ["gas-tube"],
|
||||
muzzleDevice: ["muzzle-device", "compensator", "brake"],
|
||||
suppressor: ["suppressor"],
|
||||
handguard: ["handguard"],
|
||||
chargingHandle: ["charging-handle"],
|
||||
bcg: ["bcg", "bolt-carrier-group"],
|
||||
|
||||
// ===== ACCESSORIES =====
|
||||
lower: ["lower-receiver", "lower", "LOWER_RECEIVER_STRIPPED"],
|
||||
completeLower: ["complete-lower"],
|
||||
lowerParts: ["lower-parts-kit", "lower-parts"],
|
||||
trigger: ["trigger", "trigger-kit"],
|
||||
grip: ["pistol-grip", "grip"],
|
||||
safety: ["safety", "safety-selector"],
|
||||
buffer: ["buffer-kit", "buffer"],
|
||||
stock: ["stock"],
|
||||
|
||||
// Magazines
|
||||
magazine: [
|
||||
"magazine",
|
||||
"mag",
|
||||
"magazine-ar15",
|
||||
"magazine-308",
|
||||
"drum-magazine",
|
||||
],
|
||||
sights: ["sight", "sights", "iron-sights"],
|
||||
optic: ["optic", "optics"],
|
||||
|
||||
// Lights / Lasers
|
||||
weaponLight: [
|
||||
"weapon-light",
|
||||
"light",
|
||||
"weapon-light-laser",
|
||||
"light-laser-combo",
|
||||
"laser",
|
||||
],
|
||||
|
||||
// Foregrips
|
||||
foregrip: [
|
||||
"vertical-grip",
|
||||
"angled-foregrip",
|
||||
"foregrip",
|
||||
"handstop",
|
||||
],
|
||||
|
||||
// Bipods
|
||||
bipod: [
|
||||
"bipod",
|
||||
],
|
||||
|
||||
// Slings & mounts
|
||||
sling: [
|
||||
"sling",
|
||||
"sling-mount",
|
||||
"sling-swivel",
|
||||
"qd-sling-mount",
|
||||
],
|
||||
|
||||
// Rail sections & covers
|
||||
railAccessory: [
|
||||
"rail-section",
|
||||
"picatinny-rail-section",
|
||||
"m-lok-rail-section",
|
||||
"keymod-rail-section",
|
||||
"rail-cover",
|
||||
"rail-panel",
|
||||
],
|
||||
|
||||
// Tools & maintenance
|
||||
tools: [
|
||||
"tool",
|
||||
"armorer-tool",
|
||||
"armorer-wrench",
|
||||
"cleaning-kit",
|
||||
"bore-snake",
|
||||
"vise-block",
|
||||
"torque-wrench",
|
||||
],
|
||||
magazine: ["magazine", "mag", "magazine-ar15", "magazine-308", "drum-magazine"],
|
||||
weaponLight: ["weapon-light", "light", "weapon-light-laser", "light-laser-combo", "laser"],
|
||||
foregrip: ["vertical-grip", "angled-foregrip", "foregrip", "handstop"],
|
||||
bipod: ["bipod"],
|
||||
sling: ["sling", "sling-mount", "sling-swivel", "qd-sling-mount"],
|
||||
railAccessory: ["rail-section", "picatinny-rail-section", "m-lok-rail-section", "keymod-rail-section", "rail-cover", "rail-panel"],
|
||||
tools: ["tool", "armorer-tool", "armorer-wrench", "cleaning-kit", "bore-snake", "vise-block", "torque-wrench"],
|
||||
};
|
||||
|
||||
// Invert to get partRole -> CategoryId
|
||||
export const PART_ROLE_TO_CATEGORY: Record<string, CategoryId> = Object.entries(
|
||||
CATEGORY_TO_PART_ROLES,
|
||||
CATEGORY_TO_PART_ROLES
|
||||
).reduce((acc, [categoryId, roles]) => {
|
||||
for (const role of roles) {
|
||||
acc[role] = categoryId as CategoryId;
|
||||
}
|
||||
for (const role of roles) acc[role] = categoryId as CategoryId;
|
||||
return acc;
|
||||
}, {} as Record<string, CategoryId>);
|
||||
Reference in New Issue
Block a user