From 88338514c3ad4bccfcf5d42c22f991bc95c590d2 Mon Sep 17 00:00:00 2001 From: Mohammed Al-yaseen Date: Wed, 26 Nov 2025 19:37:41 +0300 Subject: [PATCH] desktop: count on product id from localstorage since no product id in url --- src/pages/menu/components/MenuList/ProductCard.tsx | 2 +- .../components/MenuSkeleton/MenuSkeleton.module.css | 4 ++-- src/pages/product/page.tsx | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/pages/menu/components/MenuList/ProductCard.tsx b/src/pages/menu/components/MenuList/ProductCard.tsx index d5dfdaf..69d2c61 100644 --- a/src/pages/menu/components/MenuList/ProductCard.tsx +++ b/src/pages/menu/components/MenuList/ProductCard.tsx @@ -33,7 +33,7 @@ export default function ProductCard({ item }: Props) { // Handle product click - open dialog on desktop, navigate on mobile/tablet const handleProductClick = (item: Product) => { - localStorage.setItem("product", JSON.stringify(item)); + localStorage.setItem("productId", item.id.toString()); if (isDesktop) { setIsDialogOpen(true); } else { diff --git a/src/pages/menu/components/MenuSkeleton/MenuSkeleton.module.css b/src/pages/menu/components/MenuSkeleton/MenuSkeleton.module.css index 22719b3..61fe33c 100644 --- a/src/pages/menu/components/MenuSkeleton/MenuSkeleton.module.css +++ b/src/pages/menu/components/MenuSkeleton/MenuSkeleton.module.css @@ -223,7 +223,7 @@ /* Tablet Styles (769px - 1024px) */ @media (min-width: 769px) and (max-width: 1024px) { .logo { - left: 40px; + left: 24px !important; width: 80px !important; height: 80px !important; top: 142px !important; @@ -311,7 +311,7 @@ /* Desktop Styles (min-width: 1025px) */ @media (min-width: 1025px) { .logo { - left: 33px; + left: 38px !important; top: 114px !important; width: 150px !important; height: 150px !important; diff --git a/src/pages/product/page.tsx b/src/pages/product/page.tsx index ec5dcab..7f6320c 100644 --- a/src/pages/product/page.tsx +++ b/src/pages/product/page.tsx @@ -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]);