From fc60a9f37b599c616bf3e34d8fca0f5445e52677 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 12 May 2026 09:47:48 +0000 Subject: [PATCH] fix: prevent inactive products from triggering backend requests - Update ProductDetailPage.tsx to only set isValidated(true) for active products. - Add regex validation to ensure productId is numeric. - Initialize meta.active to false. - Add loading state for catalog fetch. - Fix minor lint issue in ProductsPage.tsx. Co-authored-by: starkSV <21262426+starkSV@users.noreply.github.com> --- frontend/src/pages/ProductDetailPage.tsx | 35 ++++++++++++++++++++---- frontend/src/pages/ProductsPage.tsx | 2 +- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/ProductDetailPage.tsx b/frontend/src/pages/ProductDetailPage.tsx index 739f206..6361bc0 100644 --- a/frontend/src/pages/ProductDetailPage.tsx +++ b/frontend/src/pages/ProductDetailPage.tsx @@ -57,7 +57,7 @@ export default function ProductDetailPage() { const [isValidated, setIsValidated] = useState(false) const [hasCatalogError, setHasCatalogError] = useState(false) - const [meta, setMeta] = useState<{ badge: string; archs: string[]; active: boolean }>({ badge: '', archs: [], active: true }) + const [meta, setMeta] = useState<{ badge: string; archs: string[]; active: boolean }>({ badge: '', archs: [], active: false }) const [related, setRelated] = useState<{ id: string; label: string }[]>([]) // Load product name + build string @@ -67,9 +67,15 @@ export default function ProductDetailPage() { setIsValidated(false) setHasCatalogError(false) setProductName('') - setMeta({ badge: '', archs: [], active: true }) + setMeta({ badge: '', archs: [], active: false }) setRelated([]) + if (productId && !/^\d+$/.test(productId)) { + setIsNotFound(true) + setProductName('Invalid Product ID') + return + } + fetch('/data/products.json') .then(r => { if (!r.ok) throw new Error('Failed to fetch catalog') @@ -89,14 +95,17 @@ export default function ProductDetailPage() { const name = product.name setProductName(name) - setMeta({ badge: product.badge || '', archs: product.archs || [], active: product.active !== false }) + const isActive = product.active !== false + setMeta({ badge: product.badge || '', archs: product.archs || [], active: isActive }) setRelated((product.related || []).map(rId => ({ id: rId, label: data[rId]?.name || `Product ${rId}` }))) - setIsValidated(true) + if (isActive) { + setIsValidated(true) + } // Dynamic SEO injection document.title = `${name} ISO Download | Windows ISO Downloader` @@ -217,7 +226,23 @@ export default function ProductDetailPage() { {/* Main card */}