diff --git a/src/components/CartDrawer.tsx b/src/components/CartDrawer.tsx index 4cd30b2..476a2de 100644 --- a/src/components/CartDrawer.tsx +++ b/src/components/CartDrawer.tsx @@ -132,7 +132,7 @@ export function CartDrawer() {
{item.product.name} diff --git a/src/components/ProductCard.tsx b/src/components/ProductCard.tsx index f5b30f7..525f960 100644 --- a/src/components/ProductCard.tsx +++ b/src/components/ProductCard.tsx @@ -1,15 +1,36 @@ -import { ShoppingCart, Plus } from 'lucide-react'; +import { ShoppingCart, Plus, Check } from 'lucide-react'; +import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; import { Product } from '@/types'; import { useCart } from '@/context/CartContext'; +import { useToast } from '@/hooks/use-toast'; interface ProductCardProps { product: Product; } export function ProductCard({ product }: ProductCardProps) { - const { addItem } = useCart(); + const { addItem, setIsCartOpen } = useCart(); + const { toast } = useToast(); + const [justAdded, setJustAdded] = useState(false); + + const handleAdd = (e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + addItem(product); + setJustAdded(true); + setTimeout(() => setJustAdded(false), 1200); + toast({ + title: '✓ Added to cart', + description: product.name, + action: ( + + ), + }); + }; return (