feat: dynamic UI texts system + admin panel editor + Vazirmatn local font + bug fixes
- Add getText() system for all homepage sections (Header, Hero, FeaturedProducts, SmartAdvisor, VetGallery, Footer)
- Add UITexts admin page in frontend/admin-panel with search, group collapse, per-key save
- Add seed-ui-texts.ts with 102 texts in 9 groups
- Add local VazirmatnVariable.woff2 font, remove CDN + Inter references
- Fix hero image path, productService return type { data, meta }
- Fix ArchivePage pagination + CATEGORIES list + breadcrumbs
- Fix BlogPage/Wiki page links + brightness-0 invert removal
- Fix IngredientWiki search + product links + placeholder
- Fix all getProducts() callers for { data } destructuring
- Fix sitemap.ts, CartDrawer, B2BPortal, CheckoutPage type issues
- Add .gitignore for /fonts/ and /backend/uploads/
This commit is contained in:
1 parent
ab7ed279c8
commit
1a0c98a34e
26 files changed
+653
-132
No files matched your search
@@ -28,10 +28,12 @@ import SafeImage from "./SafeImage";
|
||||
|
||||
const CATEGORIES = [
|
||||
{ id: "all", label: "همه محصولات", icon: <Activity className="w-4 h-4" /> },
|
||||
{ id: "joints", label: "حرکتی و مفاصل", icon: <HeartPulse className="w-4 h-4" /> },
|
||||
{ id: "immune", label: "تقویت و ایمنی", icon: <ShieldCheck className="w-4 h-4" /> },
|
||||
{ id: "joints", label: "مفاصل و استخوان", icon: <HeartPulse className="w-4 h-4" /> },
|
||||
{ id: "immune", label: "ایمنی و گوارش", icon: <ShieldCheck className="w-4 h-4" /> },
|
||||
{ id: "energy", label: "ویتامین و انرژی", icon: <Activity className="w-4 h-4" /> },
|
||||
{ id: "special-care", label: "پلتفرم مراقبت ویژه", icon: <Stethoscope className="w-4 h-4" /> },
|
||||
{ id: "special-care", label: "مراقبت ویژه", icon: <Stethoscope className="w-4 h-4" /> },
|
||||
{ id: "general", label: "تقویت عمومی", icon: <Heart className="w-4 h-4" /> },
|
||||
{ id: "nutrition", label: "تغذیه تخصصی", icon: <Sparkles className="w-4 h-4" /> },
|
||||
];
|
||||
|
||||
const CATEGORY_MAP: Record<string, { category?: string; query?: string; symptoms?: string[] }> = {
|
||||
@@ -178,6 +180,18 @@ export default function ArchivePage({
|
||||
const [searchQuery, setSearchQuery] = useState(initialSearch);
|
||||
const [isUpdating, setIsUpdating] = useState(false);
|
||||
const [filteredProducts, setFilteredProducts] = useState<Product[]>([]);
|
||||
const [page, setPage] = useState(1);
|
||||
const [meta, setMeta] = useState({ total: 0, lastPage: 1 });
|
||||
|
||||
const CATEGORY_LABELS: Record<string, string> = {
|
||||
all: "همه محصولات",
|
||||
joints: "مفاصل و استخوان",
|
||||
immune: "ایمنی و گوارش",
|
||||
energy: "ویتامین و انرژی",
|
||||
"special-care": "مراقبت ویژه",
|
||||
general: "تقویت عمومی",
|
||||
nutrition: "تغذیه تخصصی",
|
||||
};
|
||||
|
||||
// Debug Log for Search Params
|
||||
useEffect(() => {
|
||||
@@ -228,18 +242,22 @@ export default function ArchivePage({
|
||||
const fetchProducts = async () => {
|
||||
setIsUpdating(true);
|
||||
try {
|
||||
const data = await productService.getProducts({
|
||||
const res = await productService.getProducts({
|
||||
category: selectedCategory,
|
||||
petType: selectedPet,
|
||||
query: searchQuery
|
||||
query: searchQuery,
|
||||
page: 1,
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
let result = data;
|
||||
let result = res.data;
|
||||
if (activeSymptoms.length > 0) {
|
||||
result = result.filter(p => p.symptoms.some(s => activeSymptoms.includes(s)));
|
||||
}
|
||||
|
||||
setFilteredProducts(result);
|
||||
setMeta(res.meta);
|
||||
setPage(1);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch products:", error);
|
||||
toast.error("خطا در دریافت لیست محصولات از سرور. لطفاً صفحه را رفرش کنید.");
|
||||
@@ -251,6 +269,28 @@ export default function ArchivePage({
|
||||
fetchProducts();
|
||||
}, [selectedCategory, selectedPet, searchQuery, activeSymptoms]);
|
||||
|
||||
const loadMore = async () => {
|
||||
if (page >= meta.lastPage) return;
|
||||
try {
|
||||
const res = await productService.getProducts({
|
||||
category: selectedCategory,
|
||||
petType: selectedPet,
|
||||
query: searchQuery,
|
||||
page: page + 1,
|
||||
limit: 20,
|
||||
});
|
||||
let newItems = res.data;
|
||||
if (activeSymptoms.length > 0) {
|
||||
newItems = newItems.filter(p => p.symptoms.some(s => activeSymptoms.includes(s)));
|
||||
}
|
||||
setFilteredProducts(prev => [...prev, ...newItems]);
|
||||
setMeta(res.meta);
|
||||
setPage(prev => prev + 1);
|
||||
} catch (error) {
|
||||
console.error("Failed to load more:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const toggleSymptom = (s: string) => {
|
||||
setActiveSymptoms(prev => prev.includes(s) ? prev.filter(item => item !== s) : [...prev, s]);
|
||||
};
|
||||
@@ -277,11 +317,17 @@ export default function ArchivePage({
|
||||
</div>
|
||||
|
||||
{/* Desktop Breadcrumbs */}
|
||||
<div className="hidden lg:flex items-center gap-2 text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-10">
|
||||
<div className="flex items-center gap-2 text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-10">
|
||||
<span className="cursor-pointer hover:text-canina-blue" onClick={() => router.push('/')}>خانه</span>
|
||||
<ChevronLeft className="w-2.5 h-2.5" />
|
||||
<span className="text-canina-blue">کاتالوگ کامل محصولات</span>
|
||||
</div>
|
||||
<span className="cursor-pointer hover:text-canina-blue" onClick={() => { setSelectedCategory("all"); }}>کاتالوگ</span>
|
||||
{selectedCategory !== "all" && (
|
||||
<>
|
||||
<ChevronLeft className="w-2.5 h-2.5" />
|
||||
<span className="text-canina-blue">{CATEGORY_LABELS[selectedCategory] || selectedCategory}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col lg:flex-row gap-10">
|
||||
|
||||
@@ -383,6 +429,7 @@ export default function ArchivePage({
|
||||
))}
|
||||
</div>
|
||||
) : filteredProducts.length > 0 ? (
|
||||
<>
|
||||
<div key="grid" className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-6">
|
||||
<AnimatePresence mode="popLayout">
|
||||
{filteredProducts.map((p: Product) => (
|
||||
@@ -390,6 +437,17 @@ export default function ArchivePage({
|
||||
))}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
{page < meta.lastPage && (
|
||||
<div className="flex justify-center mt-10">
|
||||
<button
|
||||
onClick={loadMore}
|
||||
className="bg-canina-blue text-white px-8 py-3 rounded-xl font-black text-sm hover:scale-105 transition-transform shadow-lg shadow-canina-blue/20"
|
||||
>
|
||||
بارگذاری محصولات بیشتر
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<div key="empty" className="bg-white rounded-[3rem] p-20 text-center border-2 border-dashed border-medical-gray-200 flex flex-col items-center">
|
||||
<div className="w-20 h-20 bg-medical-gray-50 rounded-full flex items-center justify-center text-medical-gray-300 mb-6">
|
||||
|
||||
Reference in new issue
Block a user