category api - dashboard page

This commit is contained in:
haniyeroozmand
2026-03-27 22:48:14 +03:30
parent 299eb2d968
commit 6d121f059d
13 changed files with 1013 additions and 187 deletions

View File

@@ -11,28 +11,20 @@ export default async function CategoryPage({ params }: PageProps) {
const resolvedParams = await params;
const rawCategoryName = resolvedParams.categoryName;
// چاپ در ترمینال (VSCode)
console.log("--- DEBUG START ---");
console.log("1. Raw Params:", resolvedParams);
// ۲. دیکد کردن آدرس
const decodedUrl = decodeURIComponent(rawCategoryName);
console.log("2. Decoded URL:", decodedUrl);
// ۳. آماده‌سازی رشته برای مقایسه
const categoryNameToMatch = decodedUrl.replace(/-/g, " ").trim();
console.log(`3. Final String to Match: "${categoryNameToMatch}"`);
// استخراج تمام دسته‌بندی‌های موجود در دیتابیس (برای بررسی چشمی)
const allCategoriesInDb = Array.from(new Set(products.map(p => p.category)));
console.log("4. Available DB Categories:", allCategoriesInDb);
// ۴. فیلتر کردن (با حذف فاصله‌های اضافی از دو طرف برای اطمینان)
const filteredProducts = products.filter(
(p) => p.category.trim() === categoryNameToMatch
);
console.log("5. Found Products:", filteredProducts.length);
console.log("--- DEBUG END ---");
// ۵. اگر پیدا نشد، صفحه دیباگ را در مرورگر نمایش بده
if (!filteredProducts || filteredProducts.length === 0) {