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

@@ -33,7 +33,7 @@ export default function ProductCard({ item }: Props) {
// Handle product click - open dialog on desktop, navigate on mobile/tablet // Handle product click - open dialog on desktop, navigate on mobile/tablet
const handleProductClick = (item: Product) => { const handleProductClick = (item: Product) => {
localStorage.setItem("product", JSON.stringify(item)); localStorage.setItem("productId", item.id.toString());
if (isDesktop) { if (isDesktop) {
setIsDialogOpen(true); setIsDialogOpen(true);
} else { } else {

View File

@@ -223,7 +223,7 @@
/* Tablet Styles (769px - 1024px) */ /* Tablet Styles (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) { @media (min-width: 769px) and (max-width: 1024px) {
.logo { .logo {
left: 40px; left: 24px !important;
width: 80px !important; width: 80px !important;
height: 80px !important; height: 80px !important;
top: 142px !important; top: 142px !important;
@@ -311,7 +311,7 @@
/* Desktop Styles (min-width: 1025px) */ /* Desktop Styles (min-width: 1025px) */
@media (min-width: 1025px) { @media (min-width: 1025px) {
.logo { .logo {
left: 33px; left: 38px !important;
top: 114px !important; top: 114px !important;
width: 150px !important; width: 150px !important;
height: 150px !important; height: 150px !important;

View File

@@ -39,11 +39,16 @@ export default function ProductDetailPage({
// Find product from menu data // Find product from menu data
const product: Product = useMemo(() => { 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 // Find the product with matching IDs
return menuData.products.find( return menuData.products.find(
(p: Product) => p.id.toString() === productId, (p: Product) => p.id.toString() === (productId || productIdLocalStorage),
); );
}, [menuData, productId]); }, [menuData, productId]);
@@ -96,10 +101,6 @@ export default function ProductDetailPage({
}); });
} }
} }
// console.log("Variant levels:", levels);
// console.log("Selected variants:", selectedVariants);
return levels; return levels;
}, [product?.variants]); }, [product?.variants]);