File size: 6,873 Bytes
6b154f5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | import React from 'react';
import { X, Package, Phone, Mail, CheckCircle, XCircle, Tag } from 'lucide-react';
import { CatalogProduct, Language } from '../types';
interface ProductModalProps {
product: CatalogProduct | null;
isOpen: boolean;
onClose: () => void;
language: Language;
onWhatsAppContact: (product: CatalogProduct) => void;
onEmailContact: (product: CatalogProduct) => void;
}
export const ProductModal: React.FC<ProductModalProps> = ({
product,
isOpen,
onClose,
language,
onWhatsAppContact,
onEmailContact
}) => {
const isArabic = language.code === 'ar';
const labels = {
ar: {
productDetails: 'تفاصيل المنتج',
description: 'الوصف',
specifications: 'المواصفات',
category: 'الفئة',
availability: 'التوفر',
inStock: 'متوفر',
outOfStock: 'غير متوفر',
secoCode: 'كود SECO',
contactForPurchase: 'اتصل للشراء',
whatsapp: 'واتساب',
email: 'إيميل',
close: 'إغلاق'
},
en: {
productDetails: 'Product Details',
description: 'Description',
specifications: 'Specifications',
category: 'Category',
availability: 'Availability',
inStock: 'In Stock',
outOfStock: 'Out of Stock',
secoCode: 'SECO Code',
contactForPurchase: 'Contact for Purchase',
whatsapp: 'WhatsApp',
email: 'Email',
close: 'Close'
}
};
const t = labels[language.code];
if (!isOpen || !product) return null;
return (
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
<div className="bg-white rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] overflow-y-auto">
{/* Header */}
<div className="flex items-center justify-between p-6 border-b">
<h2 className="text-2xl font-bold text-gray-900 flex items-center gap-3">
<Package className="w-6 h-6 text-blue-600" />
{t.productDetails}
</h2>
<button
onClick={onClose}
className="p-2 hover:bg-gray-100 rounded-lg transition-colors"
>
<X className="w-6 h-6" />
</button>
</div>
{/* Content */}
<div className="p-6 space-y-6">
{/* Product Image */}
<div className="aspect-video bg-gray-100 rounded-lg flex items-center justify-center">
<Package className="w-24 h-24 text-gray-400" />
</div>
{/* Product Info */}
<div>
<div className="flex items-start justify-between mb-4">
<div className="flex-1">
<h3 className="text-xl font-bold text-gray-900 mb-2">
{product.name}
</h3>
<div className="flex items-center gap-4 mb-2">
<span className="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800">
<Tag className="w-4 h-4 mr-1" />
{product.category}
</span>
{product.inStock ? (
<span className="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800">
<CheckCircle className="w-4 h-4 mr-1" />
{t.inStock}
</span>
) : (
<span className="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-red-100 text-red-800">
<XCircle className="w-4 h-4 mr-1" />
{t.outOfStock}
</span>
)}
</div>
{product.secoCode && (
<p className="text-sm text-gray-600">
<span className="font-medium">{t.secoCode}:</span> {product.secoCode}
</p>
)}
</div>
</div>
{/* Description */}
<div className="mb-6">
<h4 className="text-lg font-semibold text-gray-900 mb-2">{t.description}</h4>
<p className="text-gray-700 leading-relaxed">{product.description}</p>
</div>
{/* Specifications */}
{product.specifications && product.specifications.length > 0 && (
<div className="mb-6">
<h4 className="text-lg font-semibold text-gray-900 mb-3">{t.specifications}</h4>
<div className="bg-gray-50 rounded-lg p-4">
<ul className="space-y-2">
{product.specifications.map((spec, index) => (
<li key={index} className="flex items-center gap-2 text-gray-700">
<div className="w-2 h-2 bg-blue-500 rounded-full flex-shrink-0"></div>
{spec}
</li>
))}
</ul>
</div>
</div>
)}
</div>
</div>
{/* Footer */}
<div className="border-t p-6">
<div className="mb-4">
<h4 className="text-lg font-semibold text-gray-900 mb-3">{t.contactForPurchase}</h4>
<div className="bg-blue-50 rounded-lg p-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-3 text-sm text-gray-700">
<div className="flex items-center gap-2">
<Phone className="w-4 h-4 text-blue-600" />
<span>+1872752725</span>
</div>
<div className="flex items-center gap-2">
<Mail className="w-4 h-4 text-blue-600" />
<span>saif@gmail.com</span>
</div>
</div>
</div>
</div>
<div className="flex gap-3">
<button
onClick={() => onWhatsAppContact(product)}
className="flex-1 bg-green-500 hover:bg-green-600 text-white px-6 py-3 rounded-lg font-medium transition-colors flex items-center justify-center gap-2"
>
<Phone className="w-5 h-5" />
{t.whatsapp}
</button>
<button
onClick={() => onEmailContact(product)}
className="flex-1 bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg font-medium transition-colors flex items-center justify-center gap-2"
>
<Mail className="w-5 h-5" />
{t.email}
</button>
<button
onClick={onClose}
className="px-6 py-3 text-gray-600 hover:bg-gray-100 rounded-lg transition-colors font-medium"
>
{t.close}
</button>
</div>
</div>
</div>
</div>
);
}; |