|
| 1 | +import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"; |
| 2 | +import { Button } from "@/components/ui/button"; |
| 3 | +import { ShoppingBag } from "lucide-react"; |
| 4 | +import { formatJOD, getProductImage } from "@/lib/productImageUtils"; |
| 5 | + |
| 6 | +interface Product { |
| 7 | + id: string; |
| 8 | + title: string; |
| 9 | + price: number; |
| 10 | + description: string | null; |
| 11 | + image_url: string | null; |
| 12 | + brand: string | null; |
| 13 | + category?: string; |
| 14 | +} |
| 15 | + |
| 16 | +interface ProductQuickViewProps { |
| 17 | + product: Product | null; |
| 18 | + open: boolean; |
| 19 | + onOpenChange: (open: boolean) => void; |
| 20 | + onAddToCart?: (product: Product) => void; |
| 21 | +} |
| 22 | + |
| 23 | +export const ProductQuickView = ({ product, open, onOpenChange, onAddToCart }: ProductQuickViewProps) => { |
| 24 | + if (!product) return null; |
| 25 | + return ( |
| 26 | + <Dialog open={open} onOpenChange={onOpenChange}> |
| 27 | + <DialogContent className="max-w-lg"> |
| 28 | + <DialogHeader> |
| 29 | + <DialogTitle className="font-serif">{product.title}</DialogTitle> |
| 30 | + </DialogHeader> |
| 31 | + <div className="space-y-4"> |
| 32 | + <img src={getProductImage(product.image_url)} alt={product.title} className="w-full aspect-square object-cover rounded-lg" /> |
| 33 | + {product.brand && <p className="text-xs text-muted-foreground uppercase tracking-widest">{product.brand}</p>} |
| 34 | + <p className="text-sm text-muted-foreground">{product.description}</p> |
| 35 | + <div className="flex items-center justify-between"> |
| 36 | + <span className="text-lg font-bold">{formatJOD(product.price)}</span> |
| 37 | + {onAddToCart && ( |
| 38 | + <Button onClick={() => onAddToCart(product)} size="sm" className="gap-2"> |
| 39 | + <ShoppingBag className="w-4 h-4" /> Add to Cart |
| 40 | + </Button> |
| 41 | + )} |
| 42 | + </div> |
| 43 | + </div> |
| 44 | + </DialogContent> |
| 45 | + </Dialog> |
| 46 | + ); |
| 47 | +}; |
0 commit comments