From 22bc048475493e93073d8c99f09e1e996cf57bf4 Mon Sep 17 00:00:00 2001 From: makearmy Date: Wed, 15 Oct 2025 18:19:23 -0400 Subject: [PATCH] background remover fix --- components/buying-guide/BuyingGuideList.tsx | 66 ++--- .../buying-guide/BuyingGuideProductClient.tsx | 246 ++++++++++++++++++ components/portal/BuyingGuideSwitcher.tsx | 45 ++-- 3 files changed, 302 insertions(+), 55 deletions(-) create mode 100644 components/buying-guide/BuyingGuideProductClient.tsx diff --git a/components/buying-guide/BuyingGuideList.tsx b/components/buying-guide/BuyingGuideList.tsx index 48ab3782..480b3701 100644 --- a/components/buying-guide/BuyingGuideList.tsx +++ b/components/buying-guide/BuyingGuideList.tsx @@ -6,7 +6,7 @@ import Link from "next/link"; import Image from "next/image"; interface Entry { - id: number; + id: number | string; product_make: string; product_model: string; product_price?: string; @@ -58,8 +58,10 @@ export default function BuyingGuidePage() { const fetchData = async () => { try { const [entriesRes, catRes, subCatRes] = await Promise.all([ - fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/items/bg_entries?fields=id,index.id,index.filename_disk,index.type,header.id,header.filename_disk,product_make,product_model,product_price,review_overview_text,bg_entry_cat,bg_entry_sub_cat&limit=-1&sort[]=sort`), - fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/items/bg_cat?fields=id,name&limit=-1`), + fetch( + `${process.env.NEXT_PUBLIC_API_BASE_URL}/items/bg_entries?fields=id,index.id,index.filename_disk,index.type,header.id,header.filename_disk,product_make,product_model,product_price,review_overview_text,bg_entry_cat,bg_entry_sub_cat&limit=-1&sort[]=sort` + ), + fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/items/bg_cat?fields=id,name&limit=-1`), fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/items/bg_sub_cat?fields=id,name,bg_entry_cat&limit=-1`), ]); @@ -99,9 +101,7 @@ export default function BuyingGuidePage() { }, [entries, debouncedQuery, selectedCat, selectedSubCat]); const filteredSubcategories = useMemo(() => { - return selectedCat - ? subcategories.filter((sub) => sub.bg_entry_cat === parseInt(selectedCat)) - : subcategories; + return selectedCat ? subcategories.filter((sub) => sub.bg_entry_cat === parseInt(selectedCat)) : subcategories; }, [subcategories, selectedCat]); const featuredEntry = useMemo(() => { @@ -119,6 +119,13 @@ export default function BuyingGuidePage() { return entries[secondIndex]; }, [entries, featuredEntry]); + // Build a URL that sets ?product= while preserving any existing params. + const makeProductHref = (id: number | string) => { + const sp = new URLSearchParams(Array.from(searchParams.entries())); + sp.set("product", String(id)); + return `?${sp.toString()}`; + }; + return (