feat(ux): complete 5-task suite (category filter, real total count, mobile wiki, blog mobile UX, chatbot typewriter)
Deploy Canina / deploy (push) Successful in 2m12s
Deploy Canina / deploy (push) Successful in 2m12s
This commit is contained in:
1 parent
3d45b618ab
commit
092933860a
4 files changed
+182
-79
No files matched your search
@@ -921,7 +921,7 @@ export default function ArchivePage({
|
||||
}}
|
||||
className={`flex items-center gap-1.5 px-3 py-1.5 rounded-xl border text-[11px] font-black shadow-2xs transition-all whitespace-nowrap ${selectedCategory !== "all" ? "bg-canina-blue text-white border-canina-blue" : "bg-white border-medical-gray-200 text-medical-gray-700"}`}
|
||||
>
|
||||
<span>{selectedCategory !== "all" ? (CATEGORY_LABELS[selectedCategory] || "راهکار درمانی") : "راهکار درمانی"}</span>
|
||||
<span>{selectedCategory !== "all" ? (CATEGORY_LABELS[selectedCategory] || "دستهبندی") : "دستهبندی و راهکار"}</span>
|
||||
<ChevronDown className={`w-3 h-3 transition-transform ${isMobileSolutionsOpen ? "rotate-180" : ""}`} />
|
||||
</button>
|
||||
|
||||
@@ -933,7 +933,7 @@ export default function ArchivePage({
|
||||
>
|
||||
<div className="w-10 h-1 bg-medical-gray-200 rounded-full mx-auto mb-3 shrink-0" />
|
||||
<div className="flex items-center justify-between pb-3 border-b border-medical-gray-100 mb-3 shrink-0">
|
||||
<h4 className="font-black text-sm text-medical-gray-900">انتخاب راهکار درمانی</h4>
|
||||
<h4 className="font-black text-sm text-medical-gray-900">فیلتر دستهبندی و راهکار درمانی</h4>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsMobileSolutionsOpen(false)}
|
||||
@@ -1122,15 +1122,20 @@ export default function ArchivePage({
|
||||
{(() => {
|
||||
const slicedProducts = filteredProducts.slice(0, visibleCount);
|
||||
const hasMore = visibleCount < filteredProducts.length;
|
||||
const totalInStock = filteredProducts.filter(product => !isProductOutOfStock(product)).length;
|
||||
const totalOutOfStock = filteredProducts.filter(product => isProductOutOfStock(product)).length;
|
||||
|
||||
const sections = [
|
||||
{
|
||||
key: "available",
|
||||
title: "محصولات موجود",
|
||||
totalCount: totalInStock,
|
||||
products: slicedProducts.filter(product => !isProductOutOfStock(product)),
|
||||
},
|
||||
{
|
||||
key: "unavailable",
|
||||
title: "محصولات ناموجود",
|
||||
totalCount: totalOutOfStock,
|
||||
products: slicedProducts.filter(product => isProductOutOfStock(product)),
|
||||
}
|
||||
] as const;
|
||||
@@ -1142,7 +1147,7 @@ export default function ArchivePage({
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h2 className="text-xl font-black text-medical-gray-900">{section.title}</h2>
|
||||
<span className="text-xs font-bold text-medical-gray-400">
|
||||
{toPersian(section.products.length)} محصول
|
||||
{toPersian(section.totalCount)} محصول
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
|
||||
@@ -17,7 +17,9 @@ import {
|
||||
Pin,
|
||||
Eye,
|
||||
Filter,
|
||||
SlidersHorizontal,
|
||||
} from "lucide-react";
|
||||
import { toPersian } from "../lib/utils";
|
||||
import { toast } from "sonner";
|
||||
import { Product } from "../lib/data/products";
|
||||
import { productService } from "../lib/services/productService";
|
||||
@@ -63,11 +65,14 @@ export default function BlogPage({
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>(initialCategoryId);
|
||||
const [searchQuery, setSearchQuery] = useState<string>("");
|
||||
const [selectedTag, setSelectedTag] = useState<string | null>(null);
|
||||
const [sortBy, setSortBy] = useState<"newest" | "oldest" | "most_viewed">("newest");
|
||||
const [visibleCount, setVisibleCount] = useState<number>(6);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (initialCategoryId) {
|
||||
setSelectedCategory(initialCategoryId);
|
||||
}
|
||||
setVisibleCount(6);
|
||||
}, [initialCategoryId]);
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -90,8 +95,16 @@ export default function BlogPage({
|
||||
(b.tags && b.tags.some((t) => t.name === selectedTag));
|
||||
|
||||
return matchCategory && matchSearch && matchTag;
|
||||
}).sort((a, b) => {
|
||||
if (sortBy === "most_viewed") {
|
||||
return (b.viewCount ?? 0) - (a.viewCount ?? 0);
|
||||
}
|
||||
if (sortBy === "oldest") {
|
||||
return new Date(a.date).getTime() - new Date(b.date).getTime();
|
||||
}
|
||||
return new Date(b.date).getTime() - new Date(a.date).getTime();
|
||||
});
|
||||
}, [blogs, selectedCategory, searchQuery, selectedTag]);
|
||||
}, [blogs, selectedCategory, searchQuery, selectedTag, sortBy]);
|
||||
|
||||
// Featured post (prioritize featured flag, otherwise the first item)
|
||||
const featuredPost = useMemo(() => {
|
||||
@@ -106,6 +119,12 @@ export default function BlogPage({
|
||||
return filteredBlogs.filter((b) => b.id !== featuredPost.id);
|
||||
}, [filteredBlogs, featuredPost]);
|
||||
|
||||
const slicedRegularPosts = useMemo(() => {
|
||||
return regularPosts.slice(0, visibleCount);
|
||||
}, [regularPosts, visibleCount]);
|
||||
|
||||
const hasMore = visibleCount < regularPosts.length;
|
||||
|
||||
// Extract all unique tags
|
||||
const allTags = useMemo(() => {
|
||||
const map = new Map<string, string>();
|
||||
@@ -153,35 +172,57 @@ export default function BlogPage({
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Search & Category Filter Section */}
|
||||
<div className="bg-white p-6 rounded-3xl border border-medical-gray-200 shadow-sm mb-12 space-y-5">
|
||||
<div className="flex flex-col md:flex-row items-center gap-4">
|
||||
{/* Search & Category Filter Section - Styled like /shop filters */}
|
||||
<div className="bg-white p-3.5 sm:p-6 rounded-2xl sm:rounded-3xl border border-medical-gray-200 shadow-xs mb-8 space-y-3 sm:space-y-4">
|
||||
<div className="flex flex-col sm:flex-row items-center gap-2 sm:gap-4">
|
||||
{/* Search Input */}
|
||||
<div className="relative flex-1 w-full">
|
||||
<Search className="w-4 h-4 absolute right-4 top-1/2 -translate-y-1/2 text-medical-gray-400" />
|
||||
<Search className="w-4 h-4 absolute right-3.5 top-1/2 -translate-y-1/2 text-medical-gray-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجو در موضوعات، بیماریها، ویتامینها..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="w-full pl-4 pr-11 py-3 rounded-2xl bg-medical-gray-50 border border-medical-gray-200 focus:border-canina-blue focus:bg-white text-xs sm:text-sm font-bold outline-none transition-all"
|
||||
onChange={(e) => {
|
||||
setSearchQuery(e.target.value);
|
||||
setVisibleCount(6);
|
||||
}}
|
||||
className="w-full pl-4 pr-10 py-2.5 rounded-xl sm:rounded-2xl bg-medical-gray-50 border border-medical-gray-200 focus:border-canina-blue focus:bg-white text-xs sm:text-sm font-bold outline-none transition-all"
|
||||
/>
|
||||
{searchQuery && (
|
||||
<button
|
||||
onClick={() => setSearchQuery("")}
|
||||
className="absolute left-3 top-1/2 -translate-y-1/2 text-xs font-bold text-medical-gray-400 hover:text-medical-gray-600"
|
||||
className="absolute left-3 top-1/2 -translate-y-1/2 text-xs font-bold text-medical-gray-400 hover:text-medical-gray-600 cursor-pointer"
|
||||
>
|
||||
پاک کردن
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Sort Dropdown */}
|
||||
<div className="relative w-full sm:w-auto flex-shrink-0">
|
||||
<div className="flex items-center bg-white border border-medical-gray-200 rounded-xl px-3 py-2 shadow-2xs text-xs font-bold text-medical-gray-700 w-full sm:w-auto justify-between sm:justify-start">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<SlidersHorizontal className="w-3.5 h-3.5 text-canina-blue shrink-0" />
|
||||
<span className="text-medical-gray-400 text-[10px] whitespace-nowrap">مرتبسازی:</span>
|
||||
</div>
|
||||
<select
|
||||
value={sortBy}
|
||||
onChange={(e) => setSortBy(e.target.value as any)}
|
||||
className="bg-transparent text-xs font-black text-medical-gray-900 outline-none cursor-pointer pr-1"
|
||||
>
|
||||
<option value="newest">جدیدترین مقالات</option>
|
||||
<option value="oldest">قدیمیترین</option>
|
||||
<option value="most_viewed">پربازدیدترینها</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{selectedTag && (
|
||||
<div className="flex items-center gap-2 px-3 py-2 bg-purple-50 text-purple-700 border border-purple-200 rounded-xl text-xs font-bold">
|
||||
<span>تگ انتخاب شده: #{selectedTag}</span>
|
||||
<div className="flex items-center gap-2 px-3 py-1.5 bg-purple-50 text-purple-700 border border-purple-200 rounded-xl text-xs font-bold self-start sm:self-auto">
|
||||
<span>تگ: #{selectedTag}</span>
|
||||
<button
|
||||
onClick={() => setSelectedTag(null)}
|
||||
className="text-purple-500 hover:text-purple-900"
|
||||
className="text-purple-500 hover:text-purple-900 cursor-pointer"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
@@ -189,54 +230,61 @@ export default function BlogPage({
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Category Filter Pills */}
|
||||
<div className="flex items-center gap-2 overflow-x-auto pb-1 scrollbar-none">
|
||||
<button
|
||||
onClick={() => {
|
||||
setSelectedCategory("ALL");
|
||||
router.replace('/blog', { scroll: false });
|
||||
}}
|
||||
className={`px-4 py-2 rounded-2xl text-xs font-black transition-all cursor-pointer whitespace-nowrap ${
|
||||
selectedCategory === "ALL"
|
||||
? "bg-canina-blue text-white shadow-md shadow-canina-blue/20 scale-102"
|
||||
: "bg-medical-gray-100 text-medical-gray-600 hover:bg-medical-gray-200"
|
||||
}`}
|
||||
>
|
||||
همه دستهها ({blogs.length})
|
||||
</button>
|
||||
{categories.map((c) => (
|
||||
{/* Category Filter Pills with smooth edge mask */}
|
||||
<div className="relative -mx-3.5 sm:mx-0 px-3.5 sm:px-0">
|
||||
<div className="flex items-center gap-1.5 sm:gap-2 overflow-x-auto pb-1 micro-hscroll select-none mobile-filter-mask">
|
||||
<button
|
||||
key={c.id}
|
||||
onClick={() => {
|
||||
setSelectedCategory(c.id);
|
||||
router.replace(`/blog?categoryId=${c.id}`, { scroll: false });
|
||||
setSelectedCategory("ALL");
|
||||
setVisibleCount(6);
|
||||
router.replace('/blog', { scroll: false });
|
||||
}}
|
||||
className={`px-4 py-2 rounded-2xl text-xs font-black transition-all cursor-pointer whitespace-nowrap ${
|
||||
selectedCategory === c.id
|
||||
? "bg-canina-blue text-white shadow-md shadow-canina-blue/20 scale-102"
|
||||
: "bg-medical-gray-100 text-medical-gray-600 hover:bg-medical-gray-200"
|
||||
className={`px-3.5 py-1.5 sm:px-4 sm:py-2 rounded-xl sm:rounded-2xl text-xs font-black transition-all cursor-pointer whitespace-nowrap border shrink-0 ${
|
||||
selectedCategory === "ALL"
|
||||
? "bg-canina-blue text-white border-canina-blue shadow-xs"
|
||||
: "bg-medical-gray-50 border-medical-gray-200 text-medical-gray-600 hover:border-canina-blue/40"
|
||||
}`}
|
||||
>
|
||||
{c.name}
|
||||
همه دستهها ({blogs.length})
|
||||
</button>
|
||||
))}
|
||||
{categories.map((c) => (
|
||||
<button
|
||||
key={c.id}
|
||||
onClick={() => {
|
||||
setSelectedCategory(c.id);
|
||||
setVisibleCount(6);
|
||||
router.replace(`/blog?categoryId=${c.id}`, { scroll: false });
|
||||
}}
|
||||
className={`px-3.5 py-1.5 sm:px-4 sm:py-2 rounded-xl sm:rounded-2xl text-xs font-black transition-all cursor-pointer whitespace-nowrap border shrink-0 ${
|
||||
selectedCategory === c.id
|
||||
? "bg-canina-blue text-white border-canina-blue shadow-xs"
|
||||
: "bg-medical-gray-50 border-medical-gray-200 text-medical-gray-600 hover:border-canina-blue/40"
|
||||
}`}
|
||||
>
|
||||
{c.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Quick Tag Cloud */}
|
||||
{allTags.length > 0 && (
|
||||
<div className="flex flex-wrap items-center gap-1.5 pt-2 border-t border-medical-gray-100">
|
||||
<span className="text-[11px] font-bold text-medical-gray-400 flex items-center gap-1 ml-2">
|
||||
<span className="text-[10px] sm:text-[11px] font-bold text-medical-gray-400 flex items-center gap-1 ml-1">
|
||||
<Tag className="w-3 h-3" />
|
||||
محبوبترین تگها:
|
||||
تگهای محبوب:
|
||||
</span>
|
||||
{allTags.slice(0, 10).map((tag) => (
|
||||
{allTags.slice(0, 8).map((tag) => (
|
||||
<button
|
||||
key={tag}
|
||||
onClick={() => setSelectedTag(selectedTag === tag ? null : tag)}
|
||||
className={`text-[11px] font-bold px-2.5 py-1 rounded-lg transition-all cursor-pointer ${
|
||||
onClick={() => {
|
||||
setSelectedTag(selectedTag === tag ? null : tag);
|
||||
setVisibleCount(6);
|
||||
}}
|
||||
className={`text-[10px] sm:text-[11px] font-bold px-2 py-0.5 sm:px-2.5 sm:py-1 rounded-lg transition-all cursor-pointer border ${
|
||||
selectedTag === tag
|
||||
? "bg-purple-600 text-white"
|
||||
: "bg-medical-gray-100 text-medical-gray-600 hover:bg-medical-gray-200"
|
||||
? "bg-purple-600 text-white border-purple-600"
|
||||
: "bg-medical-gray-50 text-medical-gray-600 border-medical-gray-200 hover:bg-medical-gray-100"
|
||||
}`}
|
||||
>
|
||||
#{tag}
|
||||
@@ -315,17 +363,25 @@ export default function BlogPage({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Regular Posts Grid */}
|
||||
{regularPosts.length > 0 ? (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
|
||||
{regularPosts.map((post, idx) => (
|
||||
{/* Regular Posts Grid - Mobile-Optimized */}
|
||||
{slicedRegularPosts.length > 0 ? (
|
||||
<>
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h2 className="text-base sm:text-xl font-black text-medical-gray-900 font-vazir">همه مقالات تخصصی</h2>
|
||||
<span className="text-xs font-bold text-medical-gray-400">
|
||||
{toPersian(regularPosts.length)} مقاله
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 sm:gap-8">
|
||||
{slicedRegularPosts.map((post, idx) => (
|
||||
<motion.div
|
||||
key={post.id}
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
whileInView={{ opacity: 1, y: 0 }}
|
||||
viewport={{ once: true }}
|
||||
transition={{ delay: idx * 0.05 }}
|
||||
className="bg-white rounded-[2.5rem] overflow-hidden border border-medical-gray-200 shadow-lg group hover:shadow-2xl hover:border-canina-blue/30 transition-all cursor-pointer flex flex-col justify-between"
|
||||
className="bg-white rounded-2xl sm:rounded-[2.5rem] overflow-hidden border border-medical-gray-200 shadow-xs sm:shadow-lg group hover:shadow-xl hover:border-canina-blue/30 transition-all cursor-pointer flex flex-col justify-between"
|
||||
onClick={() => router.push(`/blog/${encodeURIComponent(post.slug || post.id)}`)}
|
||||
>
|
||||
<div>
|
||||
@@ -348,7 +404,7 @@ export default function BlogPage({
|
||||
<span>{(post.viewCount ?? 0).toLocaleString('fa-IR')}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="p-6 sm:p-7">
|
||||
<div className="p-4 sm:p-7">
|
||||
<div className="flex items-center justify-between text-[11px] font-bold text-medical-gray-400 mb-3">
|
||||
<div className="flex items-center gap-1">
|
||||
<Calendar className="w-3 h-3" />
|
||||
@@ -374,7 +430,7 @@ export default function BlogPage({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="px-6 sm:px-7 pb-6 pt-3 border-t border-medical-gray-100 flex items-center justify-between">
|
||||
<div className="px-4 sm:px-7 pb-4 sm:pb-6 pt-2.5 border-t border-medical-gray-100 flex items-center justify-between">
|
||||
<div className="text-[11px] font-bold text-medical-gray-500 flex items-center gap-1.5">
|
||||
<User className="w-3.5 h-3.5 text-medical-gray-400" />
|
||||
<span>{post.author}</span>
|
||||
@@ -387,6 +443,22 @@ export default function BlogPage({
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{hasMore && (
|
||||
<div className="mt-8 mb-4 text-center">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setVisibleCount(prev => prev + 6)}
|
||||
className="inline-flex items-center gap-2 px-6 py-3 bg-white border border-medical-gray-200 hover:border-canina-blue text-canina-blue font-black text-xs sm:text-sm rounded-2xl shadow-xs hover:shadow-md active:scale-95 transition-all cursor-pointer font-vazir"
|
||||
>
|
||||
<span>مشاهده ۶ مقاله بیشتر</span>
|
||||
<span className="text-xs text-medical-gray-400 font-bold">
|
||||
(نمایش {toPersian(slicedRegularPosts.length)} از {toPersian(regularPosts.length)})
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<div className="text-center py-16 bg-white rounded-3xl border border-medical-gray-200">
|
||||
<p className="text-medical-gray-500 font-bold text-sm">
|
||||
|
||||
@@ -166,36 +166,36 @@ export default function IngredientWiki() {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col items-center text-center mb-20">
|
||||
<div className="inline-flex items-center gap-2 px-4 py-2 bg-canina-blue/5 border border-canina-blue/10 rounded-full text-canina-blue text-xs font-black uppercase tracking-widest mb-6">
|
||||
<FlaskConical className="w-4 h-4" />
|
||||
علم در خدمت کیفیت
|
||||
<div className="flex flex-col items-center text-center mb-6 sm:mb-14">
|
||||
<div className="inline-flex items-center gap-2 px-3 py-1 sm:px-4 sm:py-2 bg-canina-blue/5 border border-canina-blue/10 rounded-full text-canina-blue text-[11px] sm:text-xs font-black uppercase tracking-widest mb-2 sm:mb-4">
|
||||
<FlaskConical className="w-3.5 h-3.5" />
|
||||
<span>علم در خدمت کیفیت</span>
|
||||
</div>
|
||||
<h1 className="text-4xl lg:text-6xl font-black text-medical-gray-900 leading-tight md:max-w-4xl">
|
||||
<h1 className="text-2xl sm:text-4xl lg:text-5xl font-black text-medical-gray-900 leading-tight md:max-w-4xl font-lalezar tracking-wide">
|
||||
دانشنامه مواد <span className="text-canina-blue italic">نایاب و ارگانیک</span> کنینا
|
||||
</h1>
|
||||
<p className="mt-6 text-lg text-medical-gray-500 max-w-2xl leading-relaxed">
|
||||
<p className="mt-2 sm:mt-4 text-xs sm:text-base text-medical-gray-500 max-w-2xl leading-relaxed">
|
||||
تمامی ترکیبات فعال و مکملهای به کار رفته در محصولات دارویی و مراقبتی Canina Pharma آلمان، دارای بالاترین گرید بیولوژیک و فارماکوپه اروپا میباشند.
|
||||
</p>
|
||||
<div className="relative w-full max-w-md mt-8">
|
||||
<Search className="absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-medical-gray-400" />
|
||||
<div className="relative w-full max-w-md mt-4 sm:mt-6">
|
||||
<Search className="absolute right-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-medical-gray-400" />
|
||||
<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-full py-3 pr-11 pl-4 text-sm focus:outline-none focus:ring-2 focus:ring-canina-blue/20"
|
||||
className="w-full bg-white border border-medical-gray-200 rounded-2xl py-2.5 sm:py-3 pr-10 pl-4 text-xs sm:text-sm focus:outline-none focus:ring-2 focus:ring-canina-blue/20 shadow-xs"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Sugar-Free & Gluten-Free Medical Standards Banner */}
|
||||
<div className="mt-8 flex flex-wrap items-center justify-center gap-3">
|
||||
<div className="px-4 py-2 bg-emerald-50 border border-emerald-200 text-emerald-800 rounded-2xl text-xs font-black flex items-center gap-1.5 shadow-xs">
|
||||
<CheckCircle2 className="w-4 h-4 text-emerald-600" />
|
||||
<div className="mt-3 sm:mt-6 flex flex-wrap items-center justify-center gap-2">
|
||||
<div className="px-3 py-1.5 sm:px-4 sm:py-2 bg-emerald-50 border border-emerald-200 text-emerald-800 rounded-xl sm:rounded-2xl text-[10px] sm:text-xs font-black flex items-center gap-1.5 shadow-2xs">
|
||||
<CheckCircle2 className="w-3.5 h-3.5 text-emerald-600" />
|
||||
<span>۱۰۰٪ فاقد قند افزوده (Sugar-Free)</span>
|
||||
</div>
|
||||
<div className="px-4 py-2 bg-blue-50 border border-blue-200 text-blue-800 rounded-2xl text-xs font-black flex items-center gap-1.5 shadow-xs">
|
||||
<CheckCircle2 className="w-4 h-4 text-blue-600" />
|
||||
<div className="px-3 py-1.5 sm:px-4 sm:py-2 bg-blue-50 border border-blue-200 text-blue-800 rounded-xl sm:rounded-2xl text-[10px] sm:text-xs font-black flex items-center gap-1.5 shadow-2xs">
|
||||
<CheckCircle2 className="w-3.5 h-3.5 text-blue-600" />
|
||||
<span>مطابق استانداردهای دارویی و بالینی آلمان</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -219,7 +219,7 @@ export default function IngredientWiki() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-24">
|
||||
<div className="space-y-5 sm:space-y-12">
|
||||
{filtered.map((ing, idx) => {
|
||||
const hasIngredient = getProductsForIngredient(ing.id, ing.name);
|
||||
const isTargeted = termParam === ing.id;
|
||||
@@ -228,7 +228,7 @@ export default function IngredientWiki() {
|
||||
<div
|
||||
key={ing.id}
|
||||
id={`wiki-${ing.id}`}
|
||||
className={`flex flex-col lg:flex-row items-stretch gap-12 p-8 sm:p-12 rounded-[3.5rem] transition-all duration-500 border border-medical-gray-100 shadow-sm hover:shadow-xl ${isTargeted ? 'bg-canina-blue/5 border-2 border-canina-blue ring-4 ring-canina-blue/10 shadow-2xl' : 'bg-white'} ${idx % 2 === 1 ? 'lg:flex-row-reverse' : ''}`}
|
||||
className={`flex flex-col lg:flex-row items-stretch gap-5 sm:gap-10 p-4 sm:p-8 lg:p-10 rounded-2xl sm:rounded-[2.5rem] transition-all duration-300 border border-medical-gray-200/80 shadow-xs hover:shadow-lg ${isTargeted ? 'bg-canina-blue/5 border-2 border-canina-blue ring-4 ring-canina-blue/10 shadow-xl' : 'bg-white'} ${idx % 2 === 1 ? 'lg:flex-row-reverse' : ''}`}
|
||||
>
|
||||
{/* Content */}
|
||||
<div className="lg:w-1/2 flex flex-col justify-between space-y-6">
|
||||
@@ -238,23 +238,23 @@ export default function IngredientWiki() {
|
||||
viewport={{ once: true }}
|
||||
transition={{ duration: 0.6 }}
|
||||
>
|
||||
<div className="flex items-center gap-4 mb-6">
|
||||
<div className="w-14 h-14 rounded-3xl bg-medical-gray-900 flex items-center justify-center text-white shadow-xl shrink-0">
|
||||
<div className="flex items-center gap-3 mb-3 sm:mb-4">
|
||||
<div className="w-10 h-10 sm:w-12 sm:h-12 rounded-xl sm:rounded-2xl bg-medical-gray-900 flex items-center justify-center text-white shadow-md shrink-0">
|
||||
<Beaker className="w-6 h-6 text-canina-gold" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-2xl sm:text-3xl font-black text-medical-gray-900 leading-tight font-vazir">{ing.name}</h3>
|
||||
<h3 className="text-base sm:text-2xl font-black text-medical-gray-900 leading-tight font-vazir">{ing.name}</h3>
|
||||
<span className="text-[12px] text-canina-blue font-bold tracking-wider font-vazir inline-block mt-1 bg-canina-blue/5 px-2.5 py-0.5 rounded-lg border border-canina-blue/10">کد ماده مؤثره: <span className="font-mono">{ing.id}</span></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="text-base text-medical-gray-600 leading-relaxed mb-6 font-vazir">
|
||||
<p className="text-xs sm:text-sm text-medical-gray-600 leading-relaxed mb-3 sm:mb-4 font-vazir">
|
||||
{ing.description}
|
||||
</p>
|
||||
|
||||
<div className="grid grid-cols-1 gap-3 mb-6">
|
||||
<div className="grid grid-cols-1 gap-2 mb-3 sm:mb-4">
|
||||
{ing.benefits.map((benefit, bIdx) => (
|
||||
<div key={bIdx} className="flex items-start gap-3 p-3.5 bg-medical-gray-50/80 rounded-2xl border border-medical-gray-100">
|
||||
<div key={bIdx} className="flex items-start gap-2.5 p-2.5 sm:p-3 bg-medical-gray-50/80 rounded-xl sm:rounded-2xl border border-medical-gray-100">
|
||||
<CheckCircle2 className="w-5 h-5 text-canina-blue shrink-0 mt-0.5" />
|
||||
<span className="text-xs sm:text-sm font-bold text-medical-gray-700 leading-relaxed font-vazir">{benefit}</span>
|
||||
</div>
|
||||
@@ -269,10 +269,10 @@ export default function IngredientWiki() {
|
||||
initial={{ opacity: 0, scale: 0.95 }}
|
||||
whileInView={{ opacity: 1, scale: 1 }}
|
||||
viewport={{ once: true }}
|
||||
className="bg-medical-gray-50/80 rounded-[3rem] p-6 sm:p-8 border border-medical-gray-200/60 relative overflow-hidden flex-1 flex flex-col justify-between"
|
||||
className="bg-medical-gray-50/80 rounded-xl sm:rounded-3xl p-3.5 sm:p-6 border border-medical-gray-200/60 relative overflow-hidden flex-1 flex flex-col justify-between"
|
||||
>
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-6 pb-4 border-b border-medical-gray-200/60">
|
||||
<div className="flex items-center justify-between mb-3 pb-2.5 border-b border-medical-gray-200/60">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="w-2.5 h-2.5 rounded-full bg-canina-blue animate-pulse" />
|
||||
<h4 className="text-xs sm:text-sm font-black text-medical-gray-900 font-vazir">موجود در محصولات کاتالوگ</h4>
|
||||
|
||||
@@ -160,9 +160,35 @@ export default function SupportChat() {
|
||||
// safe fallback kept
|
||||
}
|
||||
if (!controller.signal.aborted && token() === current) {
|
||||
setRows((r) => { const next = [...r]; const i = next.length - 1; if (i >= 0 && next[i].question === question && next[i].answer === 'در حال بررسی…') next[i] = { question, answer }; return next; });
|
||||
// Typewriting animation for smooth AI assistant response streaming feel
|
||||
const fullAnswer = answer;
|
||||
const stepSize = Math.max(2, Math.floor(fullAnswer.length / 40));
|
||||
let currentIdx = 0;
|
||||
|
||||
const typeInterval = setInterval(() => {
|
||||
currentIdx += stepSize;
|
||||
if (currentIdx >= fullAnswer.length || controller.signal.aborted) {
|
||||
clearInterval(typeInterval);
|
||||
setRows((r) => {
|
||||
const next = [...r];
|
||||
const i = next.length - 1;
|
||||
if (i >= 0 && next[i].question === question) next[i] = { question, answer: fullAnswer };
|
||||
return next;
|
||||
});
|
||||
if (pending.current === controller) setBusy(false);
|
||||
} else {
|
||||
const partial = fullAnswer.slice(0, currentIdx) + " ▍";
|
||||
setRows((r) => {
|
||||
const next = [...r];
|
||||
const i = next.length - 1;
|
||||
if (i >= 0 && next[i].question === question) next[i] = { question, answer: partial };
|
||||
return next;
|
||||
});
|
||||
}
|
||||
}, 18);
|
||||
} else {
|
||||
if (pending.current === controller) setBusy(false);
|
||||
}
|
||||
if (pending.current === controller) setBusy(false);
|
||||
}
|
||||
|
||||
if (!config?.enabled) return configError ? <span role="status" className="sr-only">تنظیمات پشتیبان هوشمند در دسترس نیست.</span> : null;
|
||||
|
||||
Reference in new issue
Block a user