feat(catalog): implement luxury 3D RTL flipbook catalog with complete A4 PDF export and responsive height
Deploy Canina / deploy (push) Successful in 1m35s
Deploy Canina / deploy (push) Successful in 1m35s
This commit is contained in:
1 parent
6e98b8779d
commit
7e403bd53e
5 files changed
+1464
-260
No files matched your search
@@ -1,276 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect, useRef } from "react";
|
||||
import SafeImage from "../../components/SafeImage";
|
||||
import BackButton from "../../components/BackButton";
|
||||
import { Printer, ShieldCheck, Sparkles, CheckCircle2, ChevronLeft, Search } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import FlipbookCatalog from "../../components/catalog/FlipbookCatalog";
|
||||
import { productService } from "../../lib/services/productService";
|
||||
import { Product } from "../../lib/data/products";
|
||||
|
||||
import { Product, PRODUCTS } from "../../lib/data/products";
|
||||
|
||||
export default function CatalogClient() {
|
||||
const [products, setProducts] = useState<Product[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [selectedCategory, setSelectedCategory] = useState("all");
|
||||
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
const [isMouseDown, setIsMouseDown] = useState(false);
|
||||
const [startX, setStartX] = useState(0);
|
||||
const [scrollLeft, setScrollLeft] = useState(0);
|
||||
|
||||
const handleMouseDown = (e: React.MouseEvent) => {
|
||||
if (!scrollRef.current) return;
|
||||
setIsMouseDown(true);
|
||||
setStartX(e.pageX - scrollRef.current.offsetLeft);
|
||||
setScrollLeft(scrollRef.current.scrollLeft);
|
||||
};
|
||||
|
||||
const handleMouseLeaveOrUp = () => {
|
||||
setIsMouseDown(false);
|
||||
};
|
||||
|
||||
const handleMouseMove = (e: React.MouseEvent) => {
|
||||
if (!isMouseDown || !scrollRef.current) return;
|
||||
e.preventDefault();
|
||||
const x = e.pageX - scrollRef.current.offsetLeft;
|
||||
const walk = (x - startX) * 2; // scroll speed
|
||||
scrollRef.current.scrollLeft = scrollLeft - walk;
|
||||
};
|
||||
|
||||
const handleWheel = (e: React.WheelEvent) => {
|
||||
if (scrollRef.current && e.deltaY !== 0) {
|
||||
scrollRef.current.scrollLeft += e.deltaY;
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
productService.getProducts({ limit: 999 })
|
||||
.then(res => {
|
||||
setProducts(res.data || []);
|
||||
if (res.data && res.data.length > 0) {
|
||||
setProducts(res.data);
|
||||
} else {
|
||||
setProducts(PRODUCTS);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("Catalog fetch error, fallback to static products:", err);
|
||||
setProducts(PRODUCTS);
|
||||
})
|
||||
.catch(err => console.error("Catalog fetch error:", err))
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
const categories = Array.from(new Set(products.map(p => p.category).filter(Boolean)));
|
||||
|
||||
const filteredProducts = products.filter(p => {
|
||||
const matchCategory = selectedCategory === "all" || p.category === selectedCategory;
|
||||
const matchSearch = p.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
p.artNo.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
(p.main_ingredients && p.main_ingredients.some(i => i.toLowerCase().includes(searchQuery.toLowerCase())));
|
||||
return matchCategory && matchSearch;
|
||||
});
|
||||
|
||||
const handlePrint = () => {
|
||||
window.print();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-slate-50 font-vazir text-slate-800 py-12 px-4 sm:px-8 print:bg-white print:py-0 print:px-0" dir="rtl">
|
||||
{/* Header Bar - Hidden on print */}
|
||||
<div className="max-w-7xl mx-auto mb-10 print:hidden">
|
||||
<div className="bg-gradient-to-r from-canina-blue via-blue-900 to-canina-blue text-white rounded-[2.5rem] p-8 md:p-12 shadow-2xl relative overflow-hidden">
|
||||
<div className="absolute top-0 right-0 w-96 h-96 bg-white/5 rounded-full blur-3xl -mr-20 -mt-20 pointer-events-none" />
|
||||
|
||||
<div className="relative z-10 flex flex-col lg:flex-row lg:items-center justify-between gap-8">
|
||||
<div className="max-w-2xl">
|
||||
<div className="inline-flex items-center gap-2 px-3 py-1 bg-white/10 rounded-full text-xs font-black uppercase tracking-widest text-amber-300 mb-4 border border-white/10">
|
||||
<Sparkles className="w-4 h-4" />
|
||||
<span>کاتالوگ رسمی محصولات کانینا آلمان</span>
|
||||
</div>
|
||||
<h1 className="text-3xl md:text-5xl font-black font-lalezar leading-tight mb-4">
|
||||
راهنمای جامع مکملهای درمانی و دارویی Canina Pharma
|
||||
</h1>
|
||||
<p className="text-white/80 text-sm md:text-base leading-relaxed">
|
||||
معرفی کامل ترکیبات فعال، موارد مصرف بالینی و استانداردهای دارویی محصولات برند آلمانی کانینا جهت استفاده صاحبان پتها و متخصصین دامپزشکی.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<BackButton className="bg-white/10 text-white border-white/20 hover:bg-white/20 hover:text-white" />
|
||||
<button
|
||||
onClick={handlePrint}
|
||||
className="bg-amber-400 hover:bg-amber-500 text-slate-900 font-black px-6 py-4 rounded-2xl shadow-xl hover:scale-105 transition-all flex items-center gap-3 text-sm cursor-pointer"
|
||||
>
|
||||
<Printer className="w-5 h-5" />
|
||||
<span>چاپ / دانلود نسخه PDF کاتالوگ</span>
|
||||
</button>
|
||||
<Link
|
||||
href="/shop"
|
||||
className="bg-white/10 hover:bg-white/20 text-white font-bold px-6 py-4 rounded-2xl border border-white/20 transition-all flex items-center gap-2 text-sm"
|
||||
>
|
||||
<span>ورود به فروشگاه</span>
|
||||
<ChevronLeft className="w-4 h-4" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-slate-900 text-slate-100 flex items-center justify-center font-vazir">
|
||||
<div className="text-center space-y-4">
|
||||
<div className="w-12 h-12 border-4 border-amber-400 border-t-transparent rounded-full animate-spin mx-auto" />
|
||||
<p className="text-sm font-bold text-slate-300">در حال بارگذاری کاتالوگ دیجیتال Canina Pharma...</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
{/* Print Cover Header - Visible only on Print */}
|
||||
<div className="hidden print:block text-center py-8 border-b-2 border-canina-blue mb-8">
|
||||
<h1 className="text-3xl font-black text-canina-blue font-lalezar mb-2">کاتالوگ رسمی مکملهای درمانی Canina Pharma Germany</h1>
|
||||
<p className="text-sm text-gray-600 font-bold">واردکننده انحصاری مکملهای دارویی سگ و گربه در ایران — info@canina-iran.com | ۰۲۱-۸۸۸۸۴۴۴۴</p>
|
||||
</div>
|
||||
|
||||
{/* Filter & Search Controls - Hidden on print */}
|
||||
<div className="max-w-7xl mx-auto mb-10 print:hidden flex flex-col md:flex-row gap-4 justify-between items-center bg-white p-6 rounded-3xl border border-slate-200 shadow-sm">
|
||||
<div className="relative w-full md:w-96">
|
||||
<Search className="absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجوی نام محصول، کد کالا یا ماده موثره..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="w-full bg-slate-50 border border-slate-200 rounded-2xl py-3 pr-11 pl-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-canina-blue/20"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
ref={scrollRef}
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseLeave={handleMouseLeaveOrUp}
|
||||
onMouseUp={handleMouseLeaveOrUp}
|
||||
onMouseMove={handleMouseMove}
|
||||
onWheel={handleWheel}
|
||||
className={`flex items-center gap-2.5 overflow-x-auto sleek-hscroll w-full md:w-auto py-2.5 px-1 scroll-smooth select-none cursor-grab ${isMouseDown ? 'cursor-grabbing' : ''}`}
|
||||
>
|
||||
<button
|
||||
onClick={() => setSelectedCategory("all")}
|
||||
className={`px-5 py-3 rounded-2xl text-xs font-black transition-all shrink-0 shadow-xs ${
|
||||
selectedCategory === "all" ? "bg-canina-blue text-white shadow-md scale-105" : "bg-slate-100 text-slate-700 hover:bg-slate-200"
|
||||
}`}
|
||||
>
|
||||
همه دستهها ({products.length})
|
||||
</button>
|
||||
{categories.map(cat => (
|
||||
<button
|
||||
key={cat}
|
||||
onClick={() => setSelectedCategory(cat)}
|
||||
className={`px-5 py-3 rounded-2xl text-xs font-black transition-all shrink-0 shadow-xs ${
|
||||
selectedCategory === cat ? "bg-canina-blue text-white shadow-md scale-105" : "bg-slate-100 text-slate-700 hover:bg-slate-200"
|
||||
}`}
|
||||
>
|
||||
{cat}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Catalog Products Grid */}
|
||||
<div className="max-w-7xl mx-auto">
|
||||
{loading ? (
|
||||
<div className="text-center py-20 text-slate-400 font-bold">در حال بارگذاری کاتالوگ محصولات...</div>
|
||||
) : filteredProducts.length === 0 ? (
|
||||
<div className="text-center py-20 bg-white rounded-3xl border border-slate-200">
|
||||
<h3 className="text-xl font-black text-slate-700 mb-2">محصولی یافت نشد</h3>
|
||||
<p className="text-sm text-slate-500">لطفاً عبارت جستجو را تغییر دهید.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 print:grid-cols-2 print:gap-6">
|
||||
{filteredProducts.map((product) => (
|
||||
<div
|
||||
key={product.id}
|
||||
className="bg-white rounded-3xl border border-slate-200 overflow-hidden shadow-sm hover:shadow-xl transition-all duration-300 flex flex-col justify-between print:break-inside-avoid print:shadow-none print:border-slate-300"
|
||||
>
|
||||
<div>
|
||||
{/* Top Image Banner */}
|
||||
<div className="relative bg-slate-100 p-6 flex items-center justify-center border-b border-slate-100 aspect-video print:h-44">
|
||||
<SafeImage
|
||||
src={product.image}
|
||||
alt={product.name}
|
||||
className="w-full h-full"
|
||||
imgClassName="object-contain max-h-40"
|
||||
/>
|
||||
<div className="absolute top-3 right-3 bg-canina-blue text-white px-3 py-1 rounded-full text-[10px] font-black uppercase tracking-wider">
|
||||
کد کالا: {product.artNo}
|
||||
</div>
|
||||
{product.suitableFor && (
|
||||
<div className="absolute bottom-3 left-3 bg-white/90 backdrop-blur-sm text-slate-800 px-2.5 py-1 rounded-lg text-[11px] font-black shadow-sm">
|
||||
مناسب: {product.suitableFor}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Body Content */}
|
||||
<div className="p-6 space-y-4">
|
||||
<div>
|
||||
<span className="text-[10px] font-black text-canina-blue uppercase tracking-widest block mb-1">
|
||||
{product.category}
|
||||
</span>
|
||||
<h3 className="text-xl font-black text-slate-900 leading-snug font-vazir">
|
||||
{product.name}
|
||||
</h3>
|
||||
{product.scientificTagline && (
|
||||
<p className="text-xs text-slate-500 font-bold mt-1 leading-relaxed">
|
||||
{product.scientificTagline}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<p className="text-xs text-slate-600 leading-relaxed line-clamp-4 print:line-clamp-none">
|
||||
{product.shortDescription || product.description}
|
||||
</p>
|
||||
|
||||
{/* Ingredients Badges */}
|
||||
{product.main_ingredients && product.main_ingredients.length > 0 && (
|
||||
<div className="pt-2 border-t border-slate-100">
|
||||
<span className="text-[10px] font-black text-slate-400 uppercase tracking-wider block mb-2">
|
||||
مواد موثره و ترکیبات اصلی:
|
||||
</span>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{product.main_ingredients.map((ing, idx) => (
|
||||
<span
|
||||
key={idx}
|
||||
className="bg-blue-50 text-canina-blue border border-blue-100 rounded-lg px-2 py-1 text-[10px] font-bold"
|
||||
>
|
||||
{ing}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Dosage Instructions */}
|
||||
{(product.dosage_logic || (product as unknown as { dosageLogic?: string }).dosageLogic) && (
|
||||
<div className="bg-amber-50/60 border border-amber-200/60 rounded-2xl p-3 text-xs font-bold text-amber-900 flex items-start gap-2">
|
||||
<ShieldCheck className="w-4 h-4 text-amber-600 shrink-0 mt-0.5" />
|
||||
<div>
|
||||
<span className="font-black text-[11px] block text-amber-800">دستور مصرف بالینی:</span>
|
||||
<span className="text-[11px] font-medium leading-relaxed">{product.dosage_logic || (product as unknown as { dosageLogic?: string }).dosageLogic}</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Card Footer - Hidden on print */}
|
||||
<div className="p-4 bg-slate-50 border-t border-slate-100 flex items-center justify-between print:hidden">
|
||||
<div className="flex items-center gap-1 text-[11px] font-bold text-slate-500">
|
||||
<CheckCircle2 className="w-4 h-4 text-green-600" />
|
||||
<span>گرید دارویی آلمان</span>
|
||||
</div>
|
||||
<Link
|
||||
href={`/shop/${product.slug || product.id}`}
|
||||
className="text-xs font-black text-canina-blue hover:underline flex items-center gap-1"
|
||||
>
|
||||
<span>جزئیات تخصصی</span>
|
||||
<ChevronLeft className="w-3.5 h-3.5" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Print Footer */}
|
||||
<div className="hidden print:block text-center pt-8 border-t border-slate-300 mt-12 text-xs text-slate-500 font-bold">
|
||||
صفحه کاتالوگ آنلاین محصولات Canina Pharma Germany — وبسایت رسمی: https://canina-iran.com
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
return <FlipbookCatalog products={products} />;
|
||||
}
|
||||
@@ -179,10 +179,10 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
className="inline-flex items-center gap-2 px-4 py-2 bg-canina-blue/5 rounded-full mb-4 border border-canina-blue/10"
|
||||
>
|
||||
<Sparkle className="w-4 h-4 text-canina-blue animate-spin" />
|
||||
<span className="text-canina-blue text-xs font-black uppercase tracking-widest font-vazir">{getText('advisor_badge', "سیستم پایش و تجویز هوشمند")}</span>
|
||||
<span suppressHydrationWarning className="text-canina-blue text-xs font-black uppercase tracking-widest font-vazir">{getText('advisor_badge', "سیستم پایش و تجویز هوشمند")}</span>
|
||||
</motion.div>
|
||||
<h2 className="text-4xl lg:text-5xl font-black text-medical-gray-900 mb-4 font-lalezar tracking-wide">{getText('advisor_title', "دستیار سلامت و الگوریتم پایش کانینا")}</h2>
|
||||
<p className="text-medical-gray-600 font-medium text-base font-shabnam max-w-2xl mx-auto leading-relaxed">
|
||||
<h2 suppressHydrationWarning className="text-4xl lg:text-5xl font-black text-medical-gray-900 mb-4 font-lalezar tracking-wide">{getText('advisor_title', "دستیار سلامت و الگوریتم پایش کانینا")}</h2>
|
||||
<p suppressHydrationWarning className="text-medical-gray-600 font-medium text-base font-shabnam max-w-2xl mx-auto leading-relaxed">
|
||||
{getText('advisor_subtitle', "با ثبت اطلاعات همدم خود در ۴ قدم ساده، از الگوریتم علمی کانینا برای تجویز دقیق مکمل و پایش سلامت بهرهمند شوید.")}
|
||||
</p>
|
||||
|
||||
|
||||
@@ -0,0 +1,498 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import SafeImage from "../SafeImage";
|
||||
import { Product } from "../../lib/data/products";
|
||||
import {
|
||||
Sparkles,
|
||||
ChevronLeft,
|
||||
ShieldCheck,
|
||||
Dog,
|
||||
Cat,
|
||||
Pill,
|
||||
Droplet,
|
||||
Package,
|
||||
Award,
|
||||
Activity,
|
||||
BookOpen,
|
||||
CheckCircle2,
|
||||
Stethoscope,
|
||||
Heart,
|
||||
Layers,
|
||||
Check
|
||||
} from "lucide-react";
|
||||
|
||||
export interface CategoryMeta {
|
||||
id: string;
|
||||
name: string;
|
||||
color: string;
|
||||
lightBg: string;
|
||||
borderBg: string;
|
||||
icon: React.ElementType;
|
||||
tagline: string;
|
||||
startPage: number;
|
||||
}
|
||||
|
||||
interface CatalogPageSpreadProps {
|
||||
pageNumber: number;
|
||||
totalPages: number;
|
||||
pageType: "cover" | "toc" | "product" | "backcover" | "category";
|
||||
categoryMeta?: CategoryMeta;
|
||||
product?: Product;
|
||||
products?: Product[];
|
||||
onSelectProduct?: (product: Product) => void;
|
||||
onJumpToPage?: (pageNum: number) => void;
|
||||
categoriesList?: CategoryMeta[];
|
||||
}
|
||||
|
||||
// Helper to determine product form icon & label
|
||||
const getFormBadge = (unit?: string, name?: string) => {
|
||||
const str = ((unit || "") + " " + (name || "")).toLowerCase();
|
||||
if (str.includes("paste") || str.includes("خمیر")) return { label: "خمیر دارویی", icon: Droplet };
|
||||
if (str.includes("tab") || str.includes("قرص")) return { label: "قرص خوراکی", icon: Pill };
|
||||
if (str.includes("öl") || str.includes("روغن")) return { label: "روغن خالص", icon: Droplet };
|
||||
if (str.includes("pulver") || str.includes("پودر") || str.includes("mehl")) return { label: "پودر خوراکی", icon: Package };
|
||||
if (str.includes("gel") || str.includes("ژل")) return { label: "ژل بهداشتی", icon: Droplet };
|
||||
if (str.includes("spray") || str.includes("اسپری") || str.includes("shocker")) return { label: "اسپری موضعی", icon: Droplet };
|
||||
return { label: "مکمل دارویی", icon: Package };
|
||||
};
|
||||
|
||||
// Helper for pet target species icon
|
||||
const getSpeciesBadge = (suitableFor?: string) => {
|
||||
if (suitableFor === "سگ") return { label: "مخصوص سگ", icon: Dog };
|
||||
if (suitableFor === "گربه") return { label: "مخصوص گربه", icon: Cat };
|
||||
return { label: "سگ و گربه", icon: Heart };
|
||||
};
|
||||
|
||||
export default function CatalogPageSpread({
|
||||
pageNumber,
|
||||
totalPages,
|
||||
pageType,
|
||||
categoryMeta,
|
||||
product,
|
||||
onJumpToPage,
|
||||
categoriesList = [],
|
||||
}: CatalogPageSpreadProps) {
|
||||
|
||||
// ==========================================
|
||||
// 1. LUXURY FRONT COVER (طراحی لوکس جلد)
|
||||
// ==========================================
|
||||
if (pageType === "cover") {
|
||||
return (
|
||||
<div className="w-full h-full bg-gradient-to-br from-slate-950 via-[#0a192f] to-[#040d1a] text-white p-6 md:p-8 flex flex-col justify-between relative overflow-hidden select-none box-border" dir="rtl">
|
||||
{/* Luxury Background Accents & Gold Borders */}
|
||||
<div className="absolute inset-0 bg-[radial-gradient(#d4af37_1px,transparent_1px)] [background-size:28px_28px] opacity-[0.07] pointer-events-none" />
|
||||
<div className="absolute -top-20 -right-20 w-80 h-80 bg-blue-600/15 rounded-full blur-3xl pointer-events-none" />
|
||||
<div className="absolute -bottom-20 -left-20 w-80 h-80 bg-amber-500/10 rounded-full blur-3xl pointer-events-none" />
|
||||
|
||||
{/* Outer Gold Border Frame */}
|
||||
<div className="absolute inset-3 border border-amber-400/20 rounded-2xl pointer-events-none" />
|
||||
<div className="absolute inset-4 border border-white/5 rounded-xl pointer-events-none" />
|
||||
|
||||
{/* Top Header */}
|
||||
<div className="relative z-10 flex items-center justify-between border-b border-white/10 pb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-amber-400 to-amber-500 text-slate-950 flex items-center justify-center font-black text-lg shadow-lg font-mono">
|
||||
CP
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-lg font-black font-lalezar tracking-wide text-white block">
|
||||
Canina Pharma Germany
|
||||
</span>
|
||||
<span className="text-[9px] text-amber-300 font-bold uppercase tracking-widest block font-mono">
|
||||
🇩🇪 100% Made in Germany • Est. 1984
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="px-3 py-1 bg-white/10 rounded-full text-[10px] font-bold text-amber-300 border border-amber-400/30 flex items-center gap-1.5">
|
||||
<Award className="w-3 h-3 text-amber-400" />
|
||||
<span>نسخه رسمی ۲۰۲۶</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Center Hero Title & Visual */}
|
||||
<div className="relative z-10 my-auto text-center space-y-4 py-2">
|
||||
|
||||
<div className="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-amber-400/10 border border-amber-400/30 text-amber-300 text-[10px] font-black">
|
||||
<Sparkles className="w-3.5 h-3.5" />
|
||||
<span>OFFICIAL VETERINARY & CLINICAL CATALOG</span>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl sm:text-3xl md:text-4xl font-black font-lalezar leading-tight text-transparent bg-clip-text bg-gradient-to-r from-amber-100 via-white to-amber-300">
|
||||
کاتالوگ تخصصی و راهنمای بالینی مکملهای دارویی کانینا
|
||||
</h1>
|
||||
<p className="text-[11px] md:text-xs text-slate-300 font-medium max-w-md mx-auto leading-relaxed">
|
||||
مرجع رسمی مکملهای درمانی حیوانات خانگی با استانداردهای داروسازی آلمان (GMP) و تاییدیههای ارتوپدی و پوست
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Hero Render Frame */}
|
||||
<div className="pt-2 flex justify-center">
|
||||
<div className="w-36 h-36 md:w-44 md:h-44 rounded-2xl bg-gradient-to-b from-white/10 to-white/5 border border-white/15 backdrop-blur-md p-3 flex flex-col items-center justify-center shadow-2xl relative">
|
||||
<SafeImage
|
||||
src="/assets/images/hero-section-image.png"
|
||||
alt="Canina Pharma Germany"
|
||||
className="w-full h-full"
|
||||
imgClassName="object-contain filter drop-shadow-xl"
|
||||
/>
|
||||
<div className="absolute -bottom-2.5 bg-gradient-to-r from-amber-400 to-amber-500 text-slate-950 font-black text-[9px] px-3 py-0.5 rounded-full shadow-md">
|
||||
Pharma Grade Certified
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Highlights Pills */}
|
||||
<div className="flex flex-wrap items-center justify-center gap-2 pt-1 text-[10px] text-slate-300">
|
||||
<span className="bg-white/5 border border-white/10 px-2.5 py-1 rounded-lg">🦴 مفاصل و اسکلت</span>
|
||||
<span className="bg-white/5 border border-white/10 px-2.5 py-1 rounded-lg">✨ پوست و مو</span>
|
||||
<span className="bg-white/5 border border-white/10 px-2.5 py-1 rounded-lg">🛡️ ایمنی و گوارش</span>
|
||||
<span className="bg-white/5 border border-white/10 px-2.5 py-1 rounded-lg">⚡ ویتامینها</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Bottom Footer */}
|
||||
<div className="relative z-10 border-t border-white/10 pt-3 flex items-center justify-between text-[10px] text-slate-400 font-bold">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<ShieldCheck className="w-3.5 h-3.5 text-amber-400" />
|
||||
<span>نمایندگی انحصاری Canina Pharma Germany در ایران</span>
|
||||
</div>
|
||||
<span className="font-mono text-slate-400">صفحه ۰۱</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 2. TABLE OF CONTENTS (فهرست دستهبندیها)
|
||||
// ==========================================
|
||||
if (pageType === "toc") {
|
||||
return (
|
||||
<div className="w-full h-full bg-slate-50 text-slate-800 p-5 md:p-7 flex flex-col justify-between select-none box-border" dir="rtl">
|
||||
{/* TOC Header */}
|
||||
<div className="border-b border-slate-200 pb-3 flex items-center justify-between shrink-0">
|
||||
<div>
|
||||
<div className="flex items-center gap-1.5 text-[10px] font-black text-canina-blue uppercase tracking-widest">
|
||||
<BookOpen className="w-3.5 h-3.5" />
|
||||
<span>فهرست تخصصی و راهنمای بالینی</span>
|
||||
</div>
|
||||
<h2 className="text-xl md:text-2xl font-black font-lalezar text-slate-900 mt-0.5">
|
||||
دستهبندیهای کاتالوگ دارویی
|
||||
</h2>
|
||||
</div>
|
||||
<div className="text-left">
|
||||
<span className="text-[10px] font-black text-slate-400 block font-mono">CANINA PHARMA</span>
|
||||
<span className="text-[9px] font-bold text-amber-600 uppercase">Germany</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Categories List (Compact luxury layout, perfectly fitted) */}
|
||||
<div className="my-auto space-y-2.5 py-2 flex-1 flex flex-col justify-center min-h-0">
|
||||
{categoriesList.map((cat, idx) => {
|
||||
const IconComp = cat.icon;
|
||||
return (
|
||||
<div
|
||||
key={cat.id}
|
||||
onClick={() => onJumpToPage && onJumpToPage(cat.startPage)}
|
||||
className="bg-white border border-slate-200/90 hover:border-slate-300 rounded-xl p-2.5 sm:p-3 flex items-center justify-between gap-3 shadow-2xs hover:shadow-md transition-all cursor-pointer group"
|
||||
>
|
||||
<div className="flex items-center gap-3 min-w-0">
|
||||
{/* Category Color Icon */}
|
||||
<div
|
||||
className="w-9 h-9 rounded-lg flex items-center justify-center text-white font-black shadow-xs shrink-0 group-hover:scale-105 transition-transform"
|
||||
style={{ backgroundColor: cat.color }}
|
||||
>
|
||||
<IconComp className="w-4 h-4" />
|
||||
</div>
|
||||
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-[9px] font-black text-slate-400 font-mono">
|
||||
SECTION 0{idx + 1}
|
||||
</span>
|
||||
<span className="w-1.5 h-1.5 rounded-full" style={{ backgroundColor: cat.color }} />
|
||||
</div>
|
||||
<h3 className="text-xs sm:text-sm font-black text-slate-900 group-hover:text-canina-blue transition-colors font-vazir truncate">
|
||||
{cat.name}
|
||||
</h3>
|
||||
<p className="text-[10px] text-slate-500 font-medium truncate mt-0.5">
|
||||
{cat.tagline}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
<div className="text-left">
|
||||
<span className="text-[8px] text-slate-400 font-bold block">صفحه</span>
|
||||
<span className="text-xs font-black text-slate-900 font-mono">
|
||||
{cat.startPage < 10 ? `۰${cat.startPage}` : cat.startPage}
|
||||
</span>
|
||||
</div>
|
||||
<div className="w-6 h-6 rounded-full bg-slate-100 group-hover:bg-canina-blue group-hover:text-white text-slate-400 flex items-center justify-center transition-colors">
|
||||
<ChevronLeft className="w-3.5 h-3.5" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Quality Seal Note */}
|
||||
<div className="bg-amber-50/70 border border-amber-200/60 rounded-xl p-2.5 flex items-center gap-2.5 shrink-0">
|
||||
<Award className="w-4 h-4 text-amber-600 shrink-0" />
|
||||
<p className="text-[10px] text-amber-900 font-bold leading-relaxed">
|
||||
تمامی فرآوردههای کانینا آلمان مطابق با مونوگرافهای دارویی فارماکوپه اروپا (Ph. Eur.) و تحت استاندارد GMP تولید میشوند.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* TOC Footer */}
|
||||
<div className="border-t border-slate-200 pt-2 flex items-center justify-between text-[10px] text-slate-400 font-bold shrink-0">
|
||||
<span>راهنمای جامع کاتالوگ دارویی Canina Pharma</span>
|
||||
<span className="font-mono">صفحه ۰۲</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 3. LUXURY BACK COVER (شناسنامه پشت جلد)
|
||||
// ==========================================
|
||||
if (pageType === "backcover") {
|
||||
return (
|
||||
<div className="w-full h-full bg-gradient-to-br from-slate-950 via-[#0a192f] to-[#040d1a] text-white p-6 md:p-8 flex flex-col justify-between relative overflow-hidden select-none box-border" dir="rtl">
|
||||
<div className="absolute inset-3 border border-amber-400/20 rounded-2xl pointer-events-none" />
|
||||
<div className="absolute -top-24 -left-24 w-80 h-80 bg-blue-600/10 rounded-full blur-3xl pointer-events-none" />
|
||||
|
||||
<div className="relative z-10 border-b border-white/10 pb-3 flex justify-between items-center">
|
||||
<div className="flex items-center gap-2">
|
||||
<Award className="w-4 h-4 text-amber-400" />
|
||||
<span className="text-[10px] font-black uppercase tracking-widest text-amber-400">شناسنامه و استانداردهای دارویی</span>
|
||||
</div>
|
||||
<span className="text-[10px] font-mono text-slate-400">صفحه {totalPages}</span>
|
||||
</div>
|
||||
|
||||
<div className="relative z-10 my-auto space-y-5 text-center max-w-sm mx-auto">
|
||||
<div className="w-16 h-16 mx-auto rounded-2xl bg-gradient-to-br from-amber-400 to-amber-500 text-slate-950 flex items-center justify-center font-black text-2xl shadow-xl font-mono">
|
||||
CP
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<h2 className="text-2xl font-black font-lalezar text-white">Canina Pharma GmbH</h2>
|
||||
<p className="text-[10px] text-slate-400 font-mono">Made in Germany • Quality Guarantee</p>
|
||||
</div>
|
||||
|
||||
{/* Credentials Card */}
|
||||
<div className="grid grid-cols-2 gap-3 text-right bg-white/5 border border-white/10 p-4 rounded-xl text-[10px] space-y-1">
|
||||
<div>
|
||||
<span className="text-slate-400 block">کشور سازنده:</span>
|
||||
<span className="font-black text-amber-300 font-mono">Germany (آلمان)</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-slate-400 block">گواهی کیفیت:</span>
|
||||
<span className="font-black text-amber-300 font-mono">GMP & Vet Certified</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-slate-400 block">وبسایت بینالمللی:</span>
|
||||
<span className="font-black text-white font-mono">canina.de</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-slate-400 block">واردکننده انحصاری:</span>
|
||||
<span className="font-black text-white">کانینا فارما ایران</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-center gap-3 text-[10px] text-slate-400">
|
||||
<span className="flex items-center gap-1"><Check className="w-3 h-3 text-emerald-400" /> ۱۰۰٪ طبیعی</span>
|
||||
<span className="flex items-center gap-1"><Check className="w-3 h-3 text-emerald-400" /> بدون افزودنی شیمیایی</span>
|
||||
<span className="flex items-center gap-1"><Check className="w-3 h-3 text-emerald-400" /> بدون تست روی حیوانات</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="relative z-10 border-t border-white/10 pt-3 text-center text-[9px] text-slate-500 font-mono">
|
||||
© 2026 Canina Pharma GmbH. All Rights Reserved.
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 4. DEDICATED 1-PAGE LUXURY PRODUCT PRESENTATION
|
||||
// (صفحه اختصاصی و لوکس هر محصول)
|
||||
// ==========================================
|
||||
if (!product) return null;
|
||||
|
||||
const formBadge = getFormBadge(product.unit, product.name);
|
||||
const speciesBadge = getSpeciesBadge(product.suitableFor);
|
||||
const FormIcon = formBadge.icon;
|
||||
const SpeciesIcon = speciesBadge.icon;
|
||||
const themeColor = categoryMeta?.color || "#0284C7";
|
||||
|
||||
return (
|
||||
<div className="w-full h-full bg-white text-slate-800 p-4 sm:p-5 md:p-6 flex flex-col justify-between select-none box-border overflow-hidden" dir="rtl">
|
||||
|
||||
{/* 1. Header Bar: Category, Species, Form, ArtNo */}
|
||||
<div className="border-b border-slate-100 pb-2.5 flex items-center justify-between gap-2 shrink-0">
|
||||
|
||||
{/* Category Pill */}
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span
|
||||
className="w-2.5 h-2.5 rounded-full shrink-0"
|
||||
style={{ backgroundColor: themeColor }}
|
||||
/>
|
||||
<span className="text-[10px] font-black uppercase tracking-wider text-slate-700 font-vazir">
|
||||
{product.category}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Product Badges */}
|
||||
<div className="flex items-center gap-1.5 text-[9px] font-bold">
|
||||
<span className="bg-slate-100 text-slate-700 px-2 py-0.5 rounded-md flex items-center gap-1 border border-slate-200/60">
|
||||
<SpeciesIcon className="w-3 h-3 text-slate-500" />
|
||||
<span>{speciesBadge.label}</span>
|
||||
</span>
|
||||
<span className="bg-slate-100 text-slate-700 px-2 py-0.5 rounded-md flex items-center gap-1 border border-slate-200/60">
|
||||
<FormIcon className="w-3 h-3 text-slate-500" />
|
||||
<span>{formBadge.label}</span>
|
||||
</span>
|
||||
<span className="bg-blue-50 text-canina-blue font-mono px-2 py-0.5 rounded-md border border-blue-100">
|
||||
Art-Nr: {product.artNo}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 2. Main Body Content (Strictly fitted with flex-1 & min-h-0) */}
|
||||
<div className="flex-1 min-h-0 flex flex-col justify-between py-2 space-y-2">
|
||||
|
||||
{/* Top Product Hero Showcase (Image + Titles + Special Badge) */}
|
||||
<div className="flex items-center gap-3 bg-gradient-to-l from-slate-50 via-white to-slate-50 border border-slate-200/80 rounded-2xl p-2.5 shrink-0">
|
||||
|
||||
{/* Studio Image Box */}
|
||||
<div className="w-24 h-24 sm:w-28 sm:h-28 bg-white rounded-xl border border-slate-100 p-2 flex items-center justify-center shrink-0 relative shadow-2xs">
|
||||
<SafeImage
|
||||
src={product.image}
|
||||
alt={product.name}
|
||||
className="w-full h-full"
|
||||
imgClassName="object-contain max-h-20 sm:max-h-24 filter drop-shadow-md"
|
||||
/>
|
||||
{product.unit && (
|
||||
<span className="absolute bottom-1 right-1 bg-slate-900/90 text-white font-mono text-[8px] font-bold px-1.5 py-0.5 rounded">
|
||||
{product.unit}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Title & Scientific Tagline */}
|
||||
<div className="min-w-0 space-y-1">
|
||||
{product.specialBadge && (
|
||||
<span
|
||||
className="text-[9px] font-black px-2 py-0.5 rounded-full text-white inline-block shadow-2xs"
|
||||
style={{ backgroundColor: themeColor }}
|
||||
>
|
||||
★ {product.specialBadge}
|
||||
</span>
|
||||
)}
|
||||
<h2 className="text-sm sm:text-base font-black text-slate-900 font-vazir leading-tight truncate">
|
||||
{product.name}
|
||||
</h2>
|
||||
{product.scientificTagline && (
|
||||
<p className="text-[10px] text-slate-600 font-bold italic line-clamp-1">
|
||||
{product.scientificTagline}
|
||||
</p>
|
||||
)}
|
||||
<p className="text-[10px] text-slate-500 font-medium line-clamp-2 leading-relaxed">
|
||||
{product.shortDescription || product.description}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Clinical Indications & Symptoms */}
|
||||
{product.symptoms && product.symptoms.length > 0 && (
|
||||
<div className="space-y-1 shrink-0">
|
||||
<span className="text-[9px] font-black text-slate-400 uppercase tracking-widest block">
|
||||
موارد مصرف و نشانههای بالینی:
|
||||
</span>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{product.symptoms.slice(0, 4).map((symptom, i) => (
|
||||
<span
|
||||
key={i}
|
||||
className="bg-red-50/70 text-red-800 border border-red-200/60 rounded-md px-2 py-0.5 text-[9px] font-bold"
|
||||
>
|
||||
• {symptom}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Active Ingredients & Composition Table */}
|
||||
{product.main_ingredients && product.main_ingredients.length > 0 && (
|
||||
<div className="bg-slate-50 border border-slate-200/80 rounded-xl p-2 space-y-1 shrink-0">
|
||||
<div className="flex items-center gap-1 text-[9px] font-black text-canina-blue uppercase">
|
||||
<Layers className="w-3 h-3" />
|
||||
<span>ترکیبات موثره و فرمولاسیون دارویی:</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{product.main_ingredients.slice(0, 5).map((ing, idx) => (
|
||||
<span
|
||||
key={idx}
|
||||
className="bg-white text-slate-800 border border-slate-200 rounded px-1.5 py-0.5 text-[9px] font-bold shadow-3xs"
|
||||
>
|
||||
{ing}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Clinical Dosage Protocol */}
|
||||
{product.dosage_logic && (
|
||||
<div className="bg-amber-50/70 border border-amber-200/70 rounded-xl p-2 space-y-0.5 shrink-0">
|
||||
<div className="flex items-center gap-1 text-amber-900 font-black text-[9px]">
|
||||
<ShieldCheck className="w-3 h-3 text-amber-600" />
|
||||
<span>پروتکل بالینی تجویز و دوز مصرف:</span>
|
||||
</div>
|
||||
<p className="text-[9px] text-amber-950 font-bold leading-relaxed line-clamp-2">
|
||||
{product.dosage_logic}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Specialist Endorsement */}
|
||||
{product.specialist && (
|
||||
<div className="bg-slate-50/80 border border-slate-200/60 rounded-xl p-2 flex items-center gap-2.5 shrink-0">
|
||||
<SafeImage
|
||||
src={product.specialist.image}
|
||||
alt={product.specialist.name}
|
||||
className="w-8 h-8 rounded-full border border-white shadow-xs shrink-0"
|
||||
imgClassName="object-cover"
|
||||
/>
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-1">
|
||||
<Stethoscope className="w-3 h-3 text-canina-blue" />
|
||||
<span className="text-[9px] font-black text-slate-900 truncate">{product.specialist.name}</span>
|
||||
<span className="text-[8px] text-slate-500 truncate font-medium">({product.specialist.title})</span>
|
||||
</div>
|
||||
<p className="text-[8px] text-slate-600 italic truncate mt-0.5">
|
||||
«{product.specialist.message}»
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
|
||||
{/* 3. Page Footer */}
|
||||
<div className="border-t border-slate-100 pt-2 flex items-center justify-between text-[9px] text-slate-400 font-bold shrink-0">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<CheckCircle2 className="w-3 h-3 text-emerald-600" />
|
||||
<span>گرید دارویی GMP آلمان</span>
|
||||
</div>
|
||||
<span className="font-mono">
|
||||
صفحه {pageNumber < 10 ? `۰${pageNumber}` : pageNumber} از {totalPages}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,772 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect, useRef, useMemo } from "react";
|
||||
import CatalogPageSpread, { CategoryMeta } from "./CatalogPageSpread";
|
||||
import { Product } from "../../lib/data/products";
|
||||
import {
|
||||
ChevronRight,
|
||||
ChevronLeft,
|
||||
Printer,
|
||||
Maximize2,
|
||||
Minimize2,
|
||||
BookOpen,
|
||||
Search,
|
||||
Sparkles,
|
||||
Activity,
|
||||
ShieldCheck,
|
||||
Zap,
|
||||
Baby,
|
||||
X
|
||||
} from "lucide-react";
|
||||
|
||||
interface FlipbookCatalogProps {
|
||||
products: Product[];
|
||||
}
|
||||
|
||||
// Normalize Persian / Arabic strings for accurate search
|
||||
const normalizeSearchText = (str: string) => {
|
||||
return (str || "")
|
||||
.toLowerCase()
|
||||
.replace(/ي/g, "ی")
|
||||
.replace(/ك/g, "ک")
|
||||
.replace(/[\u200B-\u200D\uFEFF]/g, "") // zero-width spaces
|
||||
.trim();
|
||||
};
|
||||
|
||||
export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||
|
||||
// 3D Flipping animation state
|
||||
const [isFlipping, setIsFlipping] = useState(false);
|
||||
const [flipDirection, setFlipDirection] = useState<"next" | "prev" | null>(null);
|
||||
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// 1. Build Category Metadata with dynamic starting pages
|
||||
const categoryMetaList: CategoryMeta[] = useMemo(() => {
|
||||
let currentStartPage = 3; // Page 1 = Cover, Page 2 = TOC
|
||||
|
||||
const cats: { id: string; name: string; color: string; lightBg: string; borderBg: string; icon: React.ElementType; tagline: string; filterKey: string }[] = [
|
||||
{
|
||||
id: "joints",
|
||||
name: "مفاصل، استخوان و اسکلت",
|
||||
color: "#0284C7",
|
||||
lightBg: "bg-sky-50",
|
||||
borderBg: "border-sky-200",
|
||||
icon: Activity,
|
||||
tagline: "بازسازی غضروف، هیدروکسی آپاتیت طبیعی و تراکم استخوان",
|
||||
filterKey: "مفاصل و استخوان"
|
||||
},
|
||||
{
|
||||
id: "special-care",
|
||||
name: "پوست، مو و بهداشت تخصصی",
|
||||
color: "#0D9488",
|
||||
lightBg: "bg-teal-50",
|
||||
borderBg: "border-teal-200",
|
||||
icon: Sparkles,
|
||||
tagline: "تکنولوژی نقره میکروسیلور، اسیدهای چرب امگا و ترمیم بیولوژیک",
|
||||
filterKey: "مراقبتهای ویژه (پوست، دندان و چشم)"
|
||||
},
|
||||
{
|
||||
id: "immune",
|
||||
name: "سیستم ایمنی و گوارش",
|
||||
color: "#16A34A",
|
||||
lightBg: "bg-emerald-50",
|
||||
borderBg: "border-emerald-200",
|
||||
icon: ShieldCheck,
|
||||
tagline: "خمیر آغوز متمرکز (Colostrum) و تقویت فوری ایمونوگلوبولینها",
|
||||
filterKey: "تقویت سیستم ایمنی و گوارش"
|
||||
},
|
||||
{
|
||||
id: "vitamins",
|
||||
name: "ویتامینها و انرژیبخشها",
|
||||
color: "#D97706",
|
||||
lightBg: "bg-amber-50",
|
||||
borderBg: "border-amber-200",
|
||||
icon: Zap,
|
||||
tagline: "تامین عناصر کمیاب، هموگلوبین و توان فیزیکی پتها",
|
||||
filterKey: "ویتامینها و انرژیبخشها"
|
||||
},
|
||||
{
|
||||
id: "nutrition",
|
||||
name: "تغذیه تخصصی و رشد تولهها",
|
||||
color: "#8B5CF6",
|
||||
lightBg: "bg-purple-50",
|
||||
borderBg: "border-purple-200",
|
||||
icon: Baby,
|
||||
tagline: "شیرهای جایگزین مادر با پروتئین بالا و فرنیهای تغذیه تکمیلی",
|
||||
filterKey: "تغذیه تخصصی"
|
||||
}
|
||||
];
|
||||
|
||||
return cats.map(cat => {
|
||||
const count = products.filter(p => p.category === cat.filterKey || (cat.id === "vitamins" && p.category === "تقویت عمومی")).length;
|
||||
const meta: CategoryMeta = {
|
||||
...cat,
|
||||
startPage: currentStartPage
|
||||
};
|
||||
currentStartPage += Math.max(count, 1);
|
||||
return meta;
|
||||
});
|
||||
}, [products]);
|
||||
|
||||
// 2. Build Full Ordered List of Product Pages
|
||||
const orderedProducts = useMemo(() => {
|
||||
const list: { product: Product; categoryMeta: CategoryMeta; pageNum: number }[] = [];
|
||||
let pageCounter = 3;
|
||||
|
||||
categoryMetaList.forEach(cat => {
|
||||
const catProds = products.filter(p =>
|
||||
p.category === (cat.id === "joints" ? "مفاصل و استخوان" :
|
||||
cat.id === "special-care" ? "مراقبتهای ویژه (پوست، دندان و چشم)" :
|
||||
cat.id === "immune" ? "تقویت سیستم ایمنی و گوارش" :
|
||||
cat.id === "vitamins" ? (p.category === "ویتامینها و انرژیبخشها" || p.category === "تقویت عمومی") :
|
||||
p.category === "تغذیه تخصصی")
|
||||
);
|
||||
|
||||
catProds.forEach(prod => {
|
||||
list.push({
|
||||
product: prod,
|
||||
categoryMeta: cat,
|
||||
pageNum: pageCounter++
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return list;
|
||||
}, [products, categoryMetaList]);
|
||||
|
||||
// Total pages: Cover (1) + TOC (2) + All Products (N) + Back Cover
|
||||
const TOTAL_PAGES = useMemo(() => {
|
||||
const rawTotal = 2 + orderedProducts.length + 1;
|
||||
return rawTotal % 2 === 0 ? rawTotal : rawTotal + 1;
|
||||
}, [orderedProducts.length]);
|
||||
|
||||
// 3D Page Flip Forward in Persian (Left page turns over to the right!)
|
||||
const handleNext = () => {
|
||||
if (currentPage < TOTAL_PAGES && !isFlipping) {
|
||||
setIsFlipping(true);
|
||||
setFlipDirection("next");
|
||||
|
||||
setTimeout(() => {
|
||||
setCurrentPage(prev => {
|
||||
if (prev === 1) return 2; // From cover (1) to spread (2-3)
|
||||
return Math.min(prev + 2, TOTAL_PAGES);
|
||||
});
|
||||
setIsFlipping(false);
|
||||
setFlipDirection(null);
|
||||
}, 650);
|
||||
}
|
||||
};
|
||||
|
||||
// 3D Page Flip Backward in Persian (Right page turns back over to the left!)
|
||||
const handlePrev = () => {
|
||||
if (currentPage > 1 && !isFlipping) {
|
||||
setIsFlipping(true);
|
||||
setFlipDirection("prev");
|
||||
|
||||
setTimeout(() => {
|
||||
setCurrentPage(prev => {
|
||||
if (prev <= 3) return 1; // Back to cover
|
||||
return Math.max(prev - 2, 1);
|
||||
});
|
||||
setIsFlipping(false);
|
||||
setFlipDirection(null);
|
||||
}, 650);
|
||||
}
|
||||
};
|
||||
|
||||
// Direct Jump
|
||||
const handleJumpToPage = (pageNum: number) => {
|
||||
if (pageNum >= 1 && pageNum <= TOTAL_PAGES) {
|
||||
if (pageNum === 1) {
|
||||
setCurrentPage(1);
|
||||
} else {
|
||||
setCurrentPage(pageNum % 2 === 0 ? pageNum : pageNum - 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Keyboard navigation (RTL: Left Arrow advances forward, Right Arrow goes back)
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
// Don't trigger if focus is on search input
|
||||
if (document.activeElement?.tagName === "INPUT") return;
|
||||
if (e.key === "ArrowLeft") handleNext();
|
||||
if (e.key === "ArrowRight") handlePrev();
|
||||
};
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [currentPage, isFlipping, TOTAL_PAGES]);
|
||||
|
||||
// Enhanced Search with multi-field matching & Persian normalization
|
||||
const searchResults = useMemo(() => {
|
||||
const query = normalizeSearchText(searchQuery);
|
||||
if (!query) return [];
|
||||
|
||||
return orderedProducts.filter(item => {
|
||||
const name = normalizeSearchText(item.product.name);
|
||||
const nameEn = normalizeSearchText(item.product.nameEn || "");
|
||||
const artNo = normalizeSearchText(item.product.artNo);
|
||||
const tagline = normalizeSearchText(item.product.scientificTagline || "");
|
||||
const desc = normalizeSearchText(item.product.description || "");
|
||||
const category = normalizeSearchText(item.product.category || "");
|
||||
const ingredients = item.product.main_ingredients?.map(normalizeSearchText).join(" ") || "";
|
||||
const symptoms = item.product.symptoms?.map(normalizeSearchText).join(" ") || "";
|
||||
|
||||
return name.includes(query) ||
|
||||
nameEn.includes(query) ||
|
||||
artNo.includes(query) ||
|
||||
tagline.includes(query) ||
|
||||
desc.includes(query) ||
|
||||
category.includes(query) ||
|
||||
ingredients.includes(query) ||
|
||||
symptoms.includes(query);
|
||||
});
|
||||
}, [searchQuery, orderedProducts]);
|
||||
|
||||
const toggleFullscreen = () => {
|
||||
if (!containerRef.current) return;
|
||||
if (!document.fullscreenElement) {
|
||||
containerRef.current.requestFullscreen().catch(err => console.error(err));
|
||||
setIsFullscreen(true);
|
||||
} else {
|
||||
document.exitFullscreen().catch(err => console.error(err));
|
||||
setIsFullscreen(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handlePrint = () => {
|
||||
window.print();
|
||||
};
|
||||
|
||||
// Helper to render a specific page number content for on-screen viewing
|
||||
const renderSinglePage = (pageNum: number) => {
|
||||
if (pageNum < 1 || pageNum > TOTAL_PAGES) {
|
||||
return (
|
||||
<div className="w-full h-full bg-slate-900 flex items-center justify-center text-slate-700 select-none">
|
||||
<Sparkles className="w-8 h-8 opacity-20" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (pageNum === 1) {
|
||||
return <CatalogPageSpread pageNumber={1} totalPages={TOTAL_PAGES} pageType="cover" />;
|
||||
}
|
||||
|
||||
if (pageNum === 2) {
|
||||
return (
|
||||
<CatalogPageSpread
|
||||
pageNumber={2}
|
||||
totalPages={TOTAL_PAGES}
|
||||
pageType="toc"
|
||||
categoriesList={categoryMetaList}
|
||||
onJumpToPage={handleJumpToPage}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (pageNum === TOTAL_PAGES) {
|
||||
return <CatalogPageSpread pageNumber={TOTAL_PAGES} totalPages={TOTAL_PAGES} pageType="backcover" />;
|
||||
}
|
||||
|
||||
// Product pages: pageNum 3 corresponds to index 0 of orderedProducts
|
||||
const productItem = orderedProducts[pageNum - 3];
|
||||
if (productItem) {
|
||||
return (
|
||||
<CatalogPageSpread
|
||||
pageNumber={pageNum}
|
||||
totalPages={TOTAL_PAGES}
|
||||
pageType="product"
|
||||
categoryMeta={productItem.categoryMeta}
|
||||
product={productItem.product}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return <CatalogPageSpread pageNumber={pageNum} totalPages={TOTAL_PAGES} pageType="backcover" />;
|
||||
};
|
||||
|
||||
// Current page numbers on spread
|
||||
const rightPageNum = currentPage === 1 ? 1 : currentPage;
|
||||
const leftPageNum = currentPage === 1 ? 0 : currentPage + 1;
|
||||
|
||||
// Next spread page numbers (for upcoming pages during forward flip)
|
||||
const nextRightPageNum = currentPage === 1 ? 2 : currentPage + 2;
|
||||
const nextLeftPageNum = currentPage === 1 ? 3 : currentPage + 3;
|
||||
|
||||
// Prev spread page numbers (for upcoming pages during backward flip)
|
||||
const prevRightPageNum = currentPage <= 3 ? 1 : currentPage - 2;
|
||||
const prevLeftPageNum = currentPage <= 3 ? 0 : currentPage - 1;
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className={`w-full bg-slate-950 font-vazir text-slate-100 flex flex-col justify-between select-none print:bg-white print:p-0 print:m-0 print:h-auto ${
|
||||
isFullscreen
|
||||
? "h-screen p-3"
|
||||
: "h-[calc(100vh-140px)] min-h-[580px] max-h-[880px] py-2 px-3 sm:px-6"
|
||||
}`}
|
||||
dir="rtl"
|
||||
>
|
||||
{/* ========================================================================= */}
|
||||
{/* 1. TOP TOOLBAR (Controls, Search, Print, Fullscreen) - Fixed Height */}
|
||||
{/* ========================================================================= */}
|
||||
<div className="max-w-6xl w-full mx-auto h-14 shrink-0 bg-slate-900/95 border border-slate-800 backdrop-blur-xl rounded-2xl px-3 sm:px-4 flex items-center justify-between gap-3 shadow-xl z-30 print:hidden">
|
||||
|
||||
{/* Brand Title Badge */}
|
||||
<div className="flex items-center gap-2.5 shrink-0">
|
||||
<div className="w-8 h-8 rounded-xl bg-gradient-to-br from-amber-400 to-amber-500 text-slate-950 flex items-center justify-center font-black shadow-md font-mono text-xs">
|
||||
CP
|
||||
</div>
|
||||
<div className="hidden sm:block">
|
||||
<h1 className="text-xs sm:text-sm font-black text-white font-lalezar leading-tight">
|
||||
کاتالوگ دیجیتال Canina Pharma
|
||||
</h1>
|
||||
<span className="text-[9px] text-amber-300 font-bold block">
|
||||
شبیهساز ۳D ورقزن کتاب دارویی • ۳۰ صفحه اختصاصی A4
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Quick Search with Instant Jump & Dropdown */}
|
||||
<div className="relative flex-1 max-w-xs md:max-w-sm mx-2">
|
||||
<Search className="absolute right-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-slate-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجوی نام مکمل، کد کالا، ترکیبات..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && searchResults.length > 0) {
|
||||
handleJumpToPage(searchResults[0].pageNum);
|
||||
setSearchQuery("");
|
||||
}
|
||||
}}
|
||||
className="w-full bg-slate-950 border border-slate-800 rounded-xl py-1.5 pr-8 pl-7 text-[11px] font-bold text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-amber-400/40"
|
||||
/>
|
||||
{searchQuery && (
|
||||
<button
|
||||
onClick={() => setSearchQuery("")}
|
||||
className="absolute left-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-white"
|
||||
>
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* Search Dropdown Results */}
|
||||
{searchQuery && (
|
||||
<div className="absolute top-full mt-1.5 right-0 w-full bg-slate-900 border border-slate-700 rounded-xl shadow-2xl p-2 z-50 max-h-60 overflow-y-auto space-y-1">
|
||||
{searchResults.length === 0 ? (
|
||||
<div className="text-center py-3 text-xs text-slate-400 font-bold">
|
||||
محصولی با عبارت «{searchQuery}» یافت نشد.
|
||||
</div>
|
||||
) : (
|
||||
searchResults.map(item => (
|
||||
<div
|
||||
key={item.product.id}
|
||||
onClick={() => {
|
||||
handleJumpToPage(item.pageNum);
|
||||
setSearchQuery("");
|
||||
}}
|
||||
className="p-1.5 hover:bg-slate-800 rounded-lg flex items-center justify-between cursor-pointer group transition-colors"
|
||||
>
|
||||
<div className="min-w-0 pr-1">
|
||||
<span className="text-xs font-black text-white group-hover:text-amber-300 block truncate font-vazir">
|
||||
{item.product.name}
|
||||
</span>
|
||||
<div className="flex items-center gap-2 text-[10px] text-slate-400 font-mono">
|
||||
<span>کد: {item.product.artNo}</span>
|
||||
<span>•</span>
|
||||
<span className="text-slate-300">{item.product.category}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span className="text-[10px] font-black bg-amber-400 text-slate-950 px-2 py-0.5 rounded-md shrink-0 font-mono shadow-xs">
|
||||
صفحه {item.pageNum}
|
||||
</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
<button
|
||||
onClick={handlePrint}
|
||||
className="bg-amber-400 hover:bg-amber-500 text-slate-950 font-black px-3 py-1.5 rounded-xl shadow-md transition-all flex items-center gap-1.5 text-xs cursor-pointer hover:scale-105 active:scale-95"
|
||||
title="دانلود یا چاپ نسخه کامل PDF کاتالوگ (تمامی محصولات)"
|
||||
>
|
||||
<Printer className="w-3.5 h-3.5" />
|
||||
<span className="hidden sm:inline">چاپ / دانلود کامل PDF</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={toggleFullscreen}
|
||||
className="bg-slate-800 hover:bg-slate-700 text-white font-bold p-1.5 rounded-xl transition-all cursor-pointer border border-slate-700 hover:scale-105"
|
||||
title="تمام صفحه"
|
||||
>
|
||||
{isFullscreen ? <Minimize2 className="w-4 h-4" /> : <Maximize2 className="w-4 h-4" />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ========================================================================= */}
|
||||
{/* 2. MAIN 3D FLIPBOOK STAGE (Auto-scaled within available height) */}
|
||||
{/* ========================================================================= */}
|
||||
<div className="max-w-6xl w-full mx-auto flex-1 min-h-0 flex items-center justify-center relative my-auto py-2 print:hidden overflow-hidden">
|
||||
|
||||
{/* Navigation Arrow - Previous (Right side in RTL: flips back to earlier pages) */}
|
||||
<button
|
||||
onClick={handlePrev}
|
||||
disabled={currentPage <= 1 || isFlipping}
|
||||
className={`absolute right-1 md:right-2 z-40 w-10 h-10 md:w-12 md:h-12 rounded-full bg-slate-900/90 hover:bg-amber-400 hover:text-slate-950 border border-slate-700 text-white flex items-center justify-center shadow-2xl transition-all cursor-pointer disabled:opacity-20 disabled:pointer-events-none hover:scale-110 active:scale-95 ${
|
||||
currentPage <= 1 ? "hidden" : ""
|
||||
}`}
|
||||
aria-label="صفحه قبلی"
|
||||
>
|
||||
<ChevronRight className="w-5 h-5 md:w-6 md:h-6" />
|
||||
</button>
|
||||
|
||||
{/* 3D Book Stage Container */}
|
||||
<div className="w-full h-full flex items-center justify-center perspective-[2500px]">
|
||||
|
||||
{/* Desktop 3D Double Spread Book (Strict A4 Aspect Ratio & Height Bound) */}
|
||||
<div
|
||||
style={{
|
||||
direction: "ltr",
|
||||
aspectRatio: "1.414 / 1"
|
||||
}}
|
||||
className="hidden md:flex h-full max-h-full max-w-full bg-[#0a121e] rounded-3xl shadow-[0_25px_60px_-15px_rgba(0,0,0,0.9)] border border-slate-800/80 relative select-none"
|
||||
>
|
||||
{/* Center Spine Depth & Crease */}
|
||||
<div className="absolute left-1/2 top-0 bottom-0 w-8 -translate-x-1/2 bg-gradient-to-r from-black/40 via-black/80 to-black/40 z-30 pointer-events-none shadow-inner" />
|
||||
<div className="absolute left-1/2 top-0 bottom-0 w-[1px] -translate-x-1/2 bg-amber-400/20 z-30 pointer-events-none" />
|
||||
|
||||
{/* LEFT HALF OF SCREEN (Physical Left Page) */}
|
||||
<div
|
||||
onClick={() => handleNext()}
|
||||
className="w-1/2 h-full bg-white rounded-l-3xl overflow-hidden relative cursor-pointer group shadow-2xl border-l border-slate-800"
|
||||
style={{ direction: "rtl" }}
|
||||
>
|
||||
{currentPage === 1 ? (
|
||||
// Inside Front Flyleaf when on Cover
|
||||
<div className="w-full h-full bg-gradient-to-br from-[#071324] to-[#040d1a] p-6 text-white flex flex-col justify-between select-none" dir="rtl">
|
||||
<div className="border-b border-white/10 pb-3 flex justify-between items-center text-[10px] text-slate-400 font-mono">
|
||||
<span>CANINA PHARMA GERMANY</span>
|
||||
<span>EST. 1984</span>
|
||||
</div>
|
||||
<div className="text-center space-y-3 max-w-xs mx-auto">
|
||||
<div className="w-12 h-12 mx-auto rounded-2xl bg-amber-400/10 border border-amber-400/30 text-amber-400 flex items-center justify-center font-black text-lg font-mono shadow-inner">
|
||||
CP
|
||||
</div>
|
||||
<h3 className="text-base font-black font-lalezar text-white">
|
||||
کاتالوگ تخصصی کانینا آلمان
|
||||
</h3>
|
||||
<p className="text-[11px] text-slate-400 leading-relaxed font-medium">
|
||||
جهت باز کردن کاتالوگ و شروع مطالعه، روی صفحه چپ یا کلید ← کیبورد را بزنید.
|
||||
</p>
|
||||
</div>
|
||||
<div className="border-t border-white/10 pt-3 text-center text-[9px] text-slate-500 font-mono">
|
||||
Official Veterinary Guide 2026
|
||||
</div>
|
||||
</div>
|
||||
) : isFlipping && flipDirection === "next" ? (
|
||||
// Underneath left page during next flip (shows upcoming left page)
|
||||
renderSinglePage(nextLeftPageNum)
|
||||
) : (
|
||||
renderSinglePage(leftPageNum)
|
||||
)}
|
||||
|
||||
{/* Dynamic Spine Curvature Shadow */}
|
||||
<div className="absolute right-0 top-0 bottom-0 w-10 bg-gradient-to-l from-black/25 via-black/10 to-transparent pointer-events-none z-20" />
|
||||
|
||||
{/* Corner Curl Hover Hint */}
|
||||
<div className="absolute bottom-0 left-0 w-12 h-12 bg-gradient-to-tr from-slate-400/40 via-slate-300/20 to-transparent opacity-0 group-hover:opacity-100 transition-all pointer-events-none rounded-tr-3xl" />
|
||||
</div>
|
||||
|
||||
{/* RIGHT HALF OF SCREEN (Physical Right Page) */}
|
||||
<div
|
||||
onClick={() => handlePrev()}
|
||||
className="w-1/2 h-full bg-white rounded-r-3xl overflow-hidden relative cursor-pointer group shadow-2xl border-r border-slate-800"
|
||||
style={{ direction: "rtl" }}
|
||||
>
|
||||
{isFlipping && flipDirection === "prev" ? (
|
||||
// Underneath right page during prev flip
|
||||
renderSinglePage(prevRightPageNum)
|
||||
) : (
|
||||
renderSinglePage(rightPageNum)
|
||||
)}
|
||||
|
||||
{/* Dynamic Spine Curvature Shadow */}
|
||||
<div className="absolute left-0 top-0 bottom-0 w-10 bg-gradient-to-r from-black/25 via-black/10 to-transparent pointer-events-none z-20" />
|
||||
|
||||
{/* Corner Curl Hover Hint */}
|
||||
<div className="absolute bottom-0 right-0 w-12 h-12 bg-gradient-to-tl from-slate-400/40 via-slate-300/20 to-transparent opacity-0 group-hover:opacity-100 transition-all pointer-events-none rounded-tl-3xl" />
|
||||
</div>
|
||||
|
||||
{/* 3D FLIPPING LEAF (NEXT / FORWARD: LEFT PAGE FLIPS OVER THE SPINE TO THE RIGHT!) */}
|
||||
{isFlipping && flipDirection === "next" && (
|
||||
<div
|
||||
className="absolute left-0 top-0 w-1/2 h-full z-40 origin-right"
|
||||
style={{
|
||||
transformStyle: "preserve-3d",
|
||||
animation: "flipLeftToRight 650ms cubic-bezier(0.645, 0.045, 0.355, 1.000) forwards"
|
||||
}}
|
||||
>
|
||||
{/* Front Face (Current Left Page turning to the right) */}
|
||||
<div
|
||||
className="absolute inset-0 bg-white rounded-l-3xl overflow-hidden shadow-2xl"
|
||||
style={{ direction: "rtl", backfaceVisibility: "hidden" }}
|
||||
>
|
||||
{currentPage === 1 ? (
|
||||
<div className="w-full h-full bg-gradient-to-br from-[#071324] to-[#040d1a] p-6 text-white flex flex-col justify-between select-none">
|
||||
<div className="border-b border-white/10 pb-3 text-xs font-mono">CANINA PHARMA</div>
|
||||
<div className="text-center font-black font-lalezar text-base text-white">Canina Germany</div>
|
||||
<div className="text-[10px] text-slate-500 font-mono">2026</div>
|
||||
</div>
|
||||
) : (
|
||||
renderSinglePage(leftPageNum)
|
||||
)}
|
||||
{/* Dynamic Light Shadow during rotation */}
|
||||
<div className="absolute inset-0 bg-gradient-to-l from-black/50 via-black/20 to-transparent pointer-events-none" />
|
||||
</div>
|
||||
|
||||
{/* Back Face (Upcoming Right Page landing on the right) */}
|
||||
<div
|
||||
className="absolute inset-0 bg-white rounded-r-3xl overflow-hidden shadow-2xl"
|
||||
style={{
|
||||
direction: "rtl",
|
||||
transform: "rotateY(180deg)",
|
||||
backfaceVisibility: "hidden"
|
||||
}}
|
||||
>
|
||||
{renderSinglePage(nextRightPageNum)}
|
||||
{/* Dynamic Light Shadow during landing */}
|
||||
<div className="absolute inset-0 bg-gradient-to-r from-black/50 via-black/20 to-transparent pointer-events-none" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 3D FLIPPING LEAF (PREV / BACKWARD: RIGHT PAGE FLIPS OVER THE SPINE TO THE LEFT!) */}
|
||||
{isFlipping && flipDirection === "prev" && (
|
||||
<div
|
||||
className="absolute right-0 top-0 w-1/2 h-full z-40 origin-left"
|
||||
style={{
|
||||
transformStyle: "preserve-3d",
|
||||
animation: "flipRightToLeft 650ms cubic-bezier(0.645, 0.045, 0.355, 1.000) forwards"
|
||||
}}
|
||||
>
|
||||
{/* Front Face (Current Right Page turning back to the left) */}
|
||||
<div
|
||||
className="absolute inset-0 bg-white rounded-r-3xl overflow-hidden shadow-2xl"
|
||||
style={{ direction: "rtl", backfaceVisibility: "hidden" }}
|
||||
>
|
||||
{renderSinglePage(rightPageNum)}
|
||||
<div className="absolute inset-0 bg-gradient-to-r from-black/50 via-black/20 to-transparent pointer-events-none" />
|
||||
</div>
|
||||
|
||||
{/* Back Face (Previous Left Page landing on the left) */}
|
||||
<div
|
||||
className="absolute inset-0 bg-white rounded-l-3xl overflow-hidden shadow-2xl"
|
||||
style={{
|
||||
direction: "rtl",
|
||||
transform: "rotateY(180deg)",
|
||||
backfaceVisibility: "hidden"
|
||||
}}
|
||||
>
|
||||
{renderSinglePage(prevLeftPageNum === 0 ? 1 : prevLeftPageNum)}
|
||||
<div className="absolute inset-0 bg-gradient-to-l from-black/50 via-black/20 to-transparent pointer-events-none" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
|
||||
{/* Mobile Single Page View with 3D Flip */}
|
||||
<div
|
||||
style={{
|
||||
aspectRatio: "1 / 1.414"
|
||||
}}
|
||||
className="flex md:hidden h-full max-h-full max-w-full bg-white rounded-2xl shadow-2xl overflow-hidden border border-slate-800 relative"
|
||||
>
|
||||
<div
|
||||
onClick={() => handleNext()}
|
||||
className="w-full h-full"
|
||||
>
|
||||
{renderSinglePage(currentPage)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{/* Navigation Arrow - Next (Left side in RTL: flips forward) */}
|
||||
<button
|
||||
onClick={handleNext}
|
||||
disabled={currentPage >= TOTAL_PAGES || isFlipping}
|
||||
className={`absolute left-1 md:left-2 z-40 w-10 h-10 md:w-12 md:h-12 rounded-full bg-slate-900/90 hover:bg-amber-400 hover:text-slate-950 border border-slate-700 text-white flex items-center justify-center shadow-2xl transition-all cursor-pointer disabled:opacity-20 disabled:pointer-events-none hover:scale-110 active:scale-95 ${
|
||||
currentPage >= TOTAL_PAGES ? "hidden" : ""
|
||||
}`}
|
||||
aria-label="صفحه بعدی"
|
||||
>
|
||||
<ChevronLeft className="w-5 h-5 md:w-6 md:h-6" />
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
{/* ========================================================================= */}
|
||||
{/* 3. BOTTOM SLIDER & CATEGORY JUMP BAR - Fixed Height */}
|
||||
{/* ========================================================================= */}
|
||||
<div className="max-w-4xl w-full mx-auto h-14 shrink-0 bg-slate-900/95 border border-slate-800 backdrop-blur-xl rounded-2xl px-3 sm:px-4 flex items-center justify-between gap-3 shadow-xl z-30 print:hidden">
|
||||
|
||||
{/* Page Slider */}
|
||||
<div className="flex items-center gap-2.5 flex-1 max-w-xs sm:max-w-sm">
|
||||
<span className="text-[11px] font-black text-amber-300 shrink-0 font-mono">
|
||||
{currentPage === 1 ? "جلد ۱" : `صفحه ${currentPage}-${Math.min(currentPage + 1, TOTAL_PAGES)}`}
|
||||
</span>
|
||||
|
||||
<input
|
||||
type="range"
|
||||
min="1"
|
||||
max={TOTAL_PAGES}
|
||||
step="1"
|
||||
value={currentPage}
|
||||
onChange={(e) => handleJumpToPage(parseInt(e.target.value))}
|
||||
className="w-full h-1.5 bg-slate-800 rounded-lg appearance-none cursor-pointer accent-amber-400"
|
||||
/>
|
||||
|
||||
<span className="text-[11px] font-bold text-slate-400 shrink-0 font-mono">
|
||||
/{TOTAL_PAGES}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Category Jump Pills */}
|
||||
<div className="flex items-center gap-1.5 overflow-x-auto max-w-full py-0.5">
|
||||
<button
|
||||
onClick={() => handleJumpToPage(1)}
|
||||
className="px-2 py-1 rounded-lg text-[10px] font-black bg-slate-800 text-white hover:bg-slate-700 transition-all shrink-0 cursor-pointer"
|
||||
>
|
||||
جلد
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleJumpToPage(2)}
|
||||
className="px-2 py-1 rounded-lg text-[10px] font-black bg-slate-800 text-white hover:bg-slate-700 transition-all shrink-0 cursor-pointer"
|
||||
>
|
||||
فهرست
|
||||
</button>
|
||||
{categoryMetaList.map((cat) => (
|
||||
<button
|
||||
key={cat.id}
|
||||
onClick={() => handleJumpToPage(cat.startPage)}
|
||||
className="px-2 py-1 rounded-lg text-[10px] font-black text-white transition-all shrink-0 hover:scale-105 cursor-pointer shadow-xs"
|
||||
style={{ backgroundColor: cat.color }}
|
||||
>
|
||||
{cat.name.split(" ")[0]}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{/* ========================================================================= */}
|
||||
{/* 4. COMPLETE PRINT-ONLY A4 MULTI-PAGE DOCUMENT (Export ALL products to PDF) */}
|
||||
{/* ========================================================================= */}
|
||||
<div className="hidden print:block w-full text-slate-900 bg-white" dir="rtl">
|
||||
{/* Page 1: Cover */}
|
||||
<div className="print-a4-page">
|
||||
<CatalogPageSpread pageNumber={1} totalPages={TOTAL_PAGES} pageType="cover" />
|
||||
</div>
|
||||
|
||||
{/* Page 2: Table of Contents */}
|
||||
<div className="print-a4-page">
|
||||
<CatalogPageSpread
|
||||
pageNumber={2}
|
||||
totalPages={TOTAL_PAGES}
|
||||
pageType="toc"
|
||||
categoriesList={categoryMetaList}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Pages 3 to N: All Dedicated Product Pages in Order */}
|
||||
{orderedProducts.map((item) => (
|
||||
<div key={item.product.id} className="print-a4-page">
|
||||
<CatalogPageSpread
|
||||
pageNumber={item.pageNum}
|
||||
totalPages={TOTAL_PAGES}
|
||||
pageType="product"
|
||||
categoryMeta={item.categoryMeta}
|
||||
product={item.product}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Final Page: Back Cover */}
|
||||
<div className="print-a4-page">
|
||||
<CatalogPageSpread pageNumber={TOTAL_PAGES} totalPages={TOTAL_PAGES} pageType="backcover" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 3D Keyframe CSS Animations & Print Stylesheet */}
|
||||
<style jsx global>{`
|
||||
@keyframes flipLeftToRight {
|
||||
0% {
|
||||
transform: rotateY(0deg);
|
||||
box-shadow: 5px 0 25px rgba(0,0,0,0.3);
|
||||
}
|
||||
50% {
|
||||
transform: rotateY(90deg) scale(1.03);
|
||||
box-shadow: 20px 0 50px rgba(0,0,0,0.6);
|
||||
}
|
||||
100% {
|
||||
transform: rotateY(180deg) scale(1);
|
||||
box-shadow: -5px 0 25px rgba(0,0,0,0.3);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes flipRightToLeft {
|
||||
0% {
|
||||
transform: rotateY(0deg);
|
||||
box-shadow: -5px 0 25px rgba(0,0,0,0.3);
|
||||
}
|
||||
50% {
|
||||
transform: rotateY(-90deg) scale(1.03);
|
||||
box-shadow: -20px 0 50px rgba(0,0,0,0.6);
|
||||
}
|
||||
100% {
|
||||
transform: rotateY(-180deg) scale(1);
|
||||
box-shadow: 5px 0 25px rgba(0,0,0,0.3);
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
size: A4 portrait;
|
||||
margin: 0;
|
||||
}
|
||||
html, body {
|
||||
background: #ffffff !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
color: #000000 !important;
|
||||
}
|
||||
.print-a4-page {
|
||||
page-break-after: always !important;
|
||||
break-after: page !important;
|
||||
width: 210mm !important;
|
||||
height: 297mm !important;
|
||||
max-height: 297mm !important;
|
||||
overflow: hidden !important;
|
||||
box-sizing: border-box !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
`}</style>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import SafeImage from "../SafeImage";
|
||||
import { Product } from "../../lib/data/products";
|
||||
import { X, ShieldCheck, CheckCircle2, Award, Stethoscope, Sparkles, Layers, Info } from "lucide-react";
|
||||
|
||||
interface ProductDetailModalProps {
|
||||
product: Product | null;
|
||||
categoryColor?: string;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export default function ProductDetailModal({ product, categoryColor = "#0284C7", onClose }: ProductDetailModalProps) {
|
||||
if (!product) return null;
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/70 backdrop-blur-md animate-fadeIn" dir="rtl">
|
||||
<div
|
||||
className="bg-white w-full max-w-3xl max-h-[90vh] rounded-3xl shadow-2xl overflow-hidden flex flex-col border border-slate-200 relative animate-scaleUp"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* Modal Header */}
|
||||
<div
|
||||
className="p-6 text-white flex items-start justify-between relative overflow-hidden"
|
||||
style={{ backgroundColor: categoryColor }}
|
||||
>
|
||||
<div className="absolute -left-10 -bottom-10 w-40 h-40 bg-white/10 rounded-full blur-2xl pointer-events-none" />
|
||||
|
||||
<div className="relative z-10 space-y-1">
|
||||
<div className="flex items-center gap-2 text-xs font-bold bg-white/15 px-3 py-1 rounded-full w-fit backdrop-blur-sm border border-white/20">
|
||||
<Sparkles className="w-3.5 h-3.5" />
|
||||
<span>{product.category}</span>
|
||||
<span className="opacity-60">•</span>
|
||||
<span>کد کالا: {product.artNo}</span>
|
||||
</div>
|
||||
<h2 className="text-2xl md:text-3xl font-black font-lalezar mt-2 leading-tight">
|
||||
{product.name}
|
||||
</h2>
|
||||
{product.scientificTagline && (
|
||||
<p className="text-xs md:text-sm text-white/90 font-medium">
|
||||
{product.scientificTagline}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="p-2.5 rounded-full bg-white/10 hover:bg-white/20 text-white transition-colors relative z-10 cursor-pointer"
|
||||
aria-label="بستن"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Modal Content Scrollable Area */}
|
||||
<div className="p-6 md:p-8 overflow-y-auto space-y-6 sleek-scrollbar text-slate-800">
|
||||
|
||||
{/* Image & Key Attributes Grid */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-12 gap-6 items-center">
|
||||
<div className="md:col-span-5 bg-slate-50 border border-slate-200/80 rounded-2xl p-6 flex items-center justify-center aspect-square relative shadow-xs">
|
||||
<SafeImage
|
||||
src={product.image}
|
||||
alt={product.name}
|
||||
className="w-full h-full"
|
||||
imgClassName="object-contain max-h-52"
|
||||
/>
|
||||
<div className="absolute bottom-3 right-3 bg-white/90 backdrop-blur-sm text-slate-700 text-[11px] font-black px-3 py-1 rounded-lg border border-slate-200/60 shadow-2xs">
|
||||
وزن/حجم: {product.unit}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="md:col-span-7 space-y-4">
|
||||
<div className="space-y-2">
|
||||
<span className="text-xs font-black text-slate-400 uppercase tracking-widest block">
|
||||
شرح بالینی و عملکرد:
|
||||
</span>
|
||||
<p className="text-sm text-slate-600 leading-relaxed font-medium">
|
||||
{product.description}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Species & Dosage badges */}
|
||||
<div className="flex flex-wrap gap-2 pt-2">
|
||||
<div className="bg-slate-100 border border-slate-200 rounded-xl px-3 py-1.5 text-xs font-bold text-slate-700 flex items-center gap-1.5">
|
||||
<Award className="w-4 h-4 text-canina-blue" />
|
||||
<span>مناسب: {product.suitableFor}</span>
|
||||
</div>
|
||||
<div className="bg-slate-100 border border-slate-200 rounded-xl px-3 py-1.5 text-xs font-bold text-slate-700 flex items-center gap-1.5">
|
||||
<CheckCircle2 className="w-4 h-4 text-emerald-600" />
|
||||
<span>گرید دارویی آلمان</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Active Ingredients Section */}
|
||||
{product.main_ingredients && product.main_ingredients.length > 0 && (
|
||||
<div className="bg-blue-50/50 border border-blue-100 rounded-2xl p-5 space-y-3">
|
||||
<div className="flex items-center gap-2 text-canina-blue font-black text-xs">
|
||||
<Layers className="w-4 h-4" />
|
||||
<span>ترکیبات فعال و مواد موثره دارویی:</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{product.main_ingredients.map((ingredient, idx) => (
|
||||
<span
|
||||
key={idx}
|
||||
className="bg-white text-slate-800 border border-blue-200 rounded-xl px-3 py-1.5 text-xs font-bold shadow-2xs"
|
||||
>
|
||||
{ingredient}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Clinical Dosage Section */}
|
||||
{product.dosage_logic && (
|
||||
<div className="bg-amber-50/80 border border-amber-200/80 rounded-2xl p-5 space-y-2">
|
||||
<div className="flex items-center gap-2 text-amber-900 font-black text-xs">
|
||||
<ShieldCheck className="w-4.5 h-4.5 text-amber-600" />
|
||||
<span>دستور مصرف بالینی و دوز توصیه شده:</span>
|
||||
</div>
|
||||
<p className="text-xs md:text-sm text-amber-900 leading-relaxed font-bold">
|
||||
{product.dosage_logic}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Specialist Note */}
|
||||
{product.specialist && (
|
||||
<div className="bg-slate-50 border border-slate-200 rounded-2xl p-5 flex items-start gap-4">
|
||||
<SafeImage
|
||||
src={product.specialist.image}
|
||||
alt={product.specialist.name}
|
||||
className="w-12 h-12 rounded-full border-2 border-white shadow-xs shrink-0"
|
||||
imgClassName="object-cover"
|
||||
/>
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<Stethoscope className="w-4 h-4 text-canina-blue" />
|
||||
<span className="text-xs font-black text-slate-900">{product.specialist.name}</span>
|
||||
<span className="text-[11px] text-slate-500 font-medium">({product.specialist.title})</span>
|
||||
</div>
|
||||
<p className="text-xs text-slate-600 italic leading-relaxed">
|
||||
«{product.specialist.message}»
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
|
||||
{/* Modal Footer */}
|
||||
<div className="p-4 bg-slate-50 border-t border-slate-200 flex items-center justify-between">
|
||||
<div className="flex items-center gap-2 text-xs text-slate-500 font-bold">
|
||||
<Info className="w-4 h-4 text-slate-400" />
|
||||
<span>راهنمای کاتالوگ رسمی دارویی Canina Pharma Germany</span>
|
||||
</div>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="px-6 py-2.5 bg-slate-900 text-white rounded-xl text-xs font-black hover:bg-slate-800 transition-colors cursor-pointer"
|
||||
>
|
||||
بستن جزئیات
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user