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>
</>
);
}
const [ lessonSection, setLessonSection ] = useState( {} );
const [ lessonCategory, setLessonCategory ] = useState( {} );
const segments = useSelectedLayoutSegments();
useEffect( () => {
async function f() {
if( segments.length > 0 ) {
const newSection = await getLessonsSection( segments[ 0 ] );
setLessonSection( newSection );
}
if( segments.length > 1 ) {
const newCategory = await getLessonsSection( segments[ 1 ] );
setLessonCategory( newCategory );
}
}
f();
}, [ segments, lessonSection, lessonCategory ] );
type User {
id: Int!
firstName: String!
secondName: String!
email: String!
}
const GET_USER = gql`
query GetUser{
user{
id
firstName
secondName
email
}
}`;
Файл .env он находил.
Видимо, просто был какой-то баг. Я удалила файл package-lock.json, папку node_modules, заново установила все зависимости, а потом пересобрала проект. И ошибка пропала.