little bit of ui clean up and fixing the platform labels/keys
This commit is contained in:
@@ -19,6 +19,7 @@ import SortBar from "@/components/parts/SortBar";
|
||||
import PartsGrid from "@/components/parts/PartsGrid";
|
||||
import Pagination from "@/components/parts/Pagination";
|
||||
import PlatformSwitcher from "@/components/parts/PlatformSwitcher";
|
||||
import { normalizePlatformKey } from "@/lib/platforms";
|
||||
|
||||
import type { Category } from "@/types/builderSlots";
|
||||
import {
|
||||
@@ -111,9 +112,10 @@ export default function PartsBrowseClient(props: {
|
||||
const isBuilderMode = pathname.startsWith("/parts/p/");
|
||||
|
||||
// ✅ Respect prop override first, else read query, else fallback
|
||||
const effectivePlatform =
|
||||
props.platform ?? searchParams.get("platform") ?? "AR-15";
|
||||
|
||||
const effectivePlatform = normalizePlatformKey(
|
||||
props.platform ?? searchParams.get("platform") ?? "AR15"
|
||||
);
|
||||
|
||||
const partRole = props.partRole;
|
||||
|
||||
const [viewMode, setViewMode] = useState<ViewMode>("list");
|
||||
@@ -149,7 +151,7 @@ export default function PartsBrowseClient(props: {
|
||||
setError(null);
|
||||
|
||||
const search = new URLSearchParams();
|
||||
search.set("platform", effectivePlatform);
|
||||
search.set("platform", normalizePlatformKey(effectivePlatform));
|
||||
search.append("partRole", partRole);
|
||||
|
||||
// server paging (0-based)
|
||||
@@ -320,7 +322,7 @@ export default function PartsBrowseClient(props: {
|
||||
}
|
||||
|
||||
const qp = new URLSearchParams();
|
||||
qp.set("platform", effectivePlatform);
|
||||
qp.set("platform", normalizePlatformKey(effectivePlatform));
|
||||
qp.set("select", `${categoryId}:${p.id}`);
|
||||
|
||||
router.push(`/builder?${qp.toString()}`);
|
||||
@@ -344,14 +346,14 @@ export default function PartsBrowseClient(props: {
|
||||
{headingSubtitle}
|
||||
</p>
|
||||
|
||||
{!isBuilderMode && (
|
||||
{/* {!isBuilderMode && (
|
||||
<div className="mt-4 flex flex-wrap items-center gap-3">
|
||||
<PlatformSwitcher
|
||||
currentPlatform={effectivePlatform}
|
||||
partRole={partRole}
|
||||
preserveQuery
|
||||
mode="browse"
|
||||
/>
|
||||
/> */}
|
||||
|
||||
<Link
|
||||
href={`/builder?platform=${encodeURIComponent(
|
||||
@@ -361,8 +363,8 @@ export default function PartsBrowseClient(props: {
|
||||
>
|
||||
Start New Build →
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
{/* </div>
|
||||
)} */}
|
||||
</div>
|
||||
|
||||
{isBuilderMode && (
|
||||
|
||||
Reference in New Issue
Block a user