export default async function LessonsSectionPage({ params }) {
const lessonsSection = await getLessonsSection( params.section );
const lessonChildrens = lessonsSection.cats.children_categories;
return (
<section
className={ `${ styles[ "lessons-section" ] } section` }
>
<h2 className="title">{ lessonsSection.cats.title }</h2>
{
lessonChildrens.length > 0 ? (
<ul className={ styles[ "lessons-section__list" ] }>
{
lessonChildrens.map( category => {
return (
<LessonsSectionItem
key={ category.slug }
lessonsSection={lessonsSection}
category={ category }
/>
);
} )
}
</ul>
)
: null
}
</section>
);
}
import { baseApi } from "@/utils/constants";
export const getLessonsSection = async(slug) => {
const response = await fetch( `${ baseApi }api/fullsinglecat/${slug }`, {
cache: "no-store",
}
);
if( !response.ok ) throw new Error( "Ошибка при получении секции" );
return response.json();
};
export default async function LessonsCatalogLayout({ children, }) {
return (
<>
<div className="lessons-catalog-layout">
<BreadcrumbsWrap
/>
<div className={ styles[ "lessons-catalog-wrap" ] }>
<LeftCatalogMenu />
{ children }
</div>
</div>
</>
);
}