fixing hydration issue
This commit is contained in:
@@ -20,7 +20,7 @@ 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 { UiPart } from "@/types/uiPart";
|
||||
import type { Category } from "@/types/builderSlots";
|
||||
import {
|
||||
PART_ROLE_TO_CATEGORY,
|
||||
@@ -58,18 +58,6 @@ type GunbuilderProductFromApi = {
|
||||
inStock?: boolean | null;
|
||||
};
|
||||
|
||||
type UiPart = {
|
||||
id: string;
|
||||
name: string;
|
||||
brand: string;
|
||||
platform: string;
|
||||
partRole: string;
|
||||
price: number;
|
||||
imageUrl?: string;
|
||||
buyUrl?: string;
|
||||
inStock?: boolean;
|
||||
};
|
||||
|
||||
const API_BASE_URL =
|
||||
process.env.NEXT_PUBLIC_API_BASE_URL ?? "http://localhost:8080";
|
||||
|
||||
@@ -115,7 +103,7 @@ export default function PartsBrowseClient(props: {
|
||||
const effectivePlatform = normalizePlatformKey(
|
||||
props.platform ?? searchParams.get("platform") ?? "AR15"
|
||||
);
|
||||
|
||||
|
||||
const partRole = props.partRole;
|
||||
|
||||
const [viewMode, setViewMode] = useState<ViewMode>("list");
|
||||
@@ -201,10 +189,11 @@ export default function PartsBrowseClient(props: {
|
||||
brand: p.brand,
|
||||
platform: p.platform,
|
||||
partRole: p.partRole,
|
||||
price: p.price ?? 0,
|
||||
price: p.price,
|
||||
imageUrl: p.imageUrl ?? undefined,
|
||||
buyUrl: p.buyUrl ?? undefined,
|
||||
inStock: p.inStock ?? true,
|
||||
inStock: p.inStock ?? undefined,
|
||||
caliber: (p as any).caliber ?? null,
|
||||
}))
|
||||
);
|
||||
|
||||
@@ -264,12 +253,11 @@ export default function PartsBrowseClient(props: {
|
||||
);
|
||||
|
||||
const priceBounds = useMemo(() => {
|
||||
if (!parts.length)
|
||||
return { min: null as number | null, max: null as number | null };
|
||||
return {
|
||||
min: Math.min(...parts.map((p) => p.price)),
|
||||
max: Math.max(...parts.map((p) => p.price)),
|
||||
};
|
||||
const prices = parts
|
||||
.map((p) => p.price)
|
||||
.filter((v): v is number => typeof v === "number");
|
||||
if (!prices.length) return { min: null, max: null };
|
||||
return { min: Math.min(...prices), max: Math.max(...prices) };
|
||||
}, [parts]);
|
||||
|
||||
// Keep priceRange clamped to bounds when bounds change
|
||||
@@ -355,15 +343,15 @@ export default function PartsBrowseClient(props: {
|
||||
mode="browse"
|
||||
/> */}
|
||||
|
||||
<Link
|
||||
href={`/builder?platform=${encodeURIComponent(
|
||||
effectivePlatform
|
||||
)}`}
|
||||
className="inline-flex items-center rounded-md bg-amber-400 px-3 py-2 text-xs font-semibold text-black hover:bg-amber-300 transition-colors"
|
||||
>
|
||||
Start New Build →
|
||||
</Link>
|
||||
{/* </div>
|
||||
<Link
|
||||
href={`/builder?platform=${encodeURIComponent(
|
||||
effectivePlatform
|
||||
)}`}
|
||||
className="inline-flex items-center rounded-md bg-amber-400 px-3 py-2 text-xs font-semibold text-black hover:bg-amber-300 transition-colors"
|
||||
>
|
||||
Start New Build →
|
||||
</Link>
|
||||
{/* </div>
|
||||
)} */}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user