desktop: count on product id from localstorage since no product id in url

This commit is contained in:
2025-11-26 19:37:41 +03:00
parent 36af620b02
commit 88338514c3
3 changed files with 10 additions and 9 deletions

View File

@@ -39,11 +39,16 @@ export default function ProductDetailPage({
// Find product from menu data
const product: Product = useMemo(() => {
if (!menuData?.products || !productId) return null;
// we still need to support the old way of passing the product id in local storage
// because in desktop we open the product dialog from the menu list
// and the product id is not passed in the url
const productIdLocalStorage = localStorage.getItem("productId");
if (!menuData?.products || (!productId && !productIdLocalStorage))
return null;
// Find the product with matching IDs
return menuData.products.find(
(p: Product) => p.id.toString() === productId,
(p: Product) => p.id.toString() === (productId || productIdLocalStorage),
);
}, [menuData, productId]);
@@ -96,10 +101,6 @@ export default function ProductDetailPage({
});
}
}
// console.log("Variant levels:", levels);
// console.log("Selected variants:", selectedVariants);
return levels;
}, [product?.variants]);