📄 Learning: раздел «Обучение» с 2 подразделами

Новое:
- Раздел «Обучение» (бывший «Учитель»)
- 2 подраздела:
  - 📄 Лекции — список по уровню, PDF viewer, скачивание
  - 📚 Уроки — бывший «Учитель» (работает как раньше)
- api.ts: getLectures, getLecture, downloadLecture
- App.tsx: роуты /learning, /lectures
- MenuPage.tsx: переименование «Учитель» → «Обучение»
- translations.ts: ключи learning, lectures, lessons
- LearningPage.tsx: новая страница с 2 карточками
- LecturesPage.tsx: список + viewer + скачивание

Пока лекций нет — показывается заглушка «Лекции в разработке».
This commit is contained in:
2026-09-26 19:47:57 +03:00
parent 08b030a5fd
commit 779d96919a
6 changed files with 692 additions and 4 deletions
+83 -1
View File
@@ -1352,4 +1352,86 @@ export interface WrongBecauseItem {
}
export const getWrongBecause = (): Promise<{ items: WrongBecauseItem[] }> =>
fetchAPI('/admin/content/wrong-because');
fetchAPI('/admin/content/wrong-because');
// ============ LECTURES (Лекции) ============
export interface LectureListItem {
id: number;
title_pl: string;
title_ru: string;
title_uk: string;
title_en: string;
description_pl: string;
description_ru: string;
description_uk: string;
description_en: string;
file_type: string;
file_size_kb: number;
order_number: number;
}
export interface LecturesListResponse {
level: string;
lectures: LectureListItem[];
}
export interface LectureDetail {
id: number;
level_code: string;
title_pl: string;
title_ru: string;
title_uk: string;
title_en: string;
description_pl: string;
description_ru: string;
description_uk: string;
description_en: string;
file_type: string;
file_size_kb: number;
file_url: string;
order_number: number;
}
/**
* Получить список лекций для уровня.
* Если level не передан — бэк возьмёт из профиля юзера.
*/
export const getLectures = (level?: string): Promise<LecturesListResponse> => {
const levelParam = level ? `?level=${encodeURIComponent(level)}` : '';
return fetchAPI(`/learning/lectures${levelParam}`);
};
/**
* Получить метаданные одной лекции.
*/
export const getLecture = (lectureId: number): Promise<LectureDetail> =>
fetchAPI(`/learning/lecture/${lectureId}`);
/**
* Скачать файл лекции.
* Возвращает blob, который можно сохранить.
*/
export const downloadLecture = async (lectureId: number): Promise<Blob> => {
const initData = getInitData();
if (!initData) {
throw new Error('Telegram initData недоступен. Откройте приложение через Telegram.');
}
const url = `${API_BASE}/learning/lecture/${lectureId}/download`;
const res = await fetchWithTimeout(url, {
method: 'GET',
headers: {
'Authorization': `tma ${initData}`,
},
});
if (!res.ok) {
const errorText = await res.text();
throw new Error(`API Error: ${res.status} - ${errorText}`);
}
return res.blob();
};