fixed builder hydration issues

This commit is contained in:
2026-01-18 08:39:29 -05:00
parent b55bd7041d
commit 045e742362
5 changed files with 1143 additions and 299 deletions
+7 -5
View File
@@ -21,7 +21,7 @@ import Pagination from "@/components/parts/Pagination";
import PlatformSwitcher from "@/components/parts/PlatformSwitcher";
import { normalizePlatformKey } from "@/lib/platforms";
import type { UiPart } from "@/types/uiPart";
import type { Category } from "@/types/builderSlots";
import type { BuilderSlotKey, Category } from "@/types/builderSlots";
import {
PART_ROLE_TO_CATEGORY,
normalizePartRole,
@@ -310,15 +310,17 @@ export default function PartsBrowseClient(props: {
// Add → Builder handoff
// ----------------------------
const handleAddToBuild = (p: UiPart) => {
const normalizedRole = normalizePartRole(partRole);
const categoryId: Category | null =
// Always normalize first; our mappings may alias multiple roles to one canonical builder category
const roleKey = normalizePartRole(partRole);
const categoryId: BuilderSlotKey | null =
PART_ROLE_TO_CATEGORY[roleKey] ??
PART_ROLE_TO_CATEGORY[partRole] ??
PART_ROLE_TO_CATEGORY[normalizedRole] ??
null;
if (!categoryId) {
alert(
`No Category mapping found for role "${partRole}". Add it to catalogMappings.`
`No Category mapping found for role "${partRole}" (normalized: "${roleKey}"). Add it to catalogMappings.`
);
return;
}