diff --git a/src/pages/cart/components/CartMobileTabletLayout.tsx b/src/pages/cart/components/CartMobileTabletLayout.tsx index 32237ed..a0f75a8 100644 --- a/src/pages/cart/components/CartMobileTabletLayout.tsx +++ b/src/pages/cart/components/CartMobileTabletLayout.tsx @@ -69,7 +69,7 @@ export default function CartMobileTabletLayout({ className={`${styles.cartContainer} '${styles.cartLayout}' ${getResponsiveClass()}`} > @@ -134,7 +134,7 @@ export default function CartMobileTabletLayout({ height: "100%", }} > - +
state.order); + const { items } = useAppSelector((state) => state.order); // Check if product is in cart - // const cartItemsForProduct = items.filter((i) => i.id === item.id); - // const totalQuantity = cartItemsForProduct.reduce( - // (total, item) => total + item.quantity, - // 0, - // ); - // const isInCart = totalQuantity > 0; + const cartItemsForProduct = items.filter((i) => i.id === item.id); + const totalQuantity = cartItemsForProduct.reduce( + (total, item) => total + item.quantity, + 0, + ); + const isInCart = totalQuantity > 0; // Check if item has extras, variants, or groups const hasOptions = @@ -36,12 +37,12 @@ export function AddToCartButton({ item }: { item: Product }) { (item.theExtrasGroups && item.theExtrasGroups.length > 0); // Find basic cart item (no variants/extras) - the one added by quick add - // const basicCartItem = cartItemsForProduct.find( - // (cartItem) => - // (!cartItem.variant || cartItem.variant === "None") && - // (!cartItem.extras || cartItem.extras.length === 0) && - // (!cartItem.extrasgroupnew || cartItem.extrasgroupnew.length === 0), - // ); + const basicCartItem = cartItemsForProduct.find( + (cartItem) => + (!cartItem.variant || cartItem.variant === "None") && + (!cartItem.extras || cartItem.extras.length === 0) && + (!cartItem.extrasgroupnew || cartItem.extrasgroupnew.length === 0), + ); const handleClick = () => { if (restaurant && !restaurant.isOpened) { @@ -75,157 +76,101 @@ export function AddToCartButton({ item }: { item: Product }) { } }; - // const handleMinusClick = () => { - // if (restaurant && !restaurant.isOpened) { - // message.warning(t("menu.restaurantIsClosed")); - // return; - // } + const handleMinusClick = () => { + if (restaurant && !restaurant.isOpened) { + message.warning(t("menu.restaurantIsClosed")); + return; + } - // if (basicCartItem && basicCartItem.uniqueId) { - // if (basicCartItem.quantity > 1) { - // // Decrease quantity - // dispatch( - // updateQuantity({ - // id: basicCartItem.id, - // uniqueId: basicCartItem.uniqueId, - // quantity: basicCartItem.quantity - 1, - // }), - // ); - // } else { - // // Remove item if quantity is 1 - // dispatch(removeItem(basicCartItem.uniqueId)); - // } - // } else if (cartItemsForProduct.length > 0) { - // // If no basic item found but items exist, remove the first one - // const firstItem = cartItemsForProduct[0]; - // if (firstItem.uniqueId) { - // if (firstItem.quantity > 1) { - // dispatch( - // updateQuantity({ - // id: firstItem.id, - // uniqueId: firstItem.uniqueId, - // quantity: firstItem.quantity - 1, - // }), - // ); - // } else { - // dispatch(removeItem(firstItem.uniqueId)); - // } - // } - // } - // }; - - // const handlePlusClick = () => { - // if (restaurant && !restaurant.isOpened) { - // message.warning(t("menu.restaurantIsClosed")); - // return; - // } - - // if (basicCartItem && basicCartItem.uniqueId) { - // // Increase quantity of existing basic item - // dispatch( - // updateQuantity({ - // id: basicCartItem.id, - // uniqueId: basicCartItem.uniqueId, - // quantity: basicCartItem.quantity + 1, - // }), - // ); - // } else if (!hasOptions) { - // // Add new basic item if no options - // dispatch( - // addItem({ - // item: { - // id: Number(item.id), - // name: item.name, - // price: item.price, - // image: item.image, - // description: item.description, - // variant: "None", - // isHasLoyalty: item.isHasLoyalty, - // no_of_stamps_give: item.no_of_stamps_give, - // }, - // quantity: 1, - // }), - // ); - // } else { - // // If has options, navigate to product page - // navigate(`/${subdomain}/product/${item.id}`); - // } - // }; - - return ( -
-
+
- */ + ) : ( +
+
+ ); } diff --git a/src/pages/menu/components/MenuList/ProductCard.tsx b/src/pages/menu/components/MenuList/ProductCard.tsx index 8bc7ea6..3d3b565 100644 --- a/src/pages/menu/components/MenuList/ProductCard.tsx +++ b/src/pages/menu/components/MenuList/ProductCard.tsx @@ -48,7 +48,7 @@ export default function ProductCard({ item }: Props) { key={item.id} style={{ borderRadius: 8, - height: 148, + height: item.description ? 148 : 120, overflow: "hide", width: "100%", boxShadow: "none", @@ -188,13 +188,13 @@ export default function ProductCard({ item }: Props) { ? styles.popularMenuItemImageTablet : styles.popularMenuItemImageDesktop }`} - width={90} - height={90} + width={92} + height={92} /> + -