merge: resolve merge conflicts in ArchivePage.tsx and graphify-out from develop
This commit is contained in:
commit
753b3dd7ec
48 files changed
+240706
-94210
No files matched your search
@@ -295,51 +295,40 @@ export default function ArchivePage({
|
||||
return labels;
|
||||
}, [categories]);
|
||||
|
||||
// Sync state with prop change (e.g. from Header menu / Direct navigation)
|
||||
const prevInitialRef = React.useRef({ category: initialCategory, search: initialSearch });
|
||||
const lastInitialPropsRef = React.useRef({ initialCategory, initialSearch, initialPetType, initialSymptoms });
|
||||
|
||||
// Sync state when incoming initial props change from navigation
|
||||
useEffect(() => {
|
||||
if (prevInitialRef.current.category === initialCategory && prevInitialRef.current.search === initialSearch) {
|
||||
const isNewCategory = lastInitialPropsRef.current.initialCategory !== initialCategory;
|
||||
const isNewSearch = lastInitialPropsRef.current.initialSearch !== initialSearch;
|
||||
const isNewPet = lastInitialPropsRef.current.initialPetType !== initialPetType;
|
||||
const isNewSymptoms = lastInitialPropsRef.current.initialSymptoms !== initialSymptoms;
|
||||
|
||||
if (!isNewCategory && !isNewSearch && !isNewPet && !isNewSymptoms) {
|
||||
return;
|
||||
}
|
||||
prevInitialRef.current = { category: initialCategory, search: initialSearch };
|
||||
|
||||
// Normalize Input (Trim and lowercase)
|
||||
lastInitialPropsRef.current = { initialCategory, initialSearch, initialPetType, initialSymptoms };
|
||||
|
||||
// Normalize Input
|
||||
const normSearch = (initialSearch || "").trim().toLowerCase();
|
||||
const normCat = initialCategory.trim().toLowerCase();
|
||||
|
||||
const normCat = (initialCategory || "").trim().toLowerCase();
|
||||
const mapKey = normSearch || normCat;
|
||||
const mapping = CATEGORY_MAP[mapKey];
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
setIsUpdating(true);
|
||||
|
||||
// Reset other filters when initial URL route prop changes
|
||||
setIsUpdating(true);
|
||||
if (mapping) {
|
||||
setSelectedCategory(mapping.category || "all");
|
||||
setSearchQuery(mapping.query || "");
|
||||
setSelectedPet("all");
|
||||
setActiveSymptoms([]);
|
||||
setSearchQuery("");
|
||||
|
||||
if (mapping) {
|
||||
if (mapping.category) setSelectedCategory(mapping.category);
|
||||
if (mapping.query) setSearchQuery(mapping.query);
|
||||
if (mapping.symptoms) {
|
||||
setActiveSymptoms(mapping.symptoms);
|
||||
}
|
||||
} else {
|
||||
setSelectedCategory(initialCategory);
|
||||
setSearchQuery(initialSearch);
|
||||
|
||||
if (initialSearch && symptoms.includes(initialSearch)) {
|
||||
setActiveSymptoms([initialSearch]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}, 400);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [initialCategory, initialSearch, selectedCategory, searchQuery, symptoms]);
|
||||
setActiveSymptoms(mapping.symptoms || []);
|
||||
} else {
|
||||
setSelectedCategory(initialCategory || "all");
|
||||
setSearchQuery(initialSearch || "");
|
||||
setSelectedPet((initialPetType as PetType) || "all");
|
||||
setActiveSymptoms(initialSymptoms ? initialSymptoms.split(',').filter(Boolean) : []);
|
||||
}
|
||||
}, [initialCategory, initialSearch, initialPetType, initialSymptoms]);
|
||||
|
||||
// Update URL Query Parameters
|
||||
useEffect(() => {
|
||||
|
||||
@@ -369,23 +369,23 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{isOpen && (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4">
|
||||
<div className="fixed inset-0 z-50 flex items-end sm:items-center justify-center p-0 sm:p-4 font-vazir overflow-y-auto" dir="rtl">
|
||||
<motion.div
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
onClick={onClose}
|
||||
className="absolute inset-0 bg-medical-gray-900/60 backdrop-blur-sm"
|
||||
className="fixed inset-0 bg-medical-gray-900/60 backdrop-blur-sm"
|
||||
/>
|
||||
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scale: 0.95, y: 20 }}
|
||||
initial={{ opacity: 0, scale: 0.95, y: 30 }}
|
||||
animate={{ opacity: 1, scale: 1, y: 0 }}
|
||||
exit={{ opacity: 0, scale: 0.95, y: 20 }}
|
||||
className="relative w-full max-w-md bg-white rounded-[2.5rem] shadow-2xl overflow-hidden border border-medical-gray-100 z-10"
|
||||
exit={{ opacity: 0, scale: 0.95, y: 30 }}
|
||||
className="relative w-full max-w-md bg-white rounded-t-[2.5rem] sm:rounded-[2.5rem] shadow-2xl overflow-hidden border border-medical-gray-100 z-10 max-h-[92vh] flex flex-col my-auto pb-safe"
|
||||
>
|
||||
{/* Header */}
|
||||
<div className="p-6 pb-0 flex justify-between items-center">
|
||||
<div className="p-6 pb-0 flex justify-between items-center shrink-0">
|
||||
<div className="flex items-center gap-2 text-canina-blue font-black text-sm">
|
||||
<ShieldCheck className="w-5 h-5" />
|
||||
<span>ورود امن به کنینا</span>
|
||||
@@ -425,6 +425,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
<input
|
||||
autoFocus
|
||||
type="tel"
|
||||
inputMode="numeric"
|
||||
pattern="[0-9]*"
|
||||
maxLength={11}
|
||||
required
|
||||
placeholder="۰۹۱۲۳۴۵۶۷۸۹"
|
||||
@@ -740,6 +742,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
<input
|
||||
autoFocus
|
||||
type="tel"
|
||||
inputMode="numeric"
|
||||
pattern="[0-9]*"
|
||||
maxLength={11}
|
||||
placeholder="مثال: ۰۹۱۲۳۴۵۶۷۸۹"
|
||||
value={phoneNumber}
|
||||
@@ -795,8 +799,9 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
ref={otpInputRef}
|
||||
id="otp-code-input"
|
||||
name="one-time-code"
|
||||
type="text"
|
||||
type="tel"
|
||||
inputMode="numeric"
|
||||
pattern="[0-9]*"
|
||||
autoComplete="one-time-code"
|
||||
placeholder="کد ۵ رقمی"
|
||||
value={otpCode}
|
||||
|
||||
@@ -270,6 +270,10 @@ export default function BlogPage({
|
||||
<Clock className="w-3.5 h-3.5" />
|
||||
{featuredPost.readingTime || 4} دقیقه مطالعه
|
||||
</div>
|
||||
<div className="flex items-center gap-1 text-medical-gray-400">
|
||||
<Eye className="w-3.5 h-3.5" />
|
||||
<span>{(featuredPost.viewCount ?? 0).toLocaleString('fa-IR')} بازدید</span>
|
||||
</div>
|
||||
</div>
|
||||
<h2 className="text-2xl sm:text-3xl lg:text-4xl font-black text-medical-gray-900 mb-5 leading-tight group-hover:text-canina-blue transition-colors">
|
||||
{featuredPost.title}
|
||||
@@ -324,6 +328,11 @@ export default function BlogPage({
|
||||
{post.category}
|
||||
</span>
|
||||
)}
|
||||
{/* View Count Badge */}
|
||||
<span className="absolute top-3 left-3 px-2.5 py-1 bg-black/60 backdrop-blur-md text-white rounded-lg text-[10px] font-bold z-10 flex items-center gap-1">
|
||||
<Eye className="w-3 h-3 text-canina-blue" />
|
||||
<span>{(post.viewCount ?? 0).toLocaleString('fa-IR')}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="p-6 sm:p-7">
|
||||
<div className="flex items-center justify-between text-[11px] font-bold text-medical-gray-400 mb-3">
|
||||
@@ -331,9 +340,15 @@ export default function BlogPage({
|
||||
<Calendar className="w-3 h-3" />
|
||||
{post.date}
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="w-3 h-3" />
|
||||
{post.readingTime || 3} دقیقه
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="w-3 h-3" />
|
||||
{post.readingTime || 3} دقیقه
|
||||
</div>
|
||||
<div className="flex items-center gap-1 text-medical-gray-400">
|
||||
<Eye className="w-3 h-3" />
|
||||
<span>{(post.viewCount ?? 0).toLocaleString('fa-IR')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h3 className="text-lg font-black text-medical-gray-900 mb-3 group-hover:text-canina-blue transition-colors line-clamp-2 leading-snug">
|
||||
|
||||
@@ -43,21 +43,22 @@ function ProductCard({ product }: { product: Product }) {
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 24 }}
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
whileInView={{ opacity: 1, y: 0 }}
|
||||
viewport={{ once: true }}
|
||||
whileHover={{ y: -6 }}
|
||||
transition={{ duration: 0.35, ease: "easeOut" }}
|
||||
className="group bg-white/80 backdrop-blur-md rounded-3xl border border-medical-gray-200/80 overflow-hidden hover:shadow-2xl hover:shadow-canina-blue/15 hover:border-canina-blue/30 transition-all duration-500 flex flex-col cursor-pointer relative"
|
||||
whileHover={{ y: -4 }}
|
||||
transition={{ duration: 0.3, ease: "easeOut" }}
|
||||
onClick={() => router.push(`/shop/${product.slug || product.id}`)}
|
||||
className="group bg-white/90 backdrop-blur-md rounded-2xl sm:rounded-3xl border border-medical-gray-200/80 overflow-hidden hover:shadow-xl hover:shadow-canina-blue/10 hover:border-canina-blue/30 transition-all duration-300 flex flex-col cursor-pointer relative"
|
||||
>
|
||||
{/* Category Badge */}
|
||||
<div className="absolute top-4 right-4 z-30 px-3 py-1.5 bg-white/90 backdrop-blur-md rounded-full border border-medical-gray-200/80 text-[10px] font-black text-medical-gray-700 uppercase tracking-widest shadow-sm group-hover:bg-canina-blue group-hover:text-white transition-all">
|
||||
<div className="absolute top-3 right-3 sm:top-4 sm:right-4 z-30 px-2.5 py-1 bg-white/90 backdrop-blur-md rounded-full border border-medical-gray-200/80 text-[9px] sm:text-[10px] font-black text-medical-gray-700 uppercase tracking-wider shadow-xs group-hover:bg-canina-blue group-hover:text-white transition-all">
|
||||
{product.category}
|
||||
</div>
|
||||
|
||||
{/* Compatibility Tag */}
|
||||
{compatibility && (
|
||||
<div className={`absolute top-[3.25rem] right-4 z-10 text-[8px] font-black uppercase tracking-widest px-3 py-1 rounded-full shadow-md flex items-center gap-1 ${
|
||||
<div className={`absolute top-[2.8rem] sm:top-[3.25rem] right-3 sm:right-4 z-10 text-[8px] font-black uppercase tracking-widest px-2.5 py-0.5 rounded-full shadow-xs flex items-center gap-1 ${
|
||||
compatibility.type === "alert" ? "bg-amber-100 text-amber-700" :
|
||||
compatibility.type === "success" ? "bg-green-100 text-green-700" : "bg-medical-gray-100 text-medical-gray-600"
|
||||
}`}>
|
||||
@@ -66,22 +67,20 @@ function ProductCard({ product }: { product: Product }) {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Image */}
|
||||
<div className="relative aspect-[4/3] bg-medical-gray-50 flex items-center justify-center overflow-hidden p-5">
|
||||
{/* Image Container */}
|
||||
<div className="relative aspect-[16/11] sm:aspect-[4/3] bg-medical-gray-50 flex items-center justify-center overflow-hidden p-3 sm:p-5">
|
||||
<SafeImage
|
||||
src={product.image}
|
||||
alt={nameFa}
|
||||
sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 25vw)"
|
||||
className="w-full h-full group-hover:scale-105 transition-transform duration-500"
|
||||
imgClassName="object-contain max-h-[170px] mx-auto"
|
||||
imgClassName="object-contain max-h-[130px] sm:max-h-[170px] mx-auto"
|
||||
/>
|
||||
{/* PDP Link overlay */}
|
||||
<Link href={`/shop/${product.slug || product.id}`} className="absolute inset-0 z-10" />
|
||||
{/* Hover Actions */}
|
||||
<div className="absolute inset-0 bg-canina-blue/60 opacity-0 group-hover:opacity-100 backdrop-blur-sm transition-all duration-300 flex items-center justify-center gap-4 z-20">
|
||||
{/* Hover Actions for desktop */}
|
||||
<div className="hidden sm:flex absolute inset-0 bg-canina-blue/60 opacity-0 group-hover:opacity-100 backdrop-blur-xs transition-all duration-300 items-center justify-center gap-3 z-20">
|
||||
<div
|
||||
onClick={(e) => { e.stopPropagation(); router.push(`/shop/${product.slug || product.id}`); }}
|
||||
className="w-11 h-11 rounded-full bg-white text-canina-blue flex items-center justify-center hover:scale-110 transition-transform shadow-lg cursor-pointer"
|
||||
className="w-10 h-10 rounded-full bg-white text-canina-blue flex items-center justify-center hover:scale-110 transition-transform shadow-lg cursor-pointer"
|
||||
title="مشاهده جزئیات"
|
||||
>
|
||||
<Eye className="w-5 h-5" />
|
||||
@@ -93,7 +92,7 @@ function ProductCard({ product }: { product: Product }) {
|
||||
addItem(product, 1);
|
||||
toast.success(`${nameFa} به سبد خرید اضافه شد.`);
|
||||
}}
|
||||
className="w-11 h-11 rounded-full bg-canina-blue text-white flex items-center justify-center hover:scale-110 transition-transform shadow-lg border border-white/20 cursor-pointer"
|
||||
className="w-10 h-10 rounded-full bg-canina-blue text-white flex items-center justify-center hover:scale-110 transition-transform shadow-lg border border-white/20 cursor-pointer"
|
||||
title="افزودن به سبد خرید"
|
||||
>
|
||||
<ShoppingCart className="w-5 h-5" />
|
||||
@@ -103,40 +102,40 @@ function ProductCard({ product }: { product: Product }) {
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<Link href={`/shop/${product.slug || product.id}`} className="px-5 py-4 flex flex-col flex-1 gap-3">
|
||||
<div className="px-3.5 py-3 sm:px-5 sm:py-4 flex flex-col flex-1 gap-2 sm:gap-3">
|
||||
{/* Dual-language Name */}
|
||||
<div className="flex flex-col gap-1">
|
||||
<h3 dir="rtl" className="text-[14px] font-black text-medical-gray-900 group-hover:text-canina-blue transition-colors leading-snug text-right line-clamp-2 font-vazir">
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<h3 dir="rtl" className="text-xs sm:text-[14px] font-black text-medical-gray-900 group-hover:text-canina-blue transition-colors leading-snug text-right line-clamp-1 sm:line-clamp-2 font-vazir">
|
||||
{nameFa}
|
||||
</h3>
|
||||
{nameEn && (
|
||||
<span dir="ltr" className="text-[11px] font-semibold text-slate-400 font-sans text-left block line-clamp-1">
|
||||
<span dir="ltr" className="text-[10px] sm:text-[11px] font-semibold text-slate-400 font-sans text-left block line-clamp-1">
|
||||
{nameEn}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Short description */}
|
||||
<p className="text-xs text-medical-gray-500 leading-relaxed line-clamp-2 flex-1">
|
||||
<p className="text-[11px] sm:text-xs text-medical-gray-500 leading-relaxed line-clamp-1 sm:line-clamp-2 flex-1">
|
||||
{product.shortDescription || product.description || ''}
|
||||
</p>
|
||||
|
||||
{/* Footer: Price + CTA */}
|
||||
<div className="flex items-center justify-between pt-3 border-t border-medical-gray-100">
|
||||
<div className="text-base font-black text-medical-gray-900 font-vazir whitespace-nowrap">
|
||||
<div className="flex items-center justify-between pt-2 sm:pt-3 border-t border-medical-gray-100">
|
||||
<div className="text-xs sm:text-sm md:text-base font-black text-medical-gray-900 font-vazir whitespace-nowrap">
|
||||
{showPrices ? (typeof product.price === 'string' || typeof product.price === 'number' ? String(product.price) : 'تماس بگیرید') : 'تماس بگیرید'}
|
||||
</div>
|
||||
{showPreorderBtn ? (
|
||||
<span className="text-[11px] font-black text-amber-600 bg-amber-50 px-3 py-1 rounded-full border border-amber-200">
|
||||
<span className="text-[10px] sm:text-[11px] font-black text-amber-600 bg-amber-50 px-2.5 py-1 rounded-full border border-amber-200">
|
||||
ثبت پیشخرید
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-[11px] font-black text-canina-blue uppercase tracking-widest border-b-2 border-canina-blue pb-0.5 hover:text-medical-gray-900 hover:border-medical-gray-900 transition-all whitespace-nowrap">
|
||||
<span className="text-[10px] sm:text-[11px] font-black text-canina-blue uppercase tracking-wider border-b border-canina-blue pb-0.5 group-hover:text-medical-gray-900 group-hover:border-medical-gray-900 transition-all whitespace-nowrap">
|
||||
{getText("product_view_details", "مشاهده جزئیات")}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -556,37 +556,155 @@ export default function Header({
|
||||
initial={{ opacity: 0, height: 0 }}
|
||||
animate={{ opacity: 1, height: "auto" }}
|
||||
exit={{ opacity: 0, height: 0 }}
|
||||
className="lg:hidden relative z-50 bg-white border-b border-medical-gray-200 px-4 py-6 space-y-4 shadow-xl"
|
||||
className="lg:hidden relative z-50 bg-white border-b border-medical-gray-200 px-4 py-5 space-y-4 shadow-xl max-h-[85vh] overflow-y-auto font-vazir text-right"
|
||||
dir="rtl"
|
||||
>
|
||||
<form onSubmit={handleSearch} className="relative mb-4">
|
||||
<form onSubmit={handleSearch} className="relative mb-3">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجو در محصولات..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-xl py-3 pr-10 pl-4 text-xs font-bold"
|
||||
className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-xl py-2.5 pr-10 pl-4 text-xs font-bold focus:ring-2 focus:ring-canina-blue/20 outline-none"
|
||||
/>
|
||||
<Search className="w-4 h-4 text-medical-gray-400 absolute right-3 top-1/2 -translate-y-1/2" />
|
||||
</form>
|
||||
|
||||
<div className="space-y-2 text-sm font-black">
|
||||
<Link href="/shop" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl bg-medical-gray-50 text-medical-gray-900">
|
||||
🛒 محصولات تخصصی کنینا
|
||||
{/* Section: Shop & Catalog */}
|
||||
<div className="space-y-1">
|
||||
<div className="text-[11px] font-black text-medical-gray-400 px-2 py-1 uppercase tracking-wider">
|
||||
فروشگاه و محصولات
|
||||
</div>
|
||||
<Link
|
||||
href="/shop"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl bg-medical-gray-50 text-medical-gray-900 font-bold text-xs hover:bg-canina-blue/10 hover:text-canina-blue transition-all"
|
||||
>
|
||||
<ShoppingBag className="w-4 h-4 text-canina-blue" />
|
||||
<span>فروشگاه تخصصی محصولات کنینا</span>
|
||||
</Link>
|
||||
<Link href="/catalog" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800">
|
||||
📑 کاتالوگ آنلاین و دوز مصرفی
|
||||
<Link
|
||||
href="/catalog"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800 font-bold text-xs transition-all"
|
||||
>
|
||||
<BookOpen className="w-4 h-4 text-medical-gray-500" />
|
||||
<span>کاتالوگ دیجیتال و راهنمای بالینی</span>
|
||||
</Link>
|
||||
<Link href="/wiki" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800">
|
||||
🧬 دانشنامه علمی
|
||||
</div>
|
||||
|
||||
{/* Section: Categories */}
|
||||
<div className="space-y-1 border-t border-medical-gray-100 pt-3">
|
||||
<div className="text-[11px] font-black text-medical-gray-400 px-2 py-1 uppercase tracking-wider">
|
||||
دستهبندیهای درمانی
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{menuItems.map((item, idx) => (
|
||||
<Link
|
||||
key={idx}
|
||||
href={`/shop?category=${item.id}`}
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-2 p-2.5 rounded-xl border border-medical-gray-100 bg-white hover:border-canina-blue/30 text-medical-gray-800 text-[11px] font-bold"
|
||||
>
|
||||
<span className="text-canina-blue">{item.icon}</span>
|
||||
<span className="truncate">{item.title}</span>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Section: Academy & Science */}
|
||||
<div className="space-y-1 border-t border-medical-gray-100 pt-3">
|
||||
<div className="text-[11px] font-black text-medical-gray-400 px-2 py-1 uppercase tracking-wider">
|
||||
دانشنامه و آموزش
|
||||
</div>
|
||||
<Link
|
||||
href="/wiki"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800 font-bold text-xs transition-all"
|
||||
>
|
||||
<BookOpen className="w-4 h-4 text-canina-blue" />
|
||||
<span>دانشنامه علمی کنینا</span>
|
||||
</Link>
|
||||
<Link href="/blog" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800">
|
||||
📰 مجله سلامت پت
|
||||
<Link
|
||||
href="/blog"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800 font-bold text-xs transition-all"
|
||||
>
|
||||
<FileText className="w-4 h-4 text-purple-600" />
|
||||
<span>مجله سلامت پت (وبلاگ)</span>
|
||||
</Link>
|
||||
<Link href="/videos" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800">
|
||||
🎥 آکادمی ویدئویی و مشاوره دامپزشک
|
||||
<Link
|
||||
href="/videos"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800 font-bold text-xs transition-all"
|
||||
>
|
||||
<Video className="w-4 h-4 text-rose-500" />
|
||||
<span>آکادمی ویدئویی و مشاوره دامپزشک</span>
|
||||
</Link>
|
||||
<Link href="/profile" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800">
|
||||
🐾 شناسنامه و سوابق سلامت پت
|
||||
</div>
|
||||
|
||||
{/* Section: Tools & Profile */}
|
||||
<div className="space-y-1 border-t border-medical-gray-100 pt-3">
|
||||
<div className="text-[11px] font-black text-medical-gray-400 px-2 py-1 uppercase tracking-wider">
|
||||
ابزارهای هوشمند
|
||||
</div>
|
||||
<Link
|
||||
href="/profile"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800 font-bold text-xs transition-all"
|
||||
>
|
||||
<Dog className="w-4 h-4 text-amber-500" />
|
||||
<span>شناسنامه و سوابق سلامت پت</span>
|
||||
</Link>
|
||||
<Link
|
||||
href="/dashboard"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800 font-bold text-xs transition-all"
|
||||
>
|
||||
<Activity className="w-4 h-4 text-emerald-500" />
|
||||
<span>پایش هوشمند مصرف مکملها</span>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Section: Company & Contact */}
|
||||
<div className="space-y-1 border-t border-medical-gray-100 pt-3">
|
||||
<div className="text-[11px] font-black text-medical-gray-400 px-2 py-1 uppercase tracking-wider">
|
||||
اطلاعات و تماس
|
||||
</div>
|
||||
<Link
|
||||
href="/about"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800 font-bold text-xs transition-all"
|
||||
>
|
||||
<Award className="w-4 h-4 text-canina-blue" />
|
||||
<span>درباره کمپانی کنینا آلمان</span>
|
||||
</Link>
|
||||
<Link
|
||||
href="/trust-seals"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl hover:bg-medical-gray-50 text-emerald-600 font-bold text-xs transition-all"
|
||||
>
|
||||
<ShieldCheck className="w-4 h-4 text-emerald-600" />
|
||||
<span>نمادهای اعتماد و مجوزهای رسمی</span>
|
||||
</Link>
|
||||
{isB2BEnabled && (
|
||||
<Link
|
||||
href="/b2b"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800 font-bold text-xs transition-all"
|
||||
>
|
||||
<Building2 className="w-4 h-4 text-canina-blue" />
|
||||
<span>درخواست نمایندگی و خرید عمده (B2B)</span>
|
||||
</Link>
|
||||
)}
|
||||
<Link
|
||||
href="/contact"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="flex items-center gap-3 p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800 font-bold text-xs transition-all"
|
||||
>
|
||||
<PhoneCall className="w-4 h-4 text-canina-blue" />
|
||||
<span>تماس با مرکز پشتیبانی</span>
|
||||
</Link>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
@@ -301,14 +301,14 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
<div className="bg-medical-gray-50 rounded-[3.5rem] border border-medical-gray-100 p-8 lg:p-12 shadow-2xl shadow-medical-gray-200/50 relative overflow-hidden">
|
||||
<div className="bg-medical-gray-50 rounded-[2.5rem] border border-medical-gray-200/80 p-5 sm:p-8 lg:p-10 shadow-xl shadow-medical-gray-200/40 relative overflow-hidden">
|
||||
{/* Progress Indicator */}
|
||||
<div className="absolute top-0 left-0 w-full h-2 bg-medical-gray-200">
|
||||
<div className="absolute top-0 left-0 w-full h-1.5 bg-medical-gray-200">
|
||||
<motion.div
|
||||
className="h-full bg-canina-blue"
|
||||
initial={{ width: "0%" }}
|
||||
animate={{ width: `${(step / 4) * 100}%` }}
|
||||
transition={{ duration: 0.5 }}
|
||||
transition={{ duration: 0.4 }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -319,33 +319,35 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
initial={{ opacity: 0, x: 20 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
exit={{ opacity: 0, x: -20 }}
|
||||
className="space-y-8"
|
||||
className="space-y-6"
|
||||
>
|
||||
<div className="text-center">
|
||||
<h3 className="text-2xl font-black text-medical-gray-900 mb-2 font-vazir uppercase italic tracking-tight">{getText('advisor_step1_title', "گام اول: هویت بصری")}</h3>
|
||||
<p className="text-medical-gray-600 font-bold font-vazir">{getText('advisor_step1_desc', "همدم شما رو با چه اسمی صدا میزنید؟")}</p>
|
||||
<h3 className="text-xl sm:text-2xl font-black text-medical-gray-900 mb-1.5 font-vazir tracking-tight">{getText('advisor_step1_title', "گام اول: مشخصات پت")}</h3>
|
||||
<p className="text-xs sm:text-sm text-medical-gray-500 font-bold font-vazir">{getText('advisor_step1_desc', "همدم شما رو با چه اسمی صدا میزنید؟")}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="grid grid-cols-2 gap-3 sm:gap-4 max-w-md mx-auto">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setType("سگ")}
|
||||
className={`flex flex-col items-center gap-4 p-8 rounded-[2.5rem] border-4 transition-all focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none cursor-pointer ${type === "سگ" ? 'border-canina-blue bg-white shadow-xl shadow-canina-blue/10 scale-105 text-canina-blue' : 'border-medical-gray-250 bg-white text-medical-gray-500 hover:border-canina-blue/30 hover:text-canina-blue/70'}`}
|
||||
className={`flex flex-col items-center gap-2.5 p-5 sm:p-6 rounded-2xl border-2 transition-all cursor-pointer ${type === "سگ" ? 'border-canina-blue bg-white shadow-md shadow-canina-blue/10 text-canina-blue scale-102' : 'border-medical-gray-200 bg-white text-medical-gray-500 hover:border-canina-blue/30'}`}
|
||||
>
|
||||
<Dog className="w-12 h-12" />
|
||||
<span className="text-lg font-black font-vazir">سگ</span>
|
||||
<Dog className="w-8 h-8 sm:w-10 sm:h-10" />
|
||||
<span className="text-sm sm:text-base font-black font-vazir">سگ</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setType("گربه")}
|
||||
className={`flex flex-col items-center gap-4 p-8 rounded-[2.5rem] border-4 transition-all focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none cursor-pointer ${type === "گربه" ? 'border-canina-blue bg-white shadow-xl shadow-canina-blue/10 scale-105 text-canina-blue' : 'border-medical-gray-250 bg-white text-medical-gray-500 hover:border-canina-blue/30 hover:text-canina-blue/70'}`}
|
||||
className={`flex flex-col items-center gap-2.5 p-5 sm:p-6 rounded-2xl border-2 transition-all cursor-pointer ${type === "گربه" ? 'border-canina-blue bg-white shadow-md shadow-canina-blue/10 text-canina-blue scale-102' : 'border-medical-gray-200 bg-white text-medical-gray-500 hover:border-canina-blue/30'}`}
|
||||
>
|
||||
<Cat className="w-12 h-12" />
|
||||
<span className="text-lg font-black font-vazir">گربه</span>
|
||||
<Cat className="w-8 h-8 sm:w-10 sm:h-10" />
|
||||
<span className="text-sm sm:text-base font-black font-vazir">گربه</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="grid md:grid-cols-2 gap-6">
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs font-black text-medical-gray-600 pr-2">{getText('advisor_pet_name_label', "نام پت")}</label>
|
||||
<div className="grid md:grid-cols-2 gap-4 max-w-xl mx-auto">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-black text-medical-gray-600 pr-1">{getText('advisor_pet_name_label', "نام پت")}</label>
|
||||
<input
|
||||
type="text"
|
||||
value={name}
|
||||
@@ -353,17 +355,17 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
setName(e.target.value);
|
||||
if (e.target.value.trim() && breed.trim()) setShowError(false);
|
||||
}}
|
||||
placeholder={getText('advisor_pet_name_placeholder', "لوسی، تدی...")}
|
||||
placeholder={getText('advisor_pet_name_placeholder', "مثال: لوسی")}
|
||||
className={cn(
|
||||
"w-full bg-white border rounded-2xl py-4 px-6 focus:ring-2 outline-none font-black text-lg font-vazir placeholder-medical-gray-500 text-medical-gray-900 transition-all",
|
||||
"w-full bg-white border rounded-xl py-3 px-4 focus:ring-2 outline-none font-bold text-sm font-vazir placeholder-medical-gray-400 text-medical-gray-900 transition-all",
|
||||
showError && !name.trim()
|
||||
? "border-red-500 focus:ring-red-500/30"
|
||||
: "border-medical-gray-300 focus:ring-canina-blue/30 focus-visible:ring-4 focus-visible:ring-canina-blue/40"
|
||||
: "border-medical-gray-200 focus:ring-canina-blue/30 focus:border-canina-blue"
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs font-black text-medical-gray-600 pr-2">{getText('advisor_pet_breed_label', "نژاد")}</label>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-black text-medical-gray-600 pr-1">{getText('advisor_pet_breed_label', "نژاد")}</label>
|
||||
<input
|
||||
type="text"
|
||||
value={breed}
|
||||
@@ -371,34 +373,37 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
setBreed(e.target.value);
|
||||
if (name.trim() && e.target.value.trim()) setShowError(false);
|
||||
}}
|
||||
placeholder={getText('advisor_pet_breed_placeholder', "ژرمن، پرشین...")}
|
||||
placeholder={getText('advisor_pet_breed_placeholder', "مثال: ژرمن شپرد")}
|
||||
className={cn(
|
||||
"w-full bg-white border rounded-2xl py-4 px-6 focus:ring-2 outline-none font-bold font-vazir placeholder-medical-gray-500 text-medical-gray-900 transition-all",
|
||||
"w-full bg-white border rounded-xl py-3 px-4 focus:ring-2 outline-none font-bold text-sm font-vazir placeholder-medical-gray-400 text-medical-gray-900 transition-all",
|
||||
showError && !breed.trim()
|
||||
? "border-red-500 focus:ring-red-500/30"
|
||||
: "border-medical-gray-300 focus:ring-canina-blue/30 focus-visible:ring-4 focus-visible:ring-canina-blue/40"
|
||||
: "border-medical-gray-200 focus:ring-canina-blue/30 focus:border-canina-blue"
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<motion.button
|
||||
onClick={handleNext}
|
||||
animate={shake ? { x: [-10, 10, -10, 10, -5, 5, -2, 2, 0] } : { x: 0 }}
|
||||
transition={{ duration: 0.4 }}
|
||||
className={cn(
|
||||
"w-full py-6 rounded-3xl font-black text-lg flex items-center justify-center gap-3 font-vazir min-h-[48px] transition-all focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none bg-medical-gray-900 text-white hover:bg-canina-blue shadow-xl shadow-medical-gray-900/10",
|
||||
(!name.trim() || !breed.trim()) ? "opacity-60 cursor-pointer" : ""
|
||||
<div className="max-w-md mx-auto pt-2">
|
||||
<motion.button
|
||||
type="button"
|
||||
onClick={handleNext}
|
||||
animate={shake ? { x: [-10, 10, -10, 10, -5, 5, -2, 2, 0] } : { x: 0 }}
|
||||
transition={{ duration: 0.4 }}
|
||||
className={cn(
|
||||
"w-full whitespace-nowrap bg-canina-blue text-white px-6 sm:px-10 py-3 sm:py-4 rounded-full font-bold text-sm sm:text-base hover:bg-canina-blue/90 hover:shadow-xl focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none transition-all flex items-center justify-center gap-2 group font-vazir min-h-[48px] shadow-md shadow-canina-blue/20 cursor-pointer",
|
||||
(!name.trim() || !breed.trim()) ? "opacity-60" : ""
|
||||
)}
|
||||
>
|
||||
<span>{getText('advisor_submit_btn', "ثبت هویت و ادامه")}</span>
|
||||
<ChevronLeft className="w-4 h-4 group-hover:-translate-x-1 transition-transform" />
|
||||
</motion.button>
|
||||
{showError && (!name.trim() || !breed.trim()) && (
|
||||
<p className="text-center text-xs font-bold text-red-500 mt-2 font-vazir animate-pulse">
|
||||
{getText('advisor_validation_warning', "⚠️ لطفاً ابتدا نام و نژاد پت را وارد کنید.")}
|
||||
</p>
|
||||
)}
|
||||
>
|
||||
{getText('advisor_submit_btn', "ثبت هویت و ادامه")}
|
||||
<ChevronLeft className="w-5 h-5" />
|
||||
</motion.button>
|
||||
{showError && (!name.trim() || !breed.trim()) && (
|
||||
<p className="text-center text-xs font-black text-red-500 mt-2 font-vazir animate-pulse">
|
||||
{getText('advisor_validation_warning', "⚠️ لطفاً ابتدا نام و نژاد پت را در بالا وارد کنید.")}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
|
||||
@@ -408,60 +413,95 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
initial={{ opacity: 0, x: 20 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
exit={{ opacity: 0, x: -20 }}
|
||||
className="space-y-8"
|
||||
className="space-y-6 max-w-xl mx-auto"
|
||||
>
|
||||
<div className="text-center">
|
||||
<h3 className="text-2xl font-black text-medical-gray-900 mb-2 font-vazir uppercase italic tracking-tight">{getText('advisor_step2_title', "گام دوم: پایش فیزیکی")}</h3>
|
||||
<p className="text-medical-gray-600 font-bold font-vazir">{getText('advisor_step2_desc', "اطلاعات فیزیکی دقیق به دوزبندی صحیح مکملها کمک میکند")}</p>
|
||||
<h3 className="text-xl sm:text-2xl font-black text-medical-gray-900 mb-1.5 font-vazir tracking-tight">{getText('advisor_step2_title', "گام دوم: پایش فیزیکی")}</h3>
|
||||
<p className="text-xs sm:text-sm text-medical-gray-500 font-bold font-vazir">{getText('advisor_step2_desc', "اطلاعات فیزیکی به دوزبندی دقیق مکملها کمک میکند")}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-6">
|
||||
<div className="space-y-4">
|
||||
<label className="block text-center text-sm font-black text-medical-gray-800 font-vazir">{getText('advisor_age_label', "سن حیوان (سال)")}</label>
|
||||
<div className="flex items-center gap-2 bg-white rounded-3xl p-2 border-2 border-medical-gray-200">
|
||||
<button type="button" onClick={() => setAge(Math.max(0, age - 1))} className="w-10 h-10 shrink-0 flex items-center justify-center bg-medical-gray-50 rounded-xl text-medical-gray-900 hover:bg-canina-blue hover:text-white transition-all shadow-sm font-black text-lg">-</button>
|
||||
<div className="flex-1 flex items-center justify-center gap-1">
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{/* Age Input Box */}
|
||||
<div className="bg-white p-3.5 rounded-2xl border border-medical-gray-200 shadow-xs space-y-2">
|
||||
<label className="block text-center text-xs font-black text-medical-gray-700 font-vazir">{getText('advisor_age_label', "سن حیوان (سال)")}</label>
|
||||
<div className="flex items-center justify-between gap-1.5 bg-medical-gray-50 rounded-xl p-1 border border-medical-gray-200">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setAge(Math.max(0, age - 1))}
|
||||
className="w-9 h-9 shrink-0 flex items-center justify-center bg-white rounded-lg text-medical-gray-800 hover:bg-canina-blue hover:text-white transition-all shadow-xs font-black text-base cursor-pointer"
|
||||
>
|
||||
-
|
||||
</button>
|
||||
<div className="flex-1 flex items-center justify-center gap-1" dir="ltr">
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
max="30"
|
||||
value={age === 0 ? '' : age}
|
||||
onChange={(e) => setAge(Math.max(0, parseInt(e.target.value) || 0))}
|
||||
className="w-12 text-center text-xl font-black text-canina-blue font-vazir outline-none bg-transparent"
|
||||
type="text"
|
||||
inputMode="numeric"
|
||||
pattern="[0-9]*"
|
||||
value={age === 0 ? '' : age.toString()}
|
||||
onChange={(e) => {
|
||||
const val = e.target.value.replace(/[^0-9]/g, '');
|
||||
setAge(val === '' ? 0 : Math.min(30, parseInt(val, 10)));
|
||||
}}
|
||||
className="w-14 text-center text-lg font-black text-canina-blue font-mono outline-none bg-transparent"
|
||||
/>
|
||||
<span className="text-xs font-bold text-medical-gray-400">سال</span>
|
||||
<span className="text-[11px] font-bold text-medical-gray-400 font-vazir">سال</span>
|
||||
</div>
|
||||
<button type="button" onClick={() => setAge(age + 1)} className="w-10 h-10 shrink-0 flex items-center justify-center bg-medical-gray-50 rounded-xl text-medical-gray-900 hover:bg-canina-blue hover:text-white transition-all shadow-sm font-black text-lg">+</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setAge(Math.min(30, age + 1))}
|
||||
className="w-9 h-9 shrink-0 flex items-center justify-center bg-white rounded-lg text-medical-gray-800 hover:bg-canina-blue hover:text-white transition-all shadow-xs font-black text-base cursor-pointer"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
<label className="block text-center text-sm font-black text-medical-gray-800 font-vazir">{getText('advisor_weight_label', "وزن حیوان (کیلوگرم)")}</label>
|
||||
<div className="flex items-center gap-2 bg-white rounded-3xl p-2 border-2 border-medical-gray-200">
|
||||
<button type="button" onClick={() => setWeight(Math.max(1, weight - 1))} className="w-10 h-10 shrink-0 flex items-center justify-center bg-medical-gray-50 rounded-xl text-medical-gray-900 hover:bg-canina-blue hover:text-white transition-all shadow-sm font-black text-lg">-</button>
|
||||
<div className="flex-1 flex items-center justify-center gap-1">
|
||||
|
||||
{/* Weight Input Box */}
|
||||
<div className="bg-white p-3.5 rounded-2xl border border-medical-gray-200 shadow-xs space-y-2">
|
||||
<label className="block text-center text-xs font-black text-medical-gray-700 font-vazir">{getText('advisor_weight_label', "وزن حیوان (کیلوگرم)")}</label>
|
||||
<div className="flex items-center justify-between gap-1.5 bg-medical-gray-50 rounded-xl p-1 border border-medical-gray-200">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setWeight(Math.max(1, weight - 1))}
|
||||
className="w-9 h-9 shrink-0 flex items-center justify-center bg-white rounded-lg text-medical-gray-800 hover:bg-canina-blue hover:text-white transition-all shadow-xs font-black text-base cursor-pointer"
|
||||
>
|
||||
-
|
||||
</button>
|
||||
<div className="flex-1 flex items-center justify-center gap-1" dir="ltr">
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max="120"
|
||||
value={weight === 0 ? '' : weight}
|
||||
onChange={(e) => setWeight(Math.max(1, parseInt(e.target.value) || 1))}
|
||||
className="w-16 text-center text-xl font-black text-canina-blue font-vazir outline-none bg-transparent"
|
||||
type="text"
|
||||
inputMode="numeric"
|
||||
pattern="[0-9]*"
|
||||
value={weight === 0 ? '' : weight.toString()}
|
||||
onChange={(e) => {
|
||||
const val = e.target.value.replace(/[^0-9]/g, '');
|
||||
setWeight(val === '' ? 0 : Math.min(120, parseInt(val, 10)));
|
||||
}}
|
||||
className="w-14 text-center text-lg font-black text-canina-blue font-mono outline-none bg-transparent"
|
||||
/>
|
||||
<span className="text-xs font-bold text-medical-gray-400">kg</span>
|
||||
<span className="text-[11px] font-bold text-medical-gray-400 font-vazir">kg</span>
|
||||
</div>
|
||||
<button type="button" onClick={() => setWeight(weight + 1)} className="w-10 h-10 shrink-0 flex items-center justify-center bg-medical-gray-50 rounded-xl text-medical-gray-900 hover:bg-canina-blue hover:text-white transition-all shadow-sm font-black text-lg">+</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setWeight(Math.min(120, weight + 1))}
|
||||
className="w-9 h-9 shrink-0 flex items-center justify-center bg-white rounded-lg text-medical-gray-800 hover:bg-canina-blue hover:text-white transition-all shadow-xs font-black text-base cursor-pointer"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<label className="block text-center text-xs font-black text-medical-gray-600 uppercase tracking-widest font-vazir">{getText('advisor_activity_label', "سطح فعالیت روزانه")}</label>
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
{/* Activity Level */}
|
||||
<div className="space-y-2">
|
||||
<label className="block text-center text-xs font-black text-medical-gray-600 font-vazir">{getText('advisor_activity_label', "سطح فعالیت روزانه")}</label>
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
{["کم", "متوسط", "زیاد"].map(level => (
|
||||
<button
|
||||
key={level}
|
||||
type="button"
|
||||
onClick={() => setActivityLevel(level as "کم" | "متوسط" | "زیاد")}
|
||||
className={`py-4 rounded-2xl border-2 transition-all font-black italic focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none min-h-[48px] ${activityLevel === level ? 'border-canina-blue bg-white text-canina-blue shadow-lg' : 'border-transparent bg-white/50 text-medical-gray-500 hover:bg-white'}`}
|
||||
className={`py-2.5 rounded-xl border-2 transition-all font-bold text-xs sm:text-sm cursor-pointer ${activityLevel === level ? 'border-canina-blue bg-white text-canina-blue shadow-sm' : 'border-transparent bg-white/70 text-medical-gray-500 hover:bg-white'}`}
|
||||
>
|
||||
{level}
|
||||
</button>
|
||||
@@ -469,20 +509,23 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-4 pt-4">
|
||||
{/* Buttons (matching Hero layout) */}
|
||||
<div className="whitespace-nowrap flex items-center justify-between gap-3 pt-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleBack}
|
||||
className="flex-1 py-6 bg-medical-gray-100 text-medical-gray-600 rounded-3xl font-black text-lg hover:bg-medical-gray-200 focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none transition-all flex items-center justify-center gap-3 font-vazir min-h-[48px]"
|
||||
className="whitespace-nowrap bg-white border-2 border-medical-gray-300 text-medical-gray-700 px-4 sm:px-6 py-2.5 sm:py-3.5 rounded-full font-bold text-xs sm:text-sm hover:bg-medical-gray-50 transition-all flex items-center gap-1.5 cursor-pointer"
|
||||
>
|
||||
<ChevronRight className="w-5 h-5" />
|
||||
{getText('advisor_back', "قبلی")}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleNext}
|
||||
className="flex-[2] py-6 bg-medical-gray-900 text-white rounded-3xl font-black text-lg hover:bg-canina-blue focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none transition-all shadow-xl shadow-medical-gray-900/10 flex items-center justify-center gap-3 font-vazir min-h-[48px]"
|
||||
>
|
||||
{getText('advisor_next_symptoms', "بررسی علائم بالینی فعلی")}
|
||||
<ChevronLeft className="w-5 h-5" />
|
||||
<ChevronRight className="w-4 h-4" />
|
||||
<span>{getText('advisor_back', "قبلی")}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleNext}
|
||||
className="whitespace-nowrap bg-canina-blue text-white px-5 sm:px-8 py-2.5 sm:py-3.5 rounded-full font-bold text-xs sm:text-sm hover:bg-canina-blue/90 hover:shadow-lg transition-all flex items-center gap-1.5 shadow-md shadow-canina-blue/20 cursor-pointer"
|
||||
>
|
||||
<span>{getText('advisor_next_symptoms', "علائم بالینی")}</span>
|
||||
<ChevronLeft className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
@@ -494,42 +537,45 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
initial={{ opacity: 0, x: 20 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
exit={{ opacity: 0, x: -20 }}
|
||||
className="space-y-8"
|
||||
className="space-y-5 max-w-2xl mx-auto"
|
||||
>
|
||||
<div className="text-center">
|
||||
<h3 className="text-2xl font-black text-medical-gray-900 mb-2 font-vazir uppercase italic tracking-tight">{getText('advisor_step3_symptoms_title', "گام سوم: علائم بالینی فعلی")}</h3>
|
||||
<p className="text-medical-gray-600 font-bold font-vazir">{getText('advisor_step3_symptoms_desc', "آیا همدم شما در حال حاضر هیچکدام از علائم زیر را تجربه میکند؟")}</p>
|
||||
<h3 className="text-xl sm:text-2xl font-black text-medical-gray-900 mb-1 font-vazir tracking-tight">{getText('advisor_step3_symptoms_title', "گام سوم: علائم بالینی فعلی")}</h3>
|
||||
<p className="text-xs sm:text-sm text-medical-gray-500 font-bold font-vazir">{getText('advisor_step3_symptoms_desc', "آیا همدم شما در حال حاضر علائم زیر را دارد؟")}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-2.5 max-h-[50vh] sm:max-h-none overflow-y-auto pr-1">
|
||||
{CURRENT_SYMPTOMS.map((opt) => (
|
||||
<button
|
||||
key={opt.id}
|
||||
type="button"
|
||||
onClick={() => toggleSymptom(opt.condition)}
|
||||
className={`flex items-center gap-4 p-5 rounded-2xl border-2 transition-all text-right focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none min-h-[48px] ${currentSymptoms.includes(opt.condition) ? 'border-canina-blue bg-white shadow-md' : 'border-transparent bg-white/50 text-medical-gray-600 hover:bg-white'}`}
|
||||
className={`flex items-center gap-3 p-3.5 rounded-xl border transition-all text-right cursor-pointer ${currentSymptoms.includes(opt.condition) ? 'border-canina-blue bg-canina-blue/5 shadow-xs text-canina-blue' : 'border-medical-gray-200 bg-white text-medical-gray-700 hover:border-canina-blue/40'}`}
|
||||
>
|
||||
<div className={`w-8 h-8 rounded-lg flex items-center justify-center border ${currentSymptoms.includes(opt.condition) ? 'bg-canina-blue border-canina-blue text-white' : 'border-medical-gray-300 text-transparent'}`}>
|
||||
<ShieldCheck className="w-5 h-5" />
|
||||
<div className={`w-5 h-5 rounded-md flex items-center justify-center border shrink-0 ${currentSymptoms.includes(opt.condition) ? 'bg-canina-blue border-canina-blue text-white' : 'border-medical-gray-300 bg-white'}`}>
|
||||
{currentSymptoms.includes(opt.condition) && <Check className="w-3.5 h-3.5 stroke-[3]" />}
|
||||
</div>
|
||||
<span className={`text-sm font-black font-vazir ${currentSymptoms.includes(opt.condition) ? 'text-canina-blue' : 'text-medical-gray-900'}`}>{opt.label}</span>
|
||||
<span className="text-xs sm:text-sm font-bold font-vazir leading-tight">{opt.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="flex gap-4 pt-4">
|
||||
<div className="whitespace-nowrap flex items-center justify-between gap-3 pt-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleBack}
|
||||
className="flex-1 py-6 bg-medical-gray-100 text-medical-gray-600 rounded-3xl font-black text-lg hover:bg-medical-gray-200 focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none transition-all flex items-center justify-center gap-3 font-vazir min-h-[48px]"
|
||||
className="whitespace-nowrap bg-white border-2 border-medical-gray-300 text-medical-gray-700 px-4 sm:px-6 py-2.5 sm:py-3.5 rounded-full font-bold text-xs sm:text-sm hover:bg-medical-gray-50 transition-all flex items-center gap-1.5 cursor-pointer"
|
||||
>
|
||||
<ChevronRight className="w-5 h-5" />
|
||||
{getText('advisor_back', "قبلی")}
|
||||
<ChevronRight className="w-4 h-4" />
|
||||
<span>{getText('advisor_back', "قبلی")}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleNext}
|
||||
className="flex-[2] py-6 bg-medical-gray-900 text-white rounded-3xl font-black text-lg hover:bg-canina-blue focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none transition-all shadow-xl shadow-medical-gray-900/10 flex items-center justify-center gap-3 font-vazir min-h-[48px]"
|
||||
className="whitespace-nowrap bg-canina-blue text-white px-5 sm:px-8 py-2.5 sm:py-3.5 rounded-full font-bold text-xs sm:text-sm hover:bg-canina-blue/90 hover:shadow-lg transition-all flex items-center gap-1.5 shadow-md shadow-canina-blue/20 cursor-pointer"
|
||||
>
|
||||
{getText('advisor_next_history', "سوابق پزشکی و جراحی")}
|
||||
<ChevronLeft className="w-5 h-5" />
|
||||
<span>{getText('advisor_next_history', "سوابق پزشکی")}</span>
|
||||
<ChevronLeft className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
@@ -541,42 +587,45 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
initial={{ opacity: 0, x: 20 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
exit={{ opacity: 0, x: -20 }}
|
||||
className="space-y-8"
|
||||
className="space-y-5 max-w-2xl mx-auto"
|
||||
>
|
||||
<div className="text-center">
|
||||
<h3 className="text-2xl font-black text-medical-gray-900 mb-2 font-vazir uppercase italic tracking-tight">{getText('advisor_step4_history_title', "گام چهارم: سوابق پزشکی و جراحی")}</h3>
|
||||
<p className="text-medical-gray-600 font-bold font-vazir">{getText('advisor_step4_history_desc', "در صورت وجود سابقه جراحی، بارداری یا نارسایی، آن را مشخص کنید")}</p>
|
||||
<h3 className="text-xl sm:text-2xl font-black text-medical-gray-900 mb-1 font-vazir tracking-tight">{getText('advisor_step4_history_title', "گام چهارم: سوابق پزشکی")}</h3>
|
||||
<p className="text-xs sm:text-sm text-medical-gray-500 font-bold font-vazir">{getText('advisor_step4_history_desc', "در صورت وجود سابقه جراحی، بارداری یا نارسایی، آن را مشخص کنید")}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-2.5 max-h-[50vh] sm:max-h-none overflow-y-auto pr-1">
|
||||
{MEDICAL_HISTORIES.map((opt) => (
|
||||
<button
|
||||
key={opt.id}
|
||||
type="button"
|
||||
onClick={() => toggleMedicalHistory(opt.condition)}
|
||||
className={`flex items-center gap-4 p-5 rounded-2xl border-2 transition-all text-right focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none min-h-[48px] ${medicalConditions.includes(opt.condition) ? 'border-canina-blue bg-white shadow-md' : 'border-transparent bg-white/50 text-medical-gray-600 hover:bg-white'}`}
|
||||
className={`flex items-center gap-3 p-3.5 rounded-xl border transition-all text-right cursor-pointer ${medicalConditions.includes(opt.condition) ? 'border-canina-blue bg-canina-blue/5 shadow-xs text-canina-blue' : 'border-medical-gray-200 bg-white text-medical-gray-700 hover:border-canina-blue/40'}`}
|
||||
>
|
||||
<div className={`w-8 h-8 rounded-lg flex items-center justify-center border ${medicalConditions.includes(opt.condition) ? 'bg-canina-blue border-canina-blue text-white' : 'border-medical-gray-300 text-transparent'}`}>
|
||||
<ShieldCheck className="w-5 h-5" />
|
||||
<div className={`w-5 h-5 rounded-md flex items-center justify-center border shrink-0 ${medicalConditions.includes(opt.condition) ? 'bg-canina-blue border-canina-blue text-white' : 'border-medical-gray-300 bg-white'}`}>
|
||||
{medicalConditions.includes(opt.condition) && <Check className="w-3.5 h-3.5 stroke-[3]" />}
|
||||
</div>
|
||||
<span className={`text-sm font-black font-vazir ${medicalConditions.includes(opt.condition) ? 'text-canina-blue' : 'text-medical-gray-900'}`}>{opt.label}</span>
|
||||
<span className="text-xs sm:text-sm font-bold font-vazir leading-tight">{opt.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="flex gap-4 pt-4">
|
||||
<div className="whitespace-nowrap flex items-center justify-between gap-3 pt-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleBack}
|
||||
className="flex-1 py-6 bg-medical-gray-100 text-medical-gray-600 rounded-3xl font-black text-lg hover:bg-medical-gray-200 focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none transition-all flex items-center justify-center gap-3 font-vazir min-h-[48px]"
|
||||
className="whitespace-nowrap bg-white border-2 border-medical-gray-300 text-medical-gray-700 px-4 sm:px-6 py-2.5 sm:py-3.5 rounded-full font-bold text-xs sm:text-sm hover:bg-medical-gray-50 transition-all flex items-center gap-1.5 cursor-pointer"
|
||||
>
|
||||
<ChevronRight className="w-5 h-5" />
|
||||
{getText('advisor_back', "قبلی")}
|
||||
<ChevronRight className="w-4 h-4" />
|
||||
<span>{getText('advisor_back', "قبلی")}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleSubmit}
|
||||
className="flex-[2] py-6 bg-canina-blue text-white rounded-3xl font-black text-lg hover:bg-canina-blue/90 focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none transition-all shadow-xl shadow-canina-blue/30 flex items-center justify-center gap-3 font-vazir min-h-[48px]"
|
||||
className="whitespace-nowrap bg-emerald-600 text-white px-6 sm:px-9 py-2.5 sm:py-3.5 rounded-full font-bold text-xs sm:text-sm hover:bg-emerald-700 hover:shadow-lg transition-all flex items-center gap-1.5 shadow-md shadow-emerald-600/20 cursor-pointer"
|
||||
>
|
||||
{getText('advisor_complete', "تکمیل و صدور شناسنامه")}
|
||||
<ChevronLeft className="w-5 h-5" />
|
||||
<span>{getText('advisor_complete', "صدور شناسنامه و پیشنهاد")}</span>
|
||||
<ChevronLeft className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
@@ -71,20 +71,37 @@ export default function VideoModalPlayer({ isOpen, onClose, video }: VideoModalP
|
||||
};
|
||||
}, [showRateMenu]);
|
||||
|
||||
// Reset states on open/close
|
||||
// Reset / Restore states on open/close
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
if (isOpen && video?.id) {
|
||||
const savedTime = localStorage.getItem(`video_time_${video.id}`);
|
||||
const initialTime = savedTime ? parseFloat(savedTime) : 0;
|
||||
|
||||
setIsPlaying(true);
|
||||
setShowControls(true);
|
||||
setIsExpandedDesc(false);
|
||||
setShowRateMenu(false);
|
||||
setBufferedEnd(0);
|
||||
} else {
|
||||
|
||||
if (videoRef.current && initialTime > 0) {
|
||||
videoRef.current.currentTime = initialTime;
|
||||
setCurrentTime(initialTime);
|
||||
}
|
||||
} else if (!isOpen && video?.id) {
|
||||
if (currentTime > 0) {
|
||||
localStorage.setItem(`video_time_${video.id}`, currentTime.toString());
|
||||
}
|
||||
setIsPlaying(false);
|
||||
setCurrentTime(0);
|
||||
setBufferedEnd(0);
|
||||
}
|
||||
}, [isOpen, video]);
|
||||
}, [isOpen, video?.id]);
|
||||
|
||||
// Save playback time periodically
|
||||
useEffect(() => {
|
||||
if (video?.id && currentTime > 0) {
|
||||
localStorage.setItem(`video_time_${video.id}`, currentTime.toString());
|
||||
}
|
||||
}, [currentTime, video?.id]);
|
||||
|
||||
// Update buffered track
|
||||
const updateBuffer = useCallback(() => {
|
||||
@@ -254,164 +271,147 @@ export default function VideoModalPlayer({ isOpen, onClose, video }: VideoModalP
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
<div className="fixed inset-0 z-[120] flex items-center justify-center p-3 sm:p-6 font-vazir" dir="rtl">
|
||||
{/* Backdrop */}
|
||||
<div className="fixed inset-0 z-[120] flex items-center justify-center p-3 sm:p-6 font-vazir overflow-y-auto" dir="rtl">
|
||||
{/* Backdrop (backdrop dismiss disabled to prevent accidental closure) */}
|
||||
<motion.div
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
onClick={onClose}
|
||||
className="absolute inset-0 bg-black/90 backdrop-blur-xl"
|
||||
className="fixed inset-0 bg-black/90 backdrop-blur-xl"
|
||||
/>
|
||||
|
||||
{/* Modal Window */}
|
||||
<motion.div
|
||||
ref={containerRef}
|
||||
initial={{ opacity: 0, scale: 0.95, y: 15 }}
|
||||
animate={{ opacity: 1, scale: 1, y: 0 }}
|
||||
exit={{ opacity: 0, scale: 0.95, y: 15 }}
|
||||
transition={{ duration: 0.25 }}
|
||||
onMouseMove={resetControlsTimer}
|
||||
onTouchStart={resetControlsTimer}
|
||||
className="relative bg-black w-full max-w-5xl aspect-video rounded-[2.5rem] overflow-hidden shadow-2xl border border-white/10 flex flex-col justify-between select-none"
|
||||
>
|
||||
{/* Iframe Support (Aparat / Youtube) */}
|
||||
{isIframe ? (
|
||||
<div className="w-full h-full flex items-center justify-center relative">
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="absolute top-4 left-4 z-30 p-2.5 rounded-full bg-black/60 hover:bg-black/90 text-white transition-all cursor-pointer"
|
||||
title="بستن"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
<div
|
||||
className="w-full h-full [&>iframe]:w-full [&>iframe]:h-full"
|
||||
dangerouslySetInnerHTML={{ __html: video.videoUrl || '' }}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{/* Native Video Element */}
|
||||
<div
|
||||
className="absolute inset-0 flex items-center justify-center cursor-pointer"
|
||||
onClick={togglePlay}
|
||||
>
|
||||
<video
|
||||
ref={videoRef}
|
||||
src={video.videoUrl}
|
||||
poster={video.thumbnail}
|
||||
autoPlay
|
||||
playsInline
|
||||
onPlay={() => setIsPlaying(true)}
|
||||
onPause={() => setIsPlaying(false)}
|
||||
onTimeUpdate={() => {
|
||||
if (videoRef.current) {
|
||||
setCurrentTime(videoRef.current.currentTime);
|
||||
updateBuffer();
|
||||
}
|
||||
}}
|
||||
onProgress={updateBuffer}
|
||||
onLoadedMetadata={() => {
|
||||
if (videoRef.current) setDuration(videoRef.current.duration);
|
||||
setIsBuffering(false);
|
||||
updateBuffer();
|
||||
}}
|
||||
onWaiting={() => setIsBuffering(true)}
|
||||
onPlaying={() => setIsBuffering(false)}
|
||||
onEnded={() => {
|
||||
setIsPlaying(false);
|
||||
setShowControls(true);
|
||||
}}
|
||||
className="w-full h-full object-contain"
|
||||
{/* Modal Window Wrapper */}
|
||||
<div className="relative w-full max-w-5xl flex flex-col gap-3 my-auto z-10">
|
||||
<motion.div
|
||||
ref={containerRef}
|
||||
initial={{ opacity: 0, scale: 0.95, y: 15 }}
|
||||
animate={{ opacity: 1, scale: 1, y: 0 }}
|
||||
exit={{ opacity: 0, scale: 0.95, y: 15 }}
|
||||
transition={{ duration: 0.25 }}
|
||||
onMouseMove={resetControlsTimer}
|
||||
onTouchStart={resetControlsTimer}
|
||||
className="relative bg-black w-full aspect-video rounded-3xl sm:rounded-[2.5rem] overflow-hidden shadow-2xl border border-white/10 flex flex-col justify-between select-none"
|
||||
>
|
||||
{/* Iframe Support (Aparat / Youtube) */}
|
||||
{isIframe ? (
|
||||
<div className="w-full h-full flex items-center justify-center relative">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="absolute top-4 left-4 z-30 p-2.5 rounded-full bg-black/60 hover:bg-black/90 text-white transition-all cursor-pointer"
|
||||
title="بستن"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
<div
|
||||
className="w-full h-full [&>iframe]:w-full [&>iframe]:h-full"
|
||||
dangerouslySetInnerHTML={{ __html: video.videoUrl || '' }}
|
||||
/>
|
||||
|
||||
{/* Buffering Spinner */}
|
||||
{isBuffering && (
|
||||
<div className="absolute inset-0 flex items-center justify-center bg-black/30 backdrop-blur-2xs pointer-events-none">
|
||||
<Loader2 className="w-12 h-12 text-white animate-spin" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{/* Native Video Element */}
|
||||
<div
|
||||
className="absolute inset-0 flex items-center justify-center cursor-pointer"
|
||||
onClick={togglePlay}
|
||||
>
|
||||
<video
|
||||
ref={videoRef}
|
||||
src={video.videoUrl}
|
||||
poster={video.thumbnail}
|
||||
autoPlay
|
||||
playsInline
|
||||
onPlay={() => setIsPlaying(true)}
|
||||
onPause={() => setIsPlaying(false)}
|
||||
onTimeUpdate={() => {
|
||||
if (videoRef.current) {
|
||||
setCurrentTime(videoRef.current.currentTime);
|
||||
updateBuffer();
|
||||
}
|
||||
}}
|
||||
onProgress={updateBuffer}
|
||||
onLoadedMetadata={() => {
|
||||
if (videoRef.current) setDuration(videoRef.current.duration);
|
||||
setIsBuffering(false);
|
||||
updateBuffer();
|
||||
}}
|
||||
onWaiting={() => setIsBuffering(true)}
|
||||
onPlaying={() => setIsBuffering(false)}
|
||||
onEnded={() => {
|
||||
setIsPlaying(false);
|
||||
setShowControls(true);
|
||||
}}
|
||||
className="w-full h-full object-contain"
|
||||
/>
|
||||
|
||||
{/* Top Header Overlay */}
|
||||
<div
|
||||
className={`absolute top-0 left-0 right-0 p-4 sm:p-6 bg-gradient-to-b from-black/80 via-black/40 to-transparent transition-opacity duration-300 z-20 flex items-center justify-between ${
|
||||
showControls ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center gap-3 text-right">
|
||||
<div className="w-8 h-8 rounded-full bg-canina-blue/20 text-canina-blue flex items-center justify-center shrink-0">
|
||||
<Sparkles className="w-4 h-4" />
|
||||
{/* Buffering Spinner */}
|
||||
{isBuffering && (
|
||||
<div className="absolute inset-0 flex items-center justify-center bg-black/30 backdrop-blur-2xs pointer-events-none">
|
||||
<Loader2 className="w-12 h-12 text-white animate-spin" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Top Header Overlay */}
|
||||
<div
|
||||
className={`absolute top-0 left-0 right-0 p-4 sm:p-6 bg-gradient-to-b from-black/80 via-black/40 to-transparent transition-opacity duration-300 z-20 flex items-center justify-between ${
|
||||
showControls ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center gap-3 text-right">
|
||||
<div className="w-8 h-8 rounded-full bg-canina-blue/20 text-canina-blue flex items-center justify-center shrink-0">
|
||||
<Sparkles className="w-4 h-4" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-white text-sm sm:text-base md:text-lg font-black line-clamp-1">
|
||||
{video.title}
|
||||
</h3>
|
||||
<p className="text-white/60 text-xs font-bold mt-0.5">
|
||||
{video.doctor || "کادر علمی کنینا"}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-white text-base sm:text-lg font-black line-clamp-1">
|
||||
{video.title}
|
||||
</h3>
|
||||
<p className="text-white/60 text-xs font-bold mt-0.5">
|
||||
{video.doctor || "کادر علمی کنینا"}
|
||||
</p>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{/* Share button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); handleShare(); }}
|
||||
className="p-2.5 rounded-full bg-white/10 hover:bg-white/20 text-white transition-all cursor-pointer relative"
|
||||
title="اشتراکگذاری"
|
||||
>
|
||||
{isCopied ? <Check className="w-4 h-4 text-emerald-400" /> : <Share2 className="w-4 h-4" />}
|
||||
</button>
|
||||
|
||||
{/* Download button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); handleDownload(); }}
|
||||
className="p-2.5 rounded-full bg-white/10 hover:bg-white/20 text-white transition-all cursor-pointer"
|
||||
title="دانلود ویدئو"
|
||||
>
|
||||
<Download className="w-4 h-4" />
|
||||
</button>
|
||||
|
||||
{/* Close button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); onClose(); }}
|
||||
className="p-2.5 rounded-full bg-white/10 hover:bg-red-500/80 text-white transition-all cursor-pointer"
|
||||
title="بستن"
|
||||
>
|
||||
<X className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{/* Share button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); handleShare(); }}
|
||||
className="p-2.5 rounded-full bg-white/10 hover:bg-white/20 text-white transition-all cursor-pointer relative"
|
||||
title="اشتراکگذاری"
|
||||
>
|
||||
{isCopied ? <Check className="w-4 h-4 text-emerald-400" /> : <Share2 className="w-4 h-4" />}
|
||||
</button>
|
||||
|
||||
{/* Download button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); handleDownload(); }}
|
||||
className="p-2.5 rounded-full bg-white/10 hover:bg-white/20 text-white transition-all cursor-pointer"
|
||||
title="دانلود ویدئو"
|
||||
>
|
||||
<Download className="w-4 h-4" />
|
||||
</button>
|
||||
|
||||
{/* Close button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); onClose(); }}
|
||||
className="p-2.5 rounded-full bg-white/10 hover:bg-red-500/80 text-white transition-all cursor-pointer"
|
||||
title="بستن"
|
||||
>
|
||||
<X className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Bottom Custom Controls Bar */}
|
||||
<div
|
||||
className={`absolute bottom-0 left-0 right-0 p-4 sm:p-6 bg-gradient-to-t from-black/90 via-black/60 to-transparent transition-opacity duration-300 z-20 space-y-3 ${
|
||||
showControls ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
|
||||
}`}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* Expandable Description Box if available */}
|
||||
{video.description && (
|
||||
<div className="bg-white/10 backdrop-blur-md rounded-2xl p-3 text-white text-xs border border-white/10">
|
||||
<p className={`font-medium leading-relaxed ${isExpandedDesc ? "" : "line-clamp-1"}`}>
|
||||
{video.description}
|
||||
</p>
|
||||
{video.description.length > 80 && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsExpandedDesc(!isExpandedDesc)}
|
||||
className="text-canina-blue hover:underline font-bold mt-1 inline-flex items-center gap-1 cursor-pointer"
|
||||
>
|
||||
<span>{isExpandedDesc ? "بستن توضیحات" : "مشاهده بیشتر توضیحات"}</span>
|
||||
{isExpandedDesc ? <ChevronUp className="w-3 h-3" /> : <ChevronDown className="w-3 h-3" />}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{/* Bottom Custom Controls Bar */}
|
||||
<div
|
||||
className={`absolute bottom-0 left-0 right-0 p-4 sm:p-6 bg-gradient-to-t from-black/90 via-black/60 to-transparent transition-opacity duration-300 z-20 space-y-3 ${
|
||||
showControls ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
|
||||
}`}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
|
||||
{/* Progress / Seek Bar with filled progress & buffer tracks */}
|
||||
<div className="flex items-center gap-3 dir-ltr" dir="ltr">
|
||||
@@ -570,7 +570,30 @@ export default function VideoModalPlayer({ isOpen, onClose, video }: VideoModalP
|
||||
</>
|
||||
)}
|
||||
</motion.div>
|
||||
|
||||
{/* Video Description Box (Rendered outside & below the video player for clean viewing) */}
|
||||
{video.description && (
|
||||
<div className="bg-neutral-900/90 backdrop-blur-md rounded-2xl p-4 text-white text-xs border border-white/10 shadow-xl space-y-2 text-right">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="font-black text-canina-blue text-xs">توضیحات و نکات علمی ویدئو:</span>
|
||||
{video.description.length > 120 && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsExpandedDesc(!isExpandedDesc)}
|
||||
className="text-white/60 hover:text-white text-[11px] font-bold inline-flex items-center gap-1 cursor-pointer"
|
||||
>
|
||||
<span>{isExpandedDesc ? "بستن متن" : "مشاهده کامل متن"}</span>
|
||||
{isExpandedDesc ? <ChevronUp className="w-3 h-3" /> : <ChevronDown className="w-3 h-3" />}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<p className={`font-medium text-white/80 leading-relaxed ${isExpandedDesc ? "" : "line-clamp-2"}`}>
|
||||
{video.description}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
</AnimatePresence>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
"use client";
|
||||
import React, { useState } from "react";
|
||||
import { motion } from "motion/react";
|
||||
import { ChevronLeft, PlayCircle, Search, Clock, User } from "lucide-react";
|
||||
import { ChevronLeft, PlayCircle, Search, Clock, User, Eye, Share2, Check } from "lucide-react";
|
||||
import SafeImage from "./SafeImage";
|
||||
|
||||
import BackButton from "./BackButton";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { videoService, Video } from "../lib/services/videoService";
|
||||
import { useRouter } from 'next/navigation';
|
||||
@@ -15,6 +16,7 @@ export default function VideosPage() {
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [selectedVideo, setSelectedVideo] = useState<Video | null>(null);
|
||||
const [search, setSearch] = useState("");
|
||||
const [isCopied, setIsCopied] = useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
setIsLoading(true);
|
||||
@@ -35,6 +37,15 @@ export default function VideosPage() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleSharePage = () => {
|
||||
if (typeof window !== 'undefined') {
|
||||
navigator.clipboard.writeText(window.location.href);
|
||||
setIsCopied(true);
|
||||
toast.success("لینک آکادمی ویدئویی کپی شد.");
|
||||
setTimeout(() => setIsCopied(false), 2000);
|
||||
}
|
||||
};
|
||||
|
||||
const filteredVideos = videos.filter(v =>
|
||||
(v.title || '').toLowerCase().includes(search.toLowerCase()) ||
|
||||
(v.doctor || '').toLowerCase().includes(search.toLowerCase()) ||
|
||||
@@ -42,26 +53,36 @@ export default function VideosPage() {
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-medical-gray-900 pt-8 pb-20 px-4 font-vazir" dir="rtl">
|
||||
<div className="min-h-screen bg-medical-gray-900 pt-6 pb-20 px-4 font-vazir" dir="rtl">
|
||||
<div className="max-w-7xl mx-auto">
|
||||
{/* Header */}
|
||||
<div className="flex flex-col md:flex-row items-center justify-between mb-16 gap-6">
|
||||
<div className="text-right">
|
||||
<div className="inline-flex items-center gap-2 px-3 py-1 bg-canina-blue/10 text-canina-blue rounded-full text-[10px] font-black uppercase tracking-widest mb-4">
|
||||
<PlayCircle className="w-3 h-3" />
|
||||
Video Academy
|
||||
</div>
|
||||
<h1 className="text-4xl lg:text-6xl font-black text-white italic leading-tight">
|
||||
آکادمی ویدئویی <span className="text-canina-blue">کنینا</span>
|
||||
</h1>
|
||||
{/* Standard Page Top Bar */}
|
||||
<div className="flex items-center justify-between gap-4 mb-8 bg-white/5 p-4 rounded-3xl border border-white/10 backdrop-blur-md">
|
||||
<div className="flex items-center gap-3">
|
||||
<BackButton className="bg-white/10 text-white border-white/15 hover:bg-white/20 hover:text-white" />
|
||||
<div className="hidden sm:inline-flex items-center gap-1.5 px-3 py-1 bg-canina-blue/20 text-canina-blue rounded-full text-xs font-black">
|
||||
<PlayCircle className="w-3.5 h-3.5" />
|
||||
<span>آکادمی تخصصی کنینا</span>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => router.push('/')}
|
||||
className="px-8 py-3 bg-white/5 border border-white/10 rounded-2xl text-white shadow-sm flex items-center gap-2 font-black hover:bg-white/10 transition-all font-vazir"
|
||||
>
|
||||
<span>بازگشت</span>
|
||||
<ChevronLeft className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleSharePage}
|
||||
className="inline-flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-white/10 hover:bg-white/20 text-white text-xs font-bold transition-all border border-white/10 cursor-pointer"
|
||||
>
|
||||
{isCopied ? <Check className="w-3.5 h-3.5 text-emerald-400" /> : <Share2 className="w-3.5 h-3.5" />}
|
||||
<span>اشتراکگذاری صفحه</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Title Header */}
|
||||
<div className="text-right mb-10">
|
||||
<h1 className="text-3xl lg:text-5xl font-black text-white italic leading-tight mb-2">
|
||||
آکادمی ویدئویی <span className="text-canina-blue">کنینا</span>
|
||||
</h1>
|
||||
<p className="text-white/60 text-xs sm:text-sm font-medium">
|
||||
ویدئوهای آموزشی، مشاورههای تخصصی دامپزشکی و راهنمای مصرف مکملها
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Search Bar */}
|
||||
@@ -72,7 +93,7 @@ export default function VideosPage() {
|
||||
placeholder="جستجو در ویدئوهای آموزشی..."
|
||||
value={search}
|
||||
onChange={e => setSearch(e.target.value)}
|
||||
className="w-full bg-white/5 border border-white/10 rounded-[2rem] py-5 pr-14 pl-6 text-white outline-none focus:bg-white/10 transition-all font-bold"
|
||||
className="w-full bg-white/5 border border-white/10 rounded-[2rem] py-4 pr-14 pl-6 text-white outline-none focus:bg-white/10 transition-all font-bold text-sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -107,39 +128,50 @@ export default function VideosPage() {
|
||||
videoService.incrementViews(video.id);
|
||||
}}
|
||||
>
|
||||
<div className="relative aspect-video rounded-[2.5rem] overflow-hidden mb-6 shadow-2xl border border-white/5 bg-black/40">
|
||||
<div className="relative aspect-video rounded-3xl overflow-hidden mb-4 shadow-2xl border border-white/5 bg-black/40">
|
||||
<SafeImage
|
||||
src={video.thumbnail}
|
||||
alt={video.title}
|
||||
className="w-full h-full"
|
||||
imgClassName="object-cover group-hover:scale-110 transition-transform duration-700 opacity-60 group-hover:opacity-100"
|
||||
imgClassName="object-cover group-hover:scale-105 transition-transform duration-500 opacity-70 group-hover:opacity-100"
|
||||
/>
|
||||
<div className="absolute inset-0 flex items-center justify-center">
|
||||
<div className="w-16 h-16 bg-canina-blue rounded-full flex items-center justify-center text-white shadow-2xl group-hover:scale-110 transition-transform">
|
||||
<PlayCircle className="w-10 h-10" />
|
||||
<div className="w-14 h-14 bg-canina-blue rounded-full flex items-center justify-center text-white shadow-xl group-hover:scale-110 transition-transform">
|
||||
<PlayCircle className="w-9 h-9" />
|
||||
</div>
|
||||
</div>
|
||||
{video.duration && (
|
||||
<div className="absolute bottom-4 right-4 bg-black/60 backdrop-blur-md text-white px-3 py-1 rounded-lg text-[10px] font-black">
|
||||
<div className="absolute bottom-3 right-3 bg-black/70 backdrop-blur-md text-white px-2.5 py-1 rounded-lg text-[10px] font-black">
|
||||
{video.duration}
|
||||
</div>
|
||||
)}
|
||||
{/* View Count Badge */}
|
||||
<div className="absolute top-3 left-3 bg-black/60 backdrop-blur-md text-white/90 px-2.5 py-1 rounded-lg text-[10px] font-bold flex items-center gap-1">
|
||||
<Eye className="w-3 h-3 text-canina-blue" />
|
||||
<span>{(video.viewsCount ?? 0).toLocaleString('fa-IR')}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="px-4">
|
||||
<h3 className="text-xl font-black text-white group-hover:text-canina-blue transition-colors mb-2 leading-tight">
|
||||
<div className="px-2">
|
||||
<h3 className="text-base sm:text-lg font-black text-white group-hover:text-canina-blue transition-colors mb-2 leading-snug line-clamp-2">
|
||||
{video.title}
|
||||
</h3>
|
||||
<div className="flex items-center gap-4 text-xs font-bold text-white/40">
|
||||
<div className="flex items-center justify-between text-xs font-bold text-white/40 pt-1">
|
||||
<div className="flex items-center gap-1">
|
||||
<User className="w-3 h-3" />
|
||||
{video.doctor || 'کادر علمی کنینا'}
|
||||
<User className="w-3.5 h-3.5" />
|
||||
<span>{video.doctor || 'کادر علمی کنینا'}</span>
|
||||
</div>
|
||||
{video.duration && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="w-3 h-3" />
|
||||
<span>{video.duration}</span>
|
||||
<div className="flex items-center gap-3">
|
||||
{video.duration && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="w-3 h-3" />
|
||||
<span>{video.duration}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center gap-1 text-white/60">
|
||||
<Eye className="w-3 h-3" />
|
||||
<span>{(video.viewsCount ?? 0).toLocaleString('fa-IR')}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
@@ -32,6 +32,13 @@ const mockProducts = [
|
||||
},
|
||||
];
|
||||
|
||||
const mockPush = vi.fn();
|
||||
vi.mock('next/navigation', () => ({
|
||||
useRouter: () => ({
|
||||
push: mockPush,
|
||||
}),
|
||||
}));
|
||||
|
||||
describe('FeaturedProducts', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
@@ -42,14 +49,14 @@ describe('FeaturedProducts', () => {
|
||||
|
||||
it('renders loading skeletons initially', () => {
|
||||
vi.mocked(productService.getFeaturedProducts).mockReturnValue(new Promise(() => {}));
|
||||
const { container } = render(<FeaturedProducts onProductClick={vi.fn()} onShopNavigate={vi.fn()} />);
|
||||
const { container } = render(<FeaturedProducts />);
|
||||
// Check if skeletons are present (e.g. searching for animate-pulse)
|
||||
expect(container.getElementsByClassName('animate-pulse').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('renders products once loaded', async () => {
|
||||
vi.mocked(productService.getFeaturedProducts).mockResolvedValue(mockProducts as unknown as ReturnType<typeof productService.getFeaturedProducts>);
|
||||
render(<FeaturedProducts onProductClick={vi.fn()} onShopNavigate={vi.fn()} />);
|
||||
render(<FeaturedProducts />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Canhydrox GAG')).toBeInTheDocument();
|
||||
@@ -57,26 +64,24 @@ describe('FeaturedProducts', () => {
|
||||
expect(screen.getByText('Joint helper')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onProductClick when product card is clicked', async () => {
|
||||
const handleProductClick = vi.fn();
|
||||
it('navigates to product details when product card is clicked', async () => {
|
||||
vi.mocked(productService.getFeaturedProducts).mockResolvedValue(mockProducts as unknown as ReturnType<typeof productService.getFeaturedProducts>);
|
||||
render(<FeaturedProducts onProductClick={handleProductClick} onShopNavigate={vi.fn()} />);
|
||||
render(<FeaturedProducts />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Canhydrox GAG')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
fireEvent.click(screen.getByText('Canhydrox GAG'));
|
||||
expect(handleProductClick).toHaveBeenCalledWith(mockProducts[0]);
|
||||
expect(mockPush).toHaveBeenCalledWith('/shop/prod-1');
|
||||
});
|
||||
|
||||
it('calls onShopNavigate when navigation link is clicked', async () => {
|
||||
const handleShopNavigate = vi.fn();
|
||||
it('navigates to shop when view all link is clicked', async () => {
|
||||
vi.mocked(productService.getFeaturedProducts).mockResolvedValue(mockProducts as unknown as ReturnType<typeof productService.getFeaturedProducts>);
|
||||
render(<FeaturedProducts onProductClick={vi.fn()} onShopNavigate={handleShopNavigate} />);
|
||||
render(<FeaturedProducts />);
|
||||
|
||||
const navBtn = screen.getByText('مشاهده تمامی محصولات');
|
||||
fireEvent.click(navBtn);
|
||||
expect(handleShopNavigate).toHaveBeenCalled();
|
||||
expect(mockPush).toHaveBeenCalledWith('/shop');
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
"use client";
|
||||
"use client";
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
@@ -6,39 +6,23 @@ import Footer from '../Footer';
|
||||
|
||||
describe('Footer', () => {
|
||||
it('renders footer brand text and standard layout elements', () => {
|
||||
render(<Footer onNavigate={vi.fn()} onShopNavigate={vi.fn()} onB2BOpen={vi.fn()} />);
|
||||
render(<Footer onB2BOpen={vi.fn()} />);
|
||||
|
||||
expect(screen.getByText('کنینا ایران')).toBeInTheDocument();
|
||||
expect(screen.getByText('نماینده رسمی در ایران')).toBeInTheDocument();
|
||||
expect(screen.getByText('Canina')).toBeInTheDocument();
|
||||
expect(screen.getByText('ایران')).toBeInTheDocument();
|
||||
expect(screen.getByText('تهران، جردن، خیابان سعیدی، ساختمان کنینا، طبقه ۵، واحد ۱۹')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('triggers onNavigate and onShopNavigate when quick links are clicked', () => {
|
||||
const handleNavigate = vi.fn();
|
||||
const handleShopNavigate = vi.fn();
|
||||
const handleB2BOpen = vi.fn();
|
||||
it('renders navigation links properly', () => {
|
||||
render(<Footer onB2BOpen={vi.fn()} />);
|
||||
|
||||
render(
|
||||
<Footer
|
||||
onNavigate={handleNavigate}
|
||||
onShopNavigate={handleShopNavigate}
|
||||
onB2BOpen={handleB2BOpen}
|
||||
/>
|
||||
);
|
||||
const shopLink = screen.getByText('محصولات تخصصی ۲۰۲۴').closest('a');
|
||||
expect(shopLink).toHaveAttribute('href', '/shop');
|
||||
|
||||
// Click quick link for shop
|
||||
const shopLink = screen.getByText('محصولات تخصصی ۲۰۲۴');
|
||||
fireEvent.click(shopLink);
|
||||
expect(handleShopNavigate).toHaveBeenCalled();
|
||||
const blogLink = screen.getByText('مجله سلامت پت (وبلاگ)').closest('a');
|
||||
expect(blogLink).toHaveAttribute('href', '/blog');
|
||||
|
||||
// Click quick link for blog
|
||||
const blogLink = screen.getByText('مجله سلامت پت (وبلاگ)');
|
||||
fireEvent.click(blogLink);
|
||||
expect(handleNavigate).toHaveBeenCalledWith('blog');
|
||||
|
||||
// Click B2B link
|
||||
const b2bLink = screen.getByText('پنل سفارش عمده (B2B)');
|
||||
fireEvent.click(b2bLink);
|
||||
expect(handleB2BOpen).toHaveBeenCalled();
|
||||
const trustLink = screen.getByText('نمادهای اعتماد و مجوزهای رسمی').closest('a');
|
||||
expect(trustLink).toHaveAttribute('href', '/trust-seals');
|
||||
});
|
||||
});
|
||||
@@ -86,7 +86,9 @@ describe('Header', () => {
|
||||
);
|
||||
|
||||
expect(screen.queryByText('ورود / ثبتنام')).not.toBeInTheDocument();
|
||||
expect(screen.getByText('کوروش')).toBeInTheDocument();
|
||||
const userBtn = screen.getByText('کوروش');
|
||||
expect(userBtn).toBeInTheDocument();
|
||||
fireEvent.click(userBtn);
|
||||
expect(screen.getByText('ملوس')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user