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
|
||||
|
||||
@@ -110,13 +110,13 @@ export default function Footer({
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link
|
||||
href="/catalog"
|
||||
className="inline-flex items-center gap-3 px-6 py-3 bg-canina-blue/10 border border-canina-blue/20 rounded-2xl text-canina-blue text-xs font-black hover:bg-canina-blue hover:text-white transition-all shadow-sm group"
|
||||
>
|
||||
<Download className="w-4 h-4 group-hover:-translate-y-0.5 transition-transform" />
|
||||
<span>مشاهده و دانلود کاتالوگ آنلاین محصولات</span>
|
||||
</Link>
|
||||
<Link
|
||||
href="/catalog"
|
||||
className="inline-flex items-center justify-center gap-2.5 px-5 py-3 bg-canina-blue hover:bg-blue-600 text-white rounded-2xl text-xs font-black transition-all shadow-lg shadow-canina-blue/30 hover:scale-[1.02] border border-blue-400/30 group cursor-pointer"
|
||||
>
|
||||
<Download className="w-4 h-4 text-amber-300 group-hover:-translate-y-0.5 transition-transform" />
|
||||
<span>مشاهده و دانلود کاتالوگ آنلاین محصولات</span>
|
||||
</Link>
|
||||
</li>
|
||||
{isB2BEnabled && (
|
||||
<li onClick={onB2BOpen} className="hover:text-canina-blue hover:translate-x-[-4px] transition-all cursor-pointer flex items-center gap-2 group text-blue-200">
|
||||
|
||||
@@ -80,6 +80,9 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
const [isMounted, setIsMounted] = useState(false);
|
||||
const [dosageConfig, setDosageConfig] = useState<DosageConfig | null>(null);
|
||||
|
||||
const [activeImage, setActiveImage] = useState<string | null>(null);
|
||||
const [isImageZoomOpen, setIsImageZoomOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
Promise.resolve().then(() => setIsMounted(true));
|
||||
}, []);
|
||||
@@ -88,6 +91,7 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
productService.getProductBySlug(productSlug)
|
||||
.then(p => {
|
||||
setProduct(p);
|
||||
if (p?.image) setActiveImage(p.image);
|
||||
return productService.getProducts({ limit: 50 });
|
||||
})
|
||||
.then(res => {
|
||||
@@ -256,12 +260,14 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
|
||||
{/* Above the Fold Grid */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-12 gap-8 md:gap-12 items-center md:items-start text-center md:text-right font-vazir w-full" dir="rtl">
|
||||
{/* Right Column: Product Image Frame (md:col-span-5) */}
|
||||
<div className="md:col-span-5 w-full mx-auto max-w-sm md:max-w-none">
|
||||
{/* Right Column: Product Image Frame & Gallery (md:col-span-5) */}
|
||||
<div className="md:col-span-5 w-full mx-auto max-w-sm md:max-w-none space-y-4">
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scale: 0.95 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
className="bg-white rounded-[2.5rem] border border-medical-gray-200 shadow-xl relative group overflow-hidden h-[300px] sm:h-[380px] flex items-center justify-center p-6 sm:p-8"
|
||||
onClick={() => setIsImageZoomOpen(true)}
|
||||
className="bg-white rounded-[2.5rem] border border-medical-gray-200 shadow-xl relative group overflow-hidden h-[300px] sm:h-[380px] flex items-center justify-center p-6 sm:p-8 cursor-zoom-in"
|
||||
title="کلیک برای مشاهده تصویر بزرگتر"
|
||||
>
|
||||
<div className="absolute top-4 left-4 sm:top-6 sm:left-6 flex flex-col gap-1.5 sm:gap-2 z-10 items-start">
|
||||
<div className="px-2.5 py-1 bg-green-500 text-white rounded-full text-[9px] sm:text-[10px] font-black uppercase tracking-widest flex items-center gap-1 font-vazir shadow-sm">
|
||||
@@ -273,12 +279,51 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
</div>
|
||||
</div>
|
||||
<SafeImage
|
||||
src={product.image}
|
||||
src={activeImage || product.image}
|
||||
alt={product.name}
|
||||
className="w-full h-full"
|
||||
imgClassName="max-h-[240px] sm:max-h-[300px] w-auto object-contain drop-shadow-2xl group-hover:scale-105 transition-transform duration-700 mx-auto my-auto"
|
||||
/>
|
||||
<div className="absolute bottom-4 right-4 bg-black/60 backdrop-blur-md text-white px-3 py-1 rounded-full text-[10px] font-black flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<span>بزرگنمایی</span>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
{/* Multiple Gallery Thumbnails Strip */}
|
||||
{(() => {
|
||||
const allGalleryImages = [
|
||||
product.image,
|
||||
...(product.images || []).filter(img => img && img !== product.image)
|
||||
].filter(Boolean);
|
||||
|
||||
if (allGalleryImages.length <= 1) return null;
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2 overflow-x-auto py-2 px-1 sleek-hscroll">
|
||||
{allGalleryImages.map((imgUrl, idx) => {
|
||||
const isSelected = (activeImage || product.image) === imgUrl;
|
||||
return (
|
||||
<button
|
||||
key={idx}
|
||||
type="button"
|
||||
onClick={() => setActiveImage(imgUrl)}
|
||||
className={`relative w-16 h-16 rounded-2xl overflow-hidden bg-white border-2 transition-all shrink-0 p-1 cursor-pointer ${
|
||||
isSelected
|
||||
? 'border-canina-blue shadow-md scale-105 ring-2 ring-canina-blue/20'
|
||||
: 'border-medical-gray-200 hover:border-canina-blue/50 opacity-70 hover:opacity-100'
|
||||
}`}
|
||||
>
|
||||
<img
|
||||
src={imgUrl}
|
||||
alt={`${product.name} - ${idx + 1}`}
|
||||
className="w-full h-full object-contain"
|
||||
/>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
|
||||
{/* Left Column: Product Title & Description (md:col-span-7) */}
|
||||
@@ -394,39 +439,15 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Smart Dosage Calculator Utility Section / Topical Usage Notice */}
|
||||
{fullProduct.categorySlug === 'special-care' ||
|
||||
fullProduct.name.toLowerCase().includes('pfotenpflege') ||
|
||||
fullProduct.name.toLowerCase().includes('augenpflege') ||
|
||||
fullProduct.unit?.includes('ml Lotion') ||
|
||||
fullProduct.unit?.includes('Balsam') ||
|
||||
fullProduct.nameFa?.includes('کرم') ||
|
||||
fullProduct.nameFa?.includes('قطره تمیزکننده') ||
|
||||
fullProduct.nameFa?.includes('اسپری') ? (
|
||||
<section className="bg-white rounded-[2.5rem] border border-medical-gray-200 p-8 md:p-10 shadow-md space-y-6">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="w-12 h-12 bg-canina-blue text-white rounded-2xl flex items-center justify-center shadow-lg">
|
||||
<Sparkles className="w-6 h-6" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-2xl font-black text-medical-gray-900 italic font-vazir">نحوه استفاده موضعی و کاربرد</h3>
|
||||
<p className="text-xs text-medical-gray-400 font-bold font-vazir mt-1">محصولات بهداشتی و بهداشت موضعی نیاز به دوزبندی بر اساس وزن ندارند</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-medical-gray-50 rounded-[2rem] p-6 border border-medical-gray-100 flex items-start gap-4">
|
||||
<div className="w-10 h-10 rounded-xl bg-canina-blue/10 text-canina-blue flex items-center justify-center font-black flex-shrink-0">
|
||||
ℹ️
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="text-sm font-black text-medical-gray-900 mb-1 font-vazir">راهنمای مصرف موضعی</h4>
|
||||
<p className="text-xs text-medical-gray-600 font-bold font-vazir leading-relaxed">
|
||||
این محصول یک فرآورده موضعی/بهداشتی است و مقدار مصرف آن به صورت موضعی (روی پوست، چشم یا پنجه) اعمال میشود و وابسته به وزن بدن حیوان نمیباشد. ماندگاری بسته بسته به میزان و تکرار مصرف روزانه شما متفاوت خواهد بود.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
) : (
|
||||
{/* Smart Dosage Calculator Utility Section (Only for oral/dosed products, not topical products) */}
|
||||
{!(fullProduct.categorySlug === 'special-care' ||
|
||||
fullProduct.name.toLowerCase().includes('pfotenpflege') ||
|
||||
fullProduct.name.toLowerCase().includes('augenpflege') ||
|
||||
fullProduct.unit?.includes('ml Lotion') ||
|
||||
fullProduct.unit?.includes('Balsam') ||
|
||||
fullProduct.nameFa?.includes('کرم') ||
|
||||
fullProduct.nameFa?.includes('قطره تمیزکننده') ||
|
||||
fullProduct.nameFa?.includes('اسپری')) && (
|
||||
<section className="bg-white rounded-[2.5rem] border border-medical-gray-200 p-8 md:p-10 shadow-md space-y-8">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="w-12 h-12 bg-canina-blue text-white rounded-2xl flex items-center justify-center shadow-lg">
|
||||
@@ -511,69 +532,108 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
|
||||
<div className="space-y-8">
|
||||
{/* Ingredients Cards */}
|
||||
<div>
|
||||
<h4 className="text-xs font-black text-medical-gray-400 uppercase tracking-widest mb-4 font-vazir">مواد تشکیلدهنده برتر</h4>
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{product.main_ingredients.map((ing, idx) => {
|
||||
const termKey = termKeys.find(key => {
|
||||
const termObj = scientificTerms[key] || SCIENTIFIC_TERMS[key];
|
||||
const termName = termObj?.term || key;
|
||||
const ingClean = ing.toLowerCase();
|
||||
const keyClean = key.toLowerCase();
|
||||
const termNameClean = termName.toLowerCase();
|
||||
return ingClean.includes(keyClean) ||
|
||||
keyClean.includes(ingClean) ||
|
||||
ingClean.includes(termNameClean) ||
|
||||
termNameClean.includes(ingClean);
|
||||
});
|
||||
return (
|
||||
<div key={idx} className="bg-medical-gray-50 border border-medical-gray-100 px-5 py-3 rounded-2xl flex items-center gap-3 group hover:border-canina-blue/30 transition-all">
|
||||
<span className="text-sm font-bold text-medical-gray-700 font-vazir">
|
||||
{termKey ? (
|
||||
<Tooltip termKey={termKey} onWikiNavigate={(id) => router.push(`/wiki?term=${id}`)}>
|
||||
{ing}
|
||||
</Tooltip>
|
||||
) : ing}
|
||||
</span>
|
||||
<Sparkles className="w-3 h-3 text-canina-blue opacity-40 group-hover:opacity-100 transition-opacity" />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Analysis Cards Grid */}
|
||||
{Object.keys(product.analysis).length > 0 && (
|
||||
<div className="space-y-6">
|
||||
<div className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-4 font-vazir">تخمین اتمام بسته (هوش مصنوعی)</div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
{Object.entries(product.analysis).map(([key, value]) => (
|
||||
<div key={key} className="bg-canina-blue text-white p-8 rounded-[2.5rem] border-b-2 border-white/20 shadow-xl group hover:scale-[1.02] transition-all duration-300">
|
||||
<div className="text-[10px] font-black text-white/80 uppercase tracking-widest mb-3 font-vazir whitespace-nowrap">{key}</div>
|
||||
<div className="text-3xl font-black font-vazir tracking-tighter text-white">{toPersian(value)}</div>
|
||||
</div>
|
||||
))}
|
||||
{product.main_ingredients && product.main_ingredients.length > 0 && (
|
||||
<div>
|
||||
<h4 className="text-xs font-black text-medical-gray-400 uppercase tracking-widest mb-4 font-vazir">مواد تشکیلدهنده برتر</h4>
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{product.main_ingredients.map((ing, idx) => {
|
||||
const termKey = termKeys.find(key => {
|
||||
const termObj = scientificTerms[key] || SCIENTIFIC_TERMS[key];
|
||||
const termName = termObj?.term || key;
|
||||
const ingClean = ing.toLowerCase();
|
||||
const keyClean = key.toLowerCase();
|
||||
const termNameClean = termName.toLowerCase();
|
||||
return ingClean.includes(keyClean) ||
|
||||
keyClean.includes(ingClean) ||
|
||||
ingClean.includes(termNameClean) ||
|
||||
termNameClean.includes(ingClean);
|
||||
});
|
||||
return (
|
||||
<div key={idx} className="bg-medical-gray-50 border border-medical-gray-100 px-5 py-3 rounded-2xl flex items-center gap-3 group hover:border-canina-blue/30 transition-all">
|
||||
<span className="text-sm font-bold text-medical-gray-700 font-vazir">
|
||||
{termKey ? (
|
||||
<Tooltip termKey={termKey} onWikiNavigate={(id) => router.push(`/wiki?term=${id}`)}>
|
||||
{ing}
|
||||
</Tooltip>
|
||||
) : ing}
|
||||
</span>
|
||||
<Sparkles className="w-3 h-3 text-canina-blue opacity-40 group-hover:opacity-100 transition-opacity" />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Quantitative Analysis Cards Grid (Strict chemical percentages, not duplicate ingredients) */}
|
||||
{(() => {
|
||||
const filteredAnalysis = Object.entries(product.analysis || {}).filter(([key, val]) => {
|
||||
const cleanKey = key.toLowerCase();
|
||||
// Don't show duplicate ingredients here if already listed above
|
||||
if (cleanKey.includes('مواد') || cleanKey.includes('ترکیبات') || cleanKey.includes('ingredient')) return false;
|
||||
return Boolean(val);
|
||||
});
|
||||
|
||||
if (filteredAnalysis.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div className="space-y-4 pt-4 border-t border-medical-gray-100">
|
||||
<div className="text-xs font-black text-medical-gray-500 uppercase tracking-widest font-vazir">جدول آنالیز و آنالیتیکال ترکیبات</div>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 gap-4">
|
||||
{filteredAnalysis.map(([key, value]) => (
|
||||
<div key={key} className="bg-medical-gray-50 border border-medical-gray-200 p-5 rounded-2xl shadow-xs group hover:border-canina-blue/30 transition-all">
|
||||
<div className="text-[11px] font-bold text-medical-gray-400 mb-1 font-vazir truncate">{key}</div>
|
||||
<div className="text-xl font-black font-vazir tracking-tight text-canina-blue">{toPersian(value)}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Feeding / Usage Instructions Section (Dynamic Header based on product category) */}
|
||||
{/* Feeding / Usage Instructions Section (Merged and enriched) */}
|
||||
<section className="bg-white border border-medical-gray-200 rounded-[2.5rem] p-8 md:p-10 shadow-md">
|
||||
<div className="flex items-center gap-4 mb-8">
|
||||
<div className="flex items-center gap-4 mb-6">
|
||||
<div className="w-12 h-12 bg-canina-blue text-white rounded-2xl flex items-center justify-center shadow-lg">
|
||||
<CalendarDays className="w-6 h-6" />
|
||||
</div>
|
||||
<h3 className="text-2xl font-black text-medical-gray-900 italic font-vazir">
|
||||
{product.categorySlug === 'special-care' || product.name.toLowerCase().includes('pfotenpflege') || product.name.toLowerCase().includes('augenpflege')
|
||||
? 'دستورالعمل و نحوه استفاده موضعی'
|
||||
: 'توصیه غذایی و نحوه مصرف'}
|
||||
</h3>
|
||||
<div>
|
||||
<h3 className="text-2xl font-black text-medical-gray-900 italic font-vazir">
|
||||
{fullProduct.categorySlug === 'special-care' || fullProduct.name.toLowerCase().includes('pfotenpflege') || fullProduct.name.toLowerCase().includes('augenpflege')
|
||||
? 'دستورالعمل و نحوه استفاده موضعی'
|
||||
: 'توصیه غذایی و نحوه مصرف'}
|
||||
</h3>
|
||||
<p className="text-xs text-medical-gray-400 font-bold font-vazir mt-0.5">
|
||||
{fullProduct.categorySlug === 'special-care' || fullProduct.name.toLowerCase().includes('pfotenpflege') || fullProduct.name.toLowerCase().includes('augenpflege')
|
||||
? 'فرآورده بهداشتی / موضعی (اعمال روی موضع بدون وابستگی به وزن بدن)'
|
||||
: 'راهنمای استاندارد تغذیه بر اساس کاتالوگ دارویی آلمان'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-medical-gray-700 leading-relaxed text-sm md:text-base font-medium font-vazir mb-6">
|
||||
{product.feedingAdvice}
|
||||
</p>
|
||||
|
||||
{fullProduct.categorySlug === 'special-care' ||
|
||||
fullProduct.name.toLowerCase().includes('pfotenpflege') ||
|
||||
fullProduct.name.toLowerCase().includes('augenpflege') ||
|
||||
fullProduct.unit?.includes('ml Lotion') ||
|
||||
fullProduct.unit?.includes('Balsam') ||
|
||||
fullProduct.nameFa?.includes('کرم') ||
|
||||
fullProduct.nameFa?.includes('قطره تمیزکننده') ||
|
||||
fullProduct.nameFa?.includes('اسپری') ? (
|
||||
<div className="bg-canina-blue/5 border border-canina-blue/20 rounded-2xl p-5 mb-6 text-sm text-medical-gray-700 font-bold leading-relaxed">
|
||||
<p className="mb-2">
|
||||
{product.feedingAdvice || "چندین بار در روز روی نواحی آسیبدیده مالیده و به آرامی ماساژ داده شود."}
|
||||
</p>
|
||||
<p className="text-xs text-medical-gray-500 font-medium pt-2 border-t border-canina-blue/10">
|
||||
ℹ️ این محصول یک فرآورده موضعی/بهداشتی است و مقدار مصرف آن به صورت موضعی (روی پوست، چشم یا پنجه) اعمال میشود و وابسته به وزن بدن حیوان نمیباشد. ماندگاری بسته بسته به میزان و تکرار مصرف روزانه شما متفاوت خواهد بود.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-medical-gray-700 leading-relaxed text-sm md:text-base font-medium font-vazir mb-6">
|
||||
{product.feedingAdvice}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Storage & Precautions Bar */}
|
||||
<div className="grid md:grid-cols-2 gap-4 pt-6 border-t border-medical-gray-100">
|
||||
@@ -599,54 +659,6 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Specialist Note */}
|
||||
{product.specialist && (
|
||||
<section className="bg-white rounded-[2.5rem] p-8 md:p-10 border border-medical-gray-200 shadow-md">
|
||||
<div className="flex flex-col md:flex-row gap-10 items-start">
|
||||
<img
|
||||
src={product.specialist.image}
|
||||
alt={product.specialist.name}
|
||||
className="w-32 h-32 rounded-[2rem] object-cover border-4 border-medical-gray-50 shadow-xl"
|
||||
/>
|
||||
<div className="flex-1">
|
||||
<div className="inline-flex items-center gap-2 px-3 py-1 bg-medical-gray-900 text-white rounded-full text-[10px] font-black uppercase tracking-widest mb-4 font-vazir whitespace-nowrap">
|
||||
<Stethoscope className="w-3 h-3" />
|
||||
مورد تأیید دامپزشکان
|
||||
</div>
|
||||
<h4 className="text-2xl font-black text-medical-gray-900 mb-1 font-vazir">{product.specialist.name}</h4>
|
||||
<p className="text-sm font-bold text-canina-blue mb-6 font-vazir">{product.specialist.title}</p>
|
||||
<p className="text-base text-medical-gray-600 leading-relaxed italic font-vazir">
|
||||
"{product.specialist.message}"
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Specialized Landing Banner */}
|
||||
<section>
|
||||
<div
|
||||
className="relative bg-canina-blue rounded-[2.5rem] p-12 overflow-hidden group cursor-pointer border border-medical-gray-200 shadow-md"
|
||||
onClick={() => toast.info("بزودی: صفحه فرود تخصصی این محصول در حال آمادهسازی است")}
|
||||
>
|
||||
<div className="absolute top-0 right-0 w-full h-full bg-[url('https://www.transparenttextures.com/patterns/cubes.png')] opacity-10" />
|
||||
<div className="absolute -bottom-20 -left-20 w-80 h-80 bg-white/10 rounded-full blur-3xl group-hover:bg-white/20 transition-all duration-700" />
|
||||
|
||||
<div className="relative z-10 flex flex-col md:flex-row items-center justify-between gap-8">
|
||||
<div className="text-center md:text-right">
|
||||
<h3 className="text-3xl lg:text-4xl font-black text-white mb-4 italic">مشاهده بررسی تخصصی و نتایج درمانی</h3>
|
||||
<p className="text-white/80 font-bold font-vazir max-w-lg">
|
||||
گزارشهای علمی، ویدیوهای آموزشی و تجربیات واقعی دیگر صاحبان پت در لندینگپیج اختصاصی این محصول.
|
||||
</p>
|
||||
</div>
|
||||
<div className="bg-white text-canina-blue px-8 py-4 rounded-2xl font-black shadow-2xl hover:scale-105 transition-transform flex items-center gap-3">
|
||||
ورود به آزمایشگاه علمی
|
||||
<ArrowRight className="w-5 h-5 rotate-180" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* FAQ Section */}
|
||||
{product.faqs && product.faqs.length > 0 && (
|
||||
<section className="pt-10">
|
||||
@@ -956,6 +968,70 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Fullscreen High-Resolution Image Zoom / Lightbox Modal */}
|
||||
<AnimatePresence>
|
||||
{isImageZoomOpen && (
|
||||
<div
|
||||
className="fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-8 bg-black/85 backdrop-blur-md"
|
||||
onClick={() => setIsImageZoomOpen(false)}
|
||||
>
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scale: 0.9 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
exit={{ opacity: 0, scale: 0.9 }}
|
||||
className="relative max-w-4xl max-h-[90vh] w-full flex flex-col items-center justify-center"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* Close Button */}
|
||||
<button
|
||||
onClick={() => setIsImageZoomOpen(false)}
|
||||
className="absolute -top-12 left-0 sm:left-auto sm:-right-12 w-10 h-10 rounded-full bg-white/20 hover:bg-white/30 text-white flex items-center justify-center transition-colors cursor-pointer"
|
||||
title="بستن"
|
||||
>
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
|
||||
{/* Main Zoomed Image Container */}
|
||||
<div className="bg-white rounded-3xl p-6 sm:p-10 shadow-2xl border border-white/20 max-h-[75vh] flex items-center justify-center overflow-hidden w-full">
|
||||
<img
|
||||
src={activeImage || product.image}
|
||||
alt={product.name}
|
||||
className="max-h-[60vh] max-w-full w-auto object-contain drop-shadow-2xl"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Lightbox Thumbnails Navigation */}
|
||||
{(() => {
|
||||
const allImgs = [
|
||||
product.image,
|
||||
...(product.images || []).filter(img => img && img !== product.image)
|
||||
].filter(Boolean);
|
||||
|
||||
if (allImgs.length <= 1) return null;
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-3 mt-4 overflow-x-auto py-2 px-4 max-w-full">
|
||||
{allImgs.map((img, idx) => (
|
||||
<button
|
||||
key={idx}
|
||||
onClick={() => setActiveImage(img)}
|
||||
className={`w-14 h-14 rounded-xl overflow-hidden bg-white/10 border-2 transition-all p-1 shrink-0 ${
|
||||
(activeImage || product.image) === img
|
||||
? 'border-white scale-110 shadow-lg'
|
||||
: 'border-transparent opacity-60 hover:opacity-100'
|
||||
}`}
|
||||
>
|
||||
<img src={img} alt="Thumbnail" className="w-full h-full object-contain" />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</motion.div>
|
||||
</div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -60,6 +60,7 @@ export interface Product {
|
||||
feedingAdvice: string;
|
||||
specialist: Specialist;
|
||||
image: string;
|
||||
images?: string[];
|
||||
relatedProducts?: string[];
|
||||
faqs?: FAQ[];
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ interface BackendProduct {
|
||||
slug?: string;
|
||||
imageUrl?: string;
|
||||
image?: string;
|
||||
images?: string[];
|
||||
productGroup?: string;
|
||||
ingredientList?: Array<{ ingredient: string }>;
|
||||
ingredients?: string;
|
||||
@@ -129,6 +130,14 @@ export class ProductService {
|
||||
if (data.imageUrl.startsWith('/products/')) return local?.image || '/assets/images/hero-section-image.png';
|
||||
return local?.image || data.imageUrl || '/assets/images/hero-section-image.png';
|
||||
})(),
|
||||
images: Array.isArray(data.images) && data.images.length > 0
|
||||
? data.images.map((img: string) => {
|
||||
const apiBase = (process.env.NEXT_PUBLIC_API_URL || '').replace(/\/api$/, '');
|
||||
if (img.startsWith('http://') || img.startsWith('https://')) return img;
|
||||
if (img.startsWith('/uploads/')) return `${apiBase}${img}`;
|
||||
return img;
|
||||
})
|
||||
: (local?.images || []),
|
||||
|
||||
main_ingredients: data.ingredientList?.map(i => i.ingredient) || data.ingredients?.split(/[،,-]/).map(s => s.trim()).filter(Boolean) || [],
|
||||
symptoms: data.symptoms?.map(s => typeof s === 'string' ? s : s.symptom || '').filter(Boolean) || [],
|
||||
|
||||
Reference in new issue
Block a user