import React from 'react'; import { notFound } from 'next/navigation'; import { BreadcrumbsCategory } from '@/components/shared/breadcrumbs-category'; import { BlockAdts } from '@/components/shared/block-adts'; import { prisma } from '@/prisma/prisma-client'; type Params = Promise<{ category: string }> export default async function CategoryPage(props: { params: Params }) { const params = await props.params; const categorySlug = params.category; const category = await prisma.category.findFirst({ where: { slug: categorySlug }, include: { adts: true, children: { include: { adts: true } }, parent: true } }); if (!category) { return notFound(); } // Объединяем объявления текущей категории и всех подкатегорий const allAdts = [ ...category.adts, ...category.children.flatMap(child => child.adts) ]; // const aadts = await fetch(`/api/adt?category=${categorySlug}`).then(res => res.json()); return (

{category.nameEn}

{category.parentId && ( )}
{category.children.length > 0 && (

Подкатегории

{category.children.map((subcat) => ( {subcat.nameEn} ))}
)}

Объявления

{/* {allAdts.map((adt) => (
{adt.image && ( {adt.title} )}

{adt.title}

{adt.description}

{adt.price ? `${adt.price} ₽` : 'Цена не указана'}

))} */}
); }