From ffa6da7978e29190278173cdec15b7e5f19e13f4 Mon Sep 17 00:00:00 2001
From: parsa aghaei
Date: Tue, 21 Jul 2026 12:32:48 +0330
Subject: [PATCH] fix(shop): load all filtered products automatically without
manual pagination button
- Remove pagination limit cut-off so all matching products are displayed immediately
- Remove loadMore button for seamless full catalog browsing
---
.../application/components/ArchivePage.tsx | 45 ++-----------------
1 file changed, 4 insertions(+), 41 deletions(-)
diff --git a/frontend/application/components/ArchivePage.tsx b/frontend/application/components/ArchivePage.tsx
index 907455be..28e5153e 100644
--- a/frontend/application/components/ArchivePage.tsx
+++ b/frontend/application/components/ArchivePage.tsx
@@ -284,28 +284,24 @@ export default function ArchivePage({
router.push(newUrl, { scroll: false });
}, [selectedCategory, selectedPet, searchQuery, activeSymptoms]);
- const fetchProducts = async (resetPage = true) => {
+ const fetchProducts = async () => {
setIsUpdating(true);
try {
const res = await productService.getProducts({
category: selectedCategory,
petType: selectedPet,
query: searchQuery,
- // Send the first active symptom to the backend for server-side filtering
- symptom: activeSymptoms.length === 1 ? activeSymptoms[0] : undefined,
- page: resetPage ? 1 : page,
- limit: 20,
+ limit: 999,
});
let result = res.data;
- // If multiple symptoms selected, filter with OR logic (union of symptoms)
+ // Filter with OR logic (union of symptoms) if symptoms are active
if (activeSymptoms.length > 0) {
result = result.filter(p => p.symptoms && p.symptoms.some(s => activeSymptoms.includes(s)));
}
setFilteredProducts(result);
setMeta(res.meta);
- if (resetPage) setPage(1);
} catch (error) {
console.error("Failed to fetch products:", error);
toast.error("خطا در دریافت لیست محصولات از سرور. لطفاً صفحه را رفرش کنید.");
@@ -315,32 +311,9 @@ export default function ArchivePage({
};
useEffect(() => {
- fetchProducts(true);
+ 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,
- symptom: activeSymptoms.length === 1 ? activeSymptoms[0] : undefined,
- 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]);
};
@@ -502,16 +475,6 @@ export default function ArchivePage({
))}
- {page < meta.lastPage && (
-
-
-
- )}
>
) : (