category api - dashboard page
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user