feat(products): add product gallery, image zoom lightbox, clean duplicate analysis/usage sections and style catalog button
Deploy Canina / deploy (push) Successful in 1m47s
Deploy Canina / deploy (push) Successful in 1m47s
This commit is contained in:
1 parent
43f59813b6
commit
4cbde63b89
6 files changed
+343
-200
No files matched your search
@@ -466,11 +466,20 @@ export default function Orders() {
|
||||
const totalAmt = Number(order.totalAmount || order.total || 0);
|
||||
const payInfo = getPaymentMethodLabel(order.paymentMethod);
|
||||
const charityAmt = Number(order.charityDonation || 0);
|
||||
const isNewOrder = order.status === 'processing';
|
||||
|
||||
return (
|
||||
<tr key={order.id} className="hover:bg-gray-50/50 transition-colors font-vazir">
|
||||
<tr key={order.id} className={`transition-colors font-vazir ${isNewOrder ? 'bg-amber-50/40 hover:bg-amber-50/70' : 'hover:bg-gray-50/50'}`}>
|
||||
<td className="py-4 px-6 font-vazir" dir="rtl">
|
||||
<div className="font-black text-purple-700 text-sm tracking-wide font-vazir">{toPersianDigits(displayCode)}</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-black text-purple-700 text-sm tracking-wide font-vazir">{toPersianDigits(displayCode)}</span>
|
||||
{isNewOrder && (
|
||||
<span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-black bg-amber-500 text-white shadow-xs animate-pulse">
|
||||
<span className="w-1.5 h-1.5 rounded-full bg-white animate-ping" />
|
||||
سفارش جدید
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-1.5 mt-2 font-vazir" dir="rtl">
|
||||
<span className={`text-[10px] font-bold font-vazir px-2 py-0.5 rounded-md border flex items-center gap-1 shadow-sm ${payInfo.color}`}>
|
||||
<CreditCard className="w-3 h-3 shrink-0" />
|
||||
|
||||
@@ -1053,16 +1053,27 @@ export default function Products() {
|
||||
|
||||
{/* Media Tab */}
|
||||
<div className={activeTab === 'media' ? 'block space-y-6' : 'hidden'}>
|
||||
{/* Direct Image URL Input Box */}
|
||||
<div className="bg-white p-5 rounded-2xl border border-gray-200 shadow-sm space-y-3">
|
||||
<label className="text-sm font-bold text-gray-700 flex items-center justify-between">
|
||||
<span className="flex items-center gap-2">
|
||||
{/* Main Product Image Section */}
|
||||
<div className="bg-white p-5 rounded-2xl border border-gray-200 shadow-sm space-y-4">
|
||||
<div className="flex items-center justify-between border-b pb-2">
|
||||
<span className="text-sm font-bold text-gray-800 flex items-center gap-2">
|
||||
<ImageIcon className="w-4 h-4 text-purple-600" />
|
||||
لینک مستقیم آدرس تصویر (External / Direct URL)
|
||||
تصویر اصلی و کاور محصول (Main Cover Image)
|
||||
</span>
|
||||
<span className="text-[11px] text-gray-400 font-normal">امکان چسباندن (Ctrl+V) مستقیم آدرس اینترنتی تصویر</span>
|
||||
</label>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setMediaTargetField('imageUrl');
|
||||
setIsMediaSelectorOpen(true);
|
||||
}}
|
||||
className="bg-purple-600 hover:bg-purple-700 text-white px-4 py-1.5 rounded-xl text-xs font-bold transition-all cursor-pointer flex items-center gap-1.5"
|
||||
>
|
||||
<ImageIcon className="w-3.5 h-3.5" />
|
||||
انتخاب تصویر اصلی
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col sm:flex-row gap-4 items-center">
|
||||
<input
|
||||
type="text"
|
||||
value={formData.imageUrl}
|
||||
@@ -1070,57 +1081,80 @@ export default function Products() {
|
||||
setFormData({ ...formData, imageUrl: e.target.value });
|
||||
setMediaImageError(false);
|
||||
}}
|
||||
placeholder="https://example.com/images/product.png یا /uploads/photo.jpg"
|
||||
className="flex-1 px-4 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-sm"
|
||||
placeholder="آدرس اینترنتی یا مسیر عکس اصلی (/uploads/cover.jpg)"
|
||||
className="flex-1 w-full px-4 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-xs"
|
||||
dir="ltr"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsMediaSelectorOpen(true)}
|
||||
className="bg-purple-100 text-purple-700 hover:bg-purple-200 px-4 py-2.5 rounded-xl text-xs font-bold transition-colors whitespace-nowrap"
|
||||
>
|
||||
گالری سرور
|
||||
</button>
|
||||
{formData.imageUrl && (
|
||||
<div className="relative group w-16 h-16 shrink-0 rounded-xl border border-gray-200 overflow-hidden bg-gray-50 flex items-center justify-center">
|
||||
<img
|
||||
src={getProductImageUrl(formData.imageUrl)}
|
||||
alt="Cover"
|
||||
className="w-full h-full object-contain"
|
||||
onError={() => setMediaImageError(true)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Preview Container */}
|
||||
<div className="flex flex-col items-center justify-center p-8 border-2 border-dashed border-gray-200 rounded-2xl bg-white">
|
||||
{formData.imageUrl && !mediaImageError ? (
|
||||
<div className="w-full flex flex-col items-center">
|
||||
<div className="relative group">
|
||||
<img
|
||||
src={getProductImageUrl(formData.imageUrl)}
|
||||
alt="پیشنمایش تصویر محصول"
|
||||
onError={() => setMediaImageError(true)}
|
||||
className="max-w-xs h-48 object-contain rounded-xl shadow-md border border-gray-100"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-xl flex items-center justify-center gap-3">
|
||||
<button type="button" onClick={() => setIsMediaSelectorOpen(true)} className="bg-white text-gray-800 px-4 py-2 rounded-lg font-bold text-sm">انتخاب از گالری</button>
|
||||
<button type="button" onClick={() => setFormData({ ...formData, imageUrl: '' })} className="bg-red-500 text-white px-4 py-2 rounded-lg font-bold text-sm hover:bg-red-600">حذف عکس</button>
|
||||
{/* Product Gallery Images (Multiple Angles & Views) */}
|
||||
<div className="bg-white p-5 rounded-2xl border border-gray-200 shadow-sm space-y-4">
|
||||
<div className="flex items-center justify-between border-b pb-2">
|
||||
<div>
|
||||
<h4 className="font-bold text-gray-800 text-sm flex items-center gap-2">
|
||||
<ImageIcon className="w-4 h-4 text-blue-600" />
|
||||
گالری تصاویر جانبی محصول (Gallery Images)
|
||||
</h4>
|
||||
<p className="text-[11px] text-gray-400 font-medium mt-0.5">تصاویر زوایای مختلف، پشت بستهبندی، جدول ارزش غذایی و مشخصات فنی</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setMediaTargetField('gallery' as any);
|
||||
setIsMediaSelectorOpen(true);
|
||||
}}
|
||||
className="bg-blue-600 hover:bg-blue-700 text-white px-4 py-1.5 rounded-xl text-xs font-bold transition-all cursor-pointer flex items-center gap-1.5"
|
||||
>
|
||||
<Plus className="w-3.5 h-3.5" />
|
||||
افزودن عکس به گالری
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{formData.images && formData.images.length > 0 ? (
|
||||
<div className="grid grid-cols-2 sm:grid-cols-4 md:grid-cols-6 gap-3">
|
||||
{formData.images.map((imgUrl, idx) => (
|
||||
<div key={idx} className="relative group rounded-xl border border-gray-200 overflow-hidden bg-gray-50 aspect-square flex items-center justify-center p-2 shadow-xs">
|
||||
<img
|
||||
src={getProductImageUrl(imgUrl)}
|
||||
alt={`Gallery ${idx + 1}`}
|
||||
className="max-h-full max-w-full object-contain"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-1.5 p-1">
|
||||
<button
|
||||
type="button"
|
||||
title="حذف از گالری"
|
||||
onClick={() => {
|
||||
const updated = formData.images.filter((_, i) => i !== idx);
|
||||
setFormData({ ...formData, images: updated });
|
||||
}}
|
||||
className="w-7 h-7 rounded-lg bg-red-600 hover:bg-red-700 text-white flex items-center justify-center transition-colors"
|
||||
>
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<span className="absolute bottom-1 right-1 bg-black/60 text-white text-[9px] px-1.5 py-0.5 rounded font-mono">
|
||||
#{idx + 1}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 text-center" dir="ltr">
|
||||
<p className="text-xs text-gray-500 font-mono bg-gray-100 px-4 py-2 rounded-lg inline-block max-w-md truncate">
|
||||
{formData.imageUrl}
|
||||
</p>
|
||||
</div>
|
||||
<p className="text-[11px] text-gray-400 mt-2">تصویر با موفقیت بارگذاری و تایید شد.</p>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center text-gray-400 mb-4">
|
||||
<ImageIcon className="w-8 h-8 text-purple-400" />
|
||||
</div>
|
||||
<p className="text-gray-600 font-bold mb-2">آدرس یا فایلی برای تصویر انتخاب نشده است</p>
|
||||
<p className="text-xs text-gray-400 mb-4 text-center leading-relaxed">
|
||||
میتوانید لینک اینترنتی تصویر را در کادر بالا وارد کنید، عکس جدید آپلود نمایید<br />
|
||||
یا از کلیدهای <kbd className="px-1.5 py-0.5 bg-gray-100 rounded text-gray-700 font-mono">Ctrl+V</kbd> برای چسباندن مستقیم فایل یا لینک استفاده کنید.
|
||||
</p>
|
||||
<button type="button" onClick={() => setIsMediaSelectorOpen(true)} className="bg-purple-600 text-white hover:bg-purple-700 px-6 py-2.5 rounded-xl font-bold transition-colors shadow-sm text-sm">
|
||||
انتخاب یا آپلود در گالری
|
||||
</button>
|
||||
</>
|
||||
<div className="text-center py-6 text-gray-400 bg-gray-50/50 rounded-xl border border-dashed border-gray-200">
|
||||
<ImageIcon className="w-8 h-8 mx-auto mb-2 opacity-30 text-gray-400" />
|
||||
<p className="text-xs font-bold text-gray-500">هنوز عکس جانبی به گالری محصول اضافه نشده است.</p>
|
||||
<p className="text-[10px] text-gray-400 mt-1">با زدن دکمه «افزودن عکس به گالری» میتوانید چند عکس اضافه نمایید.</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1222,10 +1256,24 @@ export default function Products() {
|
||||
isOpen={isMediaSelectorOpen}
|
||||
onClose={() => setIsMediaSelectorOpen(false)}
|
||||
onSelect={(url) => {
|
||||
setFormData({ ...formData, [mediaTargetField]: url });
|
||||
if (mediaTargetField === 'imageUrl') setMediaImageError(false);
|
||||
if ((mediaTargetField as string) === 'gallery') {
|
||||
if (!formData.images.includes(url)) {
|
||||
setFormData({ ...formData, images: [...formData.images, url] });
|
||||
}
|
||||
} else {
|
||||
setFormData({ ...formData, [mediaTargetField]: url });
|
||||
if (mediaTargetField === 'imageUrl') setMediaImageError(false);
|
||||
}
|
||||
}}
|
||||
selectedUrl={formData[mediaTargetField]?.startsWith('http') ? formData[mediaTargetField] : formData[mediaTargetField] ? `${BASE_DOMAIN}${formData[mediaTargetField]}` : undefined}
|
||||
selectedUrl={
|
||||
(mediaTargetField as string) === 'gallery'
|
||||
? undefined
|
||||
: formData[mediaTargetField]?.startsWith('http')
|
||||
? formData[mediaTargetField]
|
||||
: formData[mediaTargetField]
|
||||
? `${BASE_DOMAIN}${formData[mediaTargetField]}`
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
|
||||
<ConfirmModal
|
||||
|
||||
Reference in new issue
Block a user