desktop: count on product id from localstorage since no product id in url
This commit is contained in:
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user