mirror of
https://gitea.gofwd.group/sean/gunbuilder-next-tailwind.git
synced 2025-12-06 02:56:45 -05:00
/admin and with working with db. data is pulling from db
This commit is contained in:
124
src/app/(main)/parts/categoryMapping.ts
Normal file
124
src/app/(main)/parts/categoryMapping.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
// Minimal, future-proof category mapping for builder logic
|
||||
export const categoryToComponentType: Record<string, string> = {
|
||||
"Muzzle Devices": "Muzzle Device",
|
||||
"Receiver Parts": "Lower Receiver",
|
||||
"Barrel Parts": "Barrel",
|
||||
"Stock Parts": "Stock",
|
||||
"Bolt Parts": "Bolt Carrier Group",
|
||||
"Triggers Parts": "Trigger",
|
||||
"Sights": "Accessories"
|
||||
};
|
||||
|
||||
// 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';
|
||||
}
|
||||
|
||||
// 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
|
||||
};
|
||||
Reference in New Issue
Block a user