"use client"; import React, { useEffect } from 'react'; import ProductDetail from './product-detail/ProductDetail'; import { Button } from './ui/button'; interface ProductImage { url: string; altText?: string; } interface ProductPrice { amount: string; currencyCode: string; } interface ProductVariant { id: string; title: string; price: ProductPrice; availableForSale: boolean; } interface Product { id: string; title: string; description?: string; handle: string; images: { edges: Array<{ node: ProductImage; }>; }; priceRange: { minVariantPrice: ProductPrice; }; compareAtPriceRange?: { minVariantPrice: ProductPrice; }; variants: { edges: Array<{ node: ProductVariant; }>; }; } interface ProductModalProps { product: Product; isOpen: boolean; onClose: () => void; } const ProductModal: React.FC = ({ product, isOpen, onClose }) => { // Close modal on ESC key press useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape') { onClose(); } }; if (isOpen) { document.addEventListener('keydown', handleEscape); document.body.style.overflow = 'hidden'; } return () => { document.removeEventListener('keydown', handleEscape); document.body.style.overflow = 'unset'; }; }, [isOpen, onClose]); const handleBackdropClick = (e: React.MouseEvent) => { if (e.target === e.currentTarget) { onClose(); } }; if (!isOpen) return null; return (
{/* Close Button */} {/* Product Detail Component */}
); }; export default ProductModal;