📄 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:
@@ -18,6 +18,8 @@ import PracticeViewPage from './pages/PracticeViewPage';
|
|||||||
import TeacherChatPage from './pages/TeacherChatPage';
|
import TeacherChatPage from './pages/TeacherChatPage';
|
||||||
import TypingPage from './pages/TypingPage';
|
import TypingPage from './pages/TypingPage';
|
||||||
import AdminDashboardModal from './components/AdminDashboardModal';
|
import AdminDashboardModal from './components/AdminDashboardModal';
|
||||||
|
import LearningPage from './pages/LearningPage';
|
||||||
|
import LecturesPage from './pages/LecturesPage';
|
||||||
// 🔧 ФИКС (25.09.2026): DEAD_CODE_GET_IS_ADMIN_FALLBACK —
|
// 🔧 ФИКС (25.09.2026): DEAD_CODE_GET_IS_ADMIN_FALLBACK —
|
||||||
// getIsAdmin больше не нужен: registerUser гарантирует is_admin: boolean.
|
// getIsAdmin больше не нужен: registerUser гарантирует is_admin: boolean.
|
||||||
import { registerUser, trackDailyLogin } from './api';
|
import { registerUser, trackDailyLogin } from './api';
|
||||||
@@ -244,6 +246,8 @@ function AppContent() {
|
|||||||
<Route path="/lessons/test/:topicId" element={<TestViewPage />} />
|
<Route path="/lessons/test/:topicId" element={<TestViewPage />} />
|
||||||
<Route path="/lessons/practice" element={<PracticeViewPage />} />
|
<Route path="/lessons/practice" element={<PracticeViewPage />} />
|
||||||
<Route path="/teacher" element={<TeacherChatPage />} />
|
<Route path="/teacher" element={<TeacherChatPage />} />
|
||||||
|
<Route path="/learning" element={<LearningPage />} />
|
||||||
|
<Route path="/lectures" element={<LecturesPage />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
|
||||||
{/* Дашборд админа — открывается через событие "open-dashboard" из MenuPage */}
|
{/* Дашборд админа — открывается через событие "open-dashboard" из MenuPage */}
|
||||||
|
|||||||
+83
-1
@@ -1352,4 +1352,86 @@ export interface WrongBecauseItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getWrongBecause = (): Promise<{ items: 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();
|
||||||
|
};
|
||||||
@@ -160,6 +160,10 @@ export const translations: Record<string, Record<string, string>> = {
|
|||||||
teacherMenuAdditional: "Dodatkowe",
|
teacherMenuAdditional: "Dodatkowe",
|
||||||
// 🔧 НОВОЕ: подсказка в обратном порядке
|
// 🔧 НОВОЕ: подсказка в обратном порядке
|
||||||
tryReverseOrder: "Spróbuj w odwrotnej kolejności",
|
tryReverseOrder: "Spróbuj w odwrotnej kolejności",
|
||||||
|
// ============ Learning (26.09.2026) ============
|
||||||
|
learning: "Nauka",
|
||||||
|
lectures: "Wykłady",
|
||||||
|
lessons: "Lekcje",
|
||||||
// ============ Onboarding ============
|
// ============ Onboarding ============
|
||||||
onboardingStep1Title: "Witaj! Jestem Marek.",
|
onboardingStep1Title: "Witaj! Jestem Marek.",
|
||||||
onboardingStep1Text: "Jestem twoim osobistym nauczycielem polskiego.\nBędę prowadzić cię krok po kroku, od pierwszego słowa do swobodnej rozmowy.",
|
onboardingStep1Text: "Jestem twoim osobistym nauczycielem polskiego.\nBędę prowadzić cię krok po kroku, od pierwszego słowa do swobodnej rozmowy.",
|
||||||
@@ -392,6 +396,10 @@ export const translations: Record<string, Record<string, string>> = {
|
|||||||
teacherMenuAdditional: "Дополнительное",
|
teacherMenuAdditional: "Дополнительное",
|
||||||
// 🔧 НОВОЕ: подсказка в обратном порядке
|
// 🔧 НОВОЕ: подсказка в обратном порядке
|
||||||
tryReverseOrder: "Попробуй в обратном порядке",
|
tryReverseOrder: "Попробуй в обратном порядке",
|
||||||
|
// ============ Learning (26.09.2026) ============
|
||||||
|
learning: "Обучение",
|
||||||
|
lectures: "Лекции",
|
||||||
|
lessons: "Уроки",
|
||||||
// ============ Onboarding ============
|
// ============ Onboarding ============
|
||||||
onboardingStep1Title: "Привет! Я Марек.",
|
onboardingStep1Title: "Привет! Я Марек.",
|
||||||
onboardingStep1Text: "Я твой личный учитель польского.\nБуду вести тебя шаг за шагом, от первого слова до свободного разговора.",
|
onboardingStep1Text: "Я твой личный учитель польского.\nБуду вести тебя шаг за шагом, от первого слова до свободного разговора.",
|
||||||
@@ -624,6 +632,10 @@ export const translations: Record<string, Record<string, string>> = {
|
|||||||
teacherMenuAdditional: "Додаткове",
|
teacherMenuAdditional: "Додаткове",
|
||||||
// 🔧 НОВОЕ: подсказка в обратном порядке
|
// 🔧 НОВОЕ: подсказка в обратном порядке
|
||||||
tryReverseOrder: "Спробуй у зворотному порядку",
|
tryReverseOrder: "Спробуй у зворотному порядку",
|
||||||
|
// ============ Learning (26.09.2026) ============
|
||||||
|
learning: "Навчання",
|
||||||
|
lectures: "Лекції",
|
||||||
|
lessons: "Уроки",
|
||||||
// ============ Onboarding ============
|
// ============ Onboarding ============
|
||||||
onboardingStep1Title: "Привіт! Я Марек.",
|
onboardingStep1Title: "Привіт! Я Марек.",
|
||||||
onboardingStep1Text: "Я твій особистий вчитель польської.\nБуду вести тебе крок за кроком, від першого слова до вільної розмови.",
|
onboardingStep1Text: "Я твій особистий вчитель польської.\nБуду вести тебе крок за кроком, від першого слова до вільної розмови.",
|
||||||
@@ -856,6 +868,10 @@ export const translations: Record<string, Record<string, string>> = {
|
|||||||
teacherMenuAdditional: "Additional",
|
teacherMenuAdditional: "Additional",
|
||||||
// 🔧 НОВОЕ: подсказка в обратном порядке
|
// 🔧 НОВОЕ: подсказка в обратном порядке
|
||||||
tryReverseOrder: "Try the reverse order",
|
tryReverseOrder: "Try the reverse order",
|
||||||
|
// ============ Learning (26.09.2026) ============
|
||||||
|
learning: "Learning",
|
||||||
|
lectures: "Lectures",
|
||||||
|
lessons: "Lessons",
|
||||||
// ============ Onboarding ============
|
// ============ Onboarding ============
|
||||||
onboardingStep1Title: "Hey! I'm Marek.",
|
onboardingStep1Title: "Hey! I'm Marek.",
|
||||||
onboardingStep1Text: "I'm your personal Polish teacher.\nI'll guide you step by step, from your very first word to a real conversation.",
|
onboardingStep1Text: "I'm your personal Polish teacher.\nI'll guide you step by step, from your very first word to a real conversation.",
|
||||||
|
|||||||
@@ -0,0 +1,190 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { useLanguage } from '../i18n/LanguageContext';
|
||||||
|
import { fonts, radius } from '../styles/theme';
|
||||||
|
import { trackTeacherMenuOpened } from '../api';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LearningPage — раздел «Обучение» с двумя подразделами:
|
||||||
|
* 1. 📄 Лекции (архивы PDF/HTML)
|
||||||
|
* 2. 📚 Уроки (бывший «Учитель»)
|
||||||
|
*/
|
||||||
|
const LearningPage: React.FC = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { t } = useLanguage();
|
||||||
|
|
||||||
|
const teacherColor = '#8B5CF6';
|
||||||
|
const lectureColor = '#4FA9E8';
|
||||||
|
const textColor = '#1A1A2E';
|
||||||
|
const subColor = '#6B7280';
|
||||||
|
|
||||||
|
const glass = (extra: React.CSSProperties = {}): React.CSSProperties => ({
|
||||||
|
background: 'rgba(255,255,255,0.55)',
|
||||||
|
backdropFilter: 'blur(24px) saturate(180%)',
|
||||||
|
WebkitBackdropFilter: 'blur(24px) saturate(180%)',
|
||||||
|
border: '1px solid rgba(255,255,255,0.7)',
|
||||||
|
boxShadow: '0 8px 32px rgba(31,38,73,0.10), inset 0 1px 0 rgba(255,255,255,0.85)',
|
||||||
|
...extra,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
trackTeacherMenuOpened().catch(() => {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const getCardStyle = (): React.CSSProperties => ({
|
||||||
|
padding: '24px',
|
||||||
|
borderRadius: radius.lg,
|
||||||
|
border: '1px solid rgba(255,255,255,0.7)',
|
||||||
|
background: 'rgba(255,255,255,0.55)',
|
||||||
|
backdropFilter: 'blur(24px) saturate(180%)',
|
||||||
|
WebkitBackdropFilter: 'blur(24px) saturate(180%)',
|
||||||
|
cursor: 'pointer',
|
||||||
|
transition: 'all 0.2s ease',
|
||||||
|
boxShadow: '0 6px 20px rgba(31,38,73,0.08), inset 0 1px 0 rgba(255,255,255,0.85)',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '16px',
|
||||||
|
textAlign: 'left',
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
minHeight: '100vh',
|
||||||
|
background: '#F4F5F7',
|
||||||
|
color: textColor,
|
||||||
|
fontFamily: fonts.main,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
padding: '24px',
|
||||||
|
position: 'relative',
|
||||||
|
overflow: 'hidden',
|
||||||
|
}}>
|
||||||
|
<div style={{ position: 'fixed', top: '-120px', left: '-90px', width: '320px', height: '320px', borderRadius: '50%', background: teacherColor, opacity: 0.25, filter: 'blur(90px)', pointerEvents: 'none', zIndex: 0 }} />
|
||||||
|
<div style={{ position: 'fixed', bottom: '-90px', right: '-40px', width: '260px', height: '260px', borderRadius: '50%', background: lectureColor, opacity: 0.22, filter: 'blur(90px)', pointerEvents: 'none', zIndex: 0 }} />
|
||||||
|
|
||||||
|
<div style={{ position: 'relative', zIndex: 1, display: 'flex', flexDirection: 'column', flex: 1 }}>
|
||||||
|
|
||||||
|
{/* Заголовок с кнопкой назад */}
|
||||||
|
<div style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '10px',
|
||||||
|
marginBottom: '32px',
|
||||||
|
}}>
|
||||||
|
<button
|
||||||
|
onClick={() => navigate('/menu')}
|
||||||
|
style={{
|
||||||
|
...glass({ padding: '10px 14px', borderRadius: radius.md }),
|
||||||
|
color: textColor,
|
||||||
|
fontSize: '14px',
|
||||||
|
fontWeight: 600,
|
||||||
|
cursor: 'pointer',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
←
|
||||||
|
</button>
|
||||||
|
<h1 style={{
|
||||||
|
fontSize: '24px',
|
||||||
|
fontWeight: 800,
|
||||||
|
margin: 0,
|
||||||
|
color: textColor,
|
||||||
|
}}>
|
||||||
|
🎓 {t('learning') || 'Обучение'}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Две карточки — Лекции и Уроки */}
|
||||||
|
<div style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: '16px',
|
||||||
|
flex: 1,
|
||||||
|
}}>
|
||||||
|
|
||||||
|
{/* Лекции */}
|
||||||
|
<button
|
||||||
|
onClick={() => navigate('/lectures')}
|
||||||
|
style={getCardStyle()}
|
||||||
|
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.98)'; }}
|
||||||
|
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||||
|
>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '48px',
|
||||||
|
flexShrink: 0,
|
||||||
|
}}>
|
||||||
|
📄
|
||||||
|
</div>
|
||||||
|
<div style={{ flex: 1 }}>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '20px',
|
||||||
|
fontWeight: 800,
|
||||||
|
color: textColor,
|
||||||
|
marginBottom: '4px',
|
||||||
|
}}>
|
||||||
|
{t('lectures') || 'Лекции'}
|
||||||
|
</div>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '14px',
|
||||||
|
color: subColor,
|
||||||
|
}}>
|
||||||
|
{t('lecturesDescription') || 'Тексты, PDF, шпаргалки по уровням'}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '20px',
|
||||||
|
color: lectureColor,
|
||||||
|
flexShrink: 0,
|
||||||
|
}}>
|
||||||
|
→
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{/* Уроки */}
|
||||||
|
<button
|
||||||
|
onClick={() => navigate('/teacher')}
|
||||||
|
style={getCardStyle()}
|
||||||
|
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.98)'; }}
|
||||||
|
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||||
|
>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '48px',
|
||||||
|
flexShrink: 0,
|
||||||
|
}}>
|
||||||
|
📚
|
||||||
|
</div>
|
||||||
|
<div style={{ flex: 1 }}>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '20px',
|
||||||
|
fontWeight: 800,
|
||||||
|
color: textColor,
|
||||||
|
marginBottom: '4px',
|
||||||
|
}}>
|
||||||
|
{t('lessons') || 'Уроки'}
|
||||||
|
</div>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '14px',
|
||||||
|
color: subColor,
|
||||||
|
}}>
|
||||||
|
{t('lessonsDescription') || 'Темы, уроки, задания и тесты'}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '20px',
|
||||||
|
color: teacherColor,
|
||||||
|
flexShrink: 0,
|
||||||
|
}}>
|
||||||
|
→
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style={{ textAlign: 'center', marginTop: '24px', color: '#9CA3AF', fontSize: '12px' }}>
|
||||||
|
Filwords PL © 2026
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LearningPage;
|
||||||
@@ -0,0 +1,390 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { useLanguage } from '../i18n/LanguageContext';
|
||||||
|
import { fonts, radius } from '../styles/theme';
|
||||||
|
import { getLectures, getLecture, downloadLecture, type LectureListItem, type LectureDetail } from '../api';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LecturesPage — список лекций по уровню пользователя.
|
||||||
|
* Открывает PDF/HTML в viewer, даёт скачать.
|
||||||
|
*/
|
||||||
|
const LecturesPage: React.FC = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { t, language } = useLanguage();
|
||||||
|
const [lectures, setLectures] = useState<LectureListItem[]>([]);
|
||||||
|
const [level, setLevel] = useState('A1');
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [activeLecture, setActiveLecture] = useState<LectureDetail | null>(null);
|
||||||
|
const [downloading, setDownloading] = useState(false);
|
||||||
|
|
||||||
|
const brandColor = '#2ECC71';
|
||||||
|
const lectureColor = '#4FA9E8';
|
||||||
|
const textColor = '#1A1A2E';
|
||||||
|
const subColor = '#6B7280';
|
||||||
|
|
||||||
|
const glass = (extra: React.CSSProperties = {}): React.CSSProperties => ({
|
||||||
|
background: 'rgba(255,255,255,0.55)',
|
||||||
|
backdropFilter: 'blur(24px) saturate(180%)',
|
||||||
|
WebkitBackdropFilter: 'blur(24px) saturate(180%)',
|
||||||
|
border: '1px solid rgba(255,255,255,0.7)',
|
||||||
|
boxShadow: '0 8px 32px rgba(31,38,73,0.10), inset 0 1px 0 rgba(255,255,255,0.85)',
|
||||||
|
...extra,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getLectures()
|
||||||
|
.then((data) => {
|
||||||
|
setLectures(data.lectures || []);
|
||||||
|
setLevel(data.level || 'A1');
|
||||||
|
setLoading(false);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.error('Failed to load lectures:', e);
|
||||||
|
setError(t('loadError') || 'Ошибка загрузки');
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const getTitle = (lecture: LectureListItem): string => {
|
||||||
|
const field = `title_${language}` as keyof LectureListItem;
|
||||||
|
return (lecture[field] as string) || lecture.title_en || lecture.title_pl || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDescription = (lecture: LectureListItem): string => {
|
||||||
|
const field = `description_${language}` as keyof LectureListItem;
|
||||||
|
return (lecture[field] as string) || lecture.description_en || lecture.description_pl || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleOpenLecture = async (lectureId: number) => {
|
||||||
|
try {
|
||||||
|
const detail = await getLecture(lectureId);
|
||||||
|
setActiveLecture(detail);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to open lecture:', e);
|
||||||
|
alert(t('loadError') || 'Ошибка загрузки');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDownload = async () => {
|
||||||
|
if (!activeLecture || downloading) return;
|
||||||
|
setDownloading(true);
|
||||||
|
try {
|
||||||
|
const blob = await downloadLecture(activeLecture.id);
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = `${activeLecture.title_pl || 'lecture'}.${activeLecture.file_type}`;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Download failed:', e);
|
||||||
|
alert(t('loadError') || 'Ошибка скачивания');
|
||||||
|
} finally {
|
||||||
|
setDownloading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ============ VIEWER ЛЕКЦИИ ============
|
||||||
|
if (activeLecture) {
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
minHeight: '100vh',
|
||||||
|
background: '#F4F5F7',
|
||||||
|
color: textColor,
|
||||||
|
fontFamily: fonts.main,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
position: 'relative',
|
||||||
|
overflow: 'hidden',
|
||||||
|
}}>
|
||||||
|
<div style={{ position: 'fixed', top: '-120px', left: '-90px', width: '320px', height: '320px', borderRadius: '50%', background: lectureColor, opacity: 0.20, filter: 'blur(90px)', pointerEvents: 'none', zIndex: 0 }} />
|
||||||
|
|
||||||
|
<div style={{ position: 'relative', zIndex: 1, display: 'flex', flexDirection: 'column', flex: 1, padding: '16px' }}>
|
||||||
|
|
||||||
|
{/* Заголовок */}
|
||||||
|
<div style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '10px',
|
||||||
|
marginBottom: '16px',
|
||||||
|
flexShrink: 0,
|
||||||
|
}}>
|
||||||
|
<button
|
||||||
|
onClick={() => setActiveLecture(null)}
|
||||||
|
style={{
|
||||||
|
...glass({ padding: '8px 14px', borderRadius: radius.sm }),
|
||||||
|
color: textColor,
|
||||||
|
fontSize: '13px',
|
||||||
|
fontWeight: 600,
|
||||||
|
cursor: 'pointer',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
←
|
||||||
|
</button>
|
||||||
|
<h1 style={{
|
||||||
|
fontSize: '16px',
|
||||||
|
fontWeight: 800,
|
||||||
|
margin: 0,
|
||||||
|
color: textColor,
|
||||||
|
flex: 1,
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
}}>
|
||||||
|
{activeLecture.title_pl}
|
||||||
|
</h1>
|
||||||
|
<button
|
||||||
|
onClick={handleDownload}
|
||||||
|
disabled={downloading}
|
||||||
|
style={{
|
||||||
|
...glass({ padding: '8px 14px', borderRadius: radius.sm }),
|
||||||
|
color: lectureColor,
|
||||||
|
fontSize: '13px',
|
||||||
|
fontWeight: 700,
|
||||||
|
cursor: downloading ? 'default' : 'pointer',
|
||||||
|
opacity: downloading ? 0.6 : 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{downloading ? '...' : '⬇'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Просмотр */}
|
||||||
|
<div style={{
|
||||||
|
flex: 1,
|
||||||
|
borderRadius: radius.lg,
|
||||||
|
background: 'rgba(255,255,255,0.85)',
|
||||||
|
border: '1px solid rgba(0,0,0,0.06)',
|
||||||
|
overflow: 'hidden',
|
||||||
|
boxShadow: '0 8px 32px rgba(31,38,73,0.10)',
|
||||||
|
minHeight: 0,
|
||||||
|
}}>
|
||||||
|
{activeLecture.file_type === 'pdf' ? (
|
||||||
|
<iframe
|
||||||
|
src={`https://api.filwordspl.com${activeLecture.file_url}`}
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
border: 'none',
|
||||||
|
}}
|
||||||
|
title={activeLecture.title_pl}
|
||||||
|
/>
|
||||||
|
) : activeLecture.file_type === 'html' ? (
|
||||||
|
<iframe
|
||||||
|
src={`https://api.filwordspl.com${activeLecture.file_url}`}
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
border: 'none',
|
||||||
|
}}
|
||||||
|
title={activeLecture.title_pl}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
height: '100%',
|
||||||
|
padding: '40px',
|
||||||
|
textAlign: 'center',
|
||||||
|
}}>
|
||||||
|
<div style={{ fontSize: '64px', marginBottom: '16px' }}>📄</div>
|
||||||
|
<p style={{ fontSize: '16px', color: subColor, marginBottom: '20px' }}>
|
||||||
|
{t('lecturePreviewNotAvailable') || 'Просмотр недоступен для этого формата'}
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
onClick={handleDownload}
|
||||||
|
disabled={downloading}
|
||||||
|
style={{
|
||||||
|
padding: '14px 28px',
|
||||||
|
borderRadius: radius.lg,
|
||||||
|
border: 'none',
|
||||||
|
background: `linear-gradient(135deg, ${lectureColor}, #3B82F6)`,
|
||||||
|
color: '#FFFFFF',
|
||||||
|
fontSize: '15px',
|
||||||
|
fontWeight: 700,
|
||||||
|
cursor: downloading ? 'default' : 'pointer',
|
||||||
|
opacity: downloading ? 0.6 : 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{downloading ? '...' : `⬇ ${t('download') || 'Скачать'}`}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ СПИСОК ЛЕКЦИЙ ============
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
minHeight: '100vh',
|
||||||
|
background: '#F4F5F7',
|
||||||
|
color: textColor,
|
||||||
|
fontFamily: fonts.main,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
padding: '24px',
|
||||||
|
position: 'relative',
|
||||||
|
overflow: 'hidden',
|
||||||
|
}}>
|
||||||
|
<div style={{ position: 'fixed', top: '-120px', left: '-90px', width: '320px', height: '320px', borderRadius: '50%', background: lectureColor, opacity: 0.20, filter: 'blur(90px)', pointerEvents: 'none', zIndex: 0 }} />
|
||||||
|
|
||||||
|
<div style={{ position: 'relative', zIndex: 1, display: 'flex', flexDirection: 'column', flex: 1 }}>
|
||||||
|
|
||||||
|
{/* Заголовок */}
|
||||||
|
<div style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '10px',
|
||||||
|
marginBottom: '24px',
|
||||||
|
}}>
|
||||||
|
<button
|
||||||
|
onClick={() => navigate('/learning')}
|
||||||
|
style={{
|
||||||
|
...glass({ padding: '10px 14px', borderRadius: radius.md }),
|
||||||
|
color: textColor,
|
||||||
|
fontSize: '14px',
|
||||||
|
fontWeight: 600,
|
||||||
|
cursor: 'pointer',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
←
|
||||||
|
</button>
|
||||||
|
<h1 style={{
|
||||||
|
fontSize: '22px',
|
||||||
|
fontWeight: 800,
|
||||||
|
margin: 0,
|
||||||
|
color: textColor,
|
||||||
|
flex: 1,
|
||||||
|
}}>
|
||||||
|
📄 {t('lectures') || 'Лекции'}
|
||||||
|
</h1>
|
||||||
|
<span style={{
|
||||||
|
...glass({ padding: '6px 12px', borderRadius: radius.sm }),
|
||||||
|
fontSize: '14px',
|
||||||
|
fontWeight: 800,
|
||||||
|
color: brandColor,
|
||||||
|
}}>
|
||||||
|
{level}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Список */}
|
||||||
|
{loading ? (
|
||||||
|
<div style={{ textAlign: 'center', padding: '40px', color: subColor }}>
|
||||||
|
{t('loading') || 'Загрузка...'}
|
||||||
|
</div>
|
||||||
|
) : error ? (
|
||||||
|
<div style={{ textAlign: 'center', padding: '40px', color: '#E74C3C' }}>
|
||||||
|
⚠️ {error}
|
||||||
|
</div>
|
||||||
|
) : lectures.length === 0 ? (
|
||||||
|
<div style={{
|
||||||
|
textAlign: 'center',
|
||||||
|
padding: '60px 20px',
|
||||||
|
color: subColor,
|
||||||
|
animation: 'fadeIn 0.3s ease',
|
||||||
|
}}>
|
||||||
|
<div style={{ fontSize: '64px', marginBottom: '16px' }}>📭</div>
|
||||||
|
<p style={{ fontSize: '16px', marginBottom: '8px', fontWeight: 600 }}>
|
||||||
|
{t('lecturesEmpty') || 'Лекции в разработке'}
|
||||||
|
</p>
|
||||||
|
<p style={{ fontSize: '14px', opacity: 0.7 }}>
|
||||||
|
{t('lecturesEmptyHint') || 'Скоро здесь появятся материалы для уровня'} {level}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: '12px',
|
||||||
|
}}>
|
||||||
|
{lectures.map((lecture) => (
|
||||||
|
<button
|
||||||
|
key={lecture.id}
|
||||||
|
onClick={() => handleOpenLecture(lecture.id)}
|
||||||
|
style={{
|
||||||
|
padding: '18px 20px',
|
||||||
|
borderRadius: radius.lg,
|
||||||
|
border: '1px solid rgba(255,255,255,0.7)',
|
||||||
|
background: 'rgba(255,255,255,0.55)',
|
||||||
|
backdropFilter: 'blur(24px) saturate(180%)',
|
||||||
|
WebkitBackdropFilter: 'blur(24px) saturate(180%)',
|
||||||
|
boxShadow: '0 6px 20px rgba(31,38,73,0.08), inset 0 1px 0 rgba(255,255,255,0.85)',
|
||||||
|
cursor: 'pointer',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '16px',
|
||||||
|
textAlign: 'left',
|
||||||
|
transition: 'all 0.2s ease',
|
||||||
|
}}
|
||||||
|
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.98)'; }}
|
||||||
|
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||||
|
>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '32px',
|
||||||
|
flexShrink: 0,
|
||||||
|
}}>
|
||||||
|
{lecture.file_type === 'pdf' ? '📕' : lecture.file_type === 'html' ? '🌐' : '📄'}
|
||||||
|
</div>
|
||||||
|
<div style={{ flex: 1, minWidth: 0 }}>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '16px',
|
||||||
|
fontWeight: 700,
|
||||||
|
color: textColor,
|
||||||
|
marginBottom: '4px',
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
}}>
|
||||||
|
{getTitle(lecture)}
|
||||||
|
</div>
|
||||||
|
{getDescription(lecture) && (
|
||||||
|
<div style={{
|
||||||
|
fontSize: '13px',
|
||||||
|
color: subColor,
|
||||||
|
marginBottom: '4px',
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
}}>
|
||||||
|
{getDescription(lecture)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div style={{
|
||||||
|
fontSize: '11px',
|
||||||
|
color: subColor,
|
||||||
|
opacity: 0.7,
|
||||||
|
}}>
|
||||||
|
{lecture.file_type.toUpperCase()} · {lecture.file_size_kb} KB
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style={{
|
||||||
|
fontSize: '20px',
|
||||||
|
color: lectureColor,
|
||||||
|
flexShrink: 0,
|
||||||
|
}}>
|
||||||
|
→
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div style={{ textAlign: 'center', marginTop: '24px', color: '#9CA3AF', fontSize: '12px' }}>
|
||||||
|
Filwords PL © 2026
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LecturesPage;
|
||||||
@@ -263,7 +263,10 @@ const MenuPage: React.FC = () => {
|
|||||||
|
|
||||||
// 🔧 ОБНОВЛЕНО: убраны typingHandlers и pronunciationHandlers —
|
// 🔧 ОБНОВЛЕНО: убраны typingHandlers и pronunciationHandlers —
|
||||||
// эти разделы теперь живут в меню учителя (☰ → Произношение / Печать).
|
// эти разделы теперь живут в меню учителя (☰ → Произношение / Печать).
|
||||||
const teacherHandlers = makeButtonHandlers('teacher', () => navigate('/teacher'));
|
// 🔧 ОБНОВЛЕНО (26.09.2026): teacherHandlers → learningHandlers.
|
||||||
|
// Кнопка 🎓 теперь ведёт на /learning (новый раздел «Обучение» с лекциями),
|
||||||
|
// а не на /teacher (старый чат-учитель).
|
||||||
|
const learningHandlers = makeButtonHandlers('teacher', () => navigate('/learning'));
|
||||||
const gamesHandlers = makeButtonHandlers('games', () => setShowGamesModal(true));
|
const gamesHandlers = makeButtonHandlers('games', () => setShowGamesModal(true));
|
||||||
const leaderboardHandlers = makeButtonHandlers('leaderboard', () => navigate('/leaderboard'));
|
const leaderboardHandlers = makeButtonHandlers('leaderboard', () => navigate('/leaderboard'));
|
||||||
const supportHandlers = makeButtonHandlers('support', () => setShowSupportModal(true));
|
const supportHandlers = makeButtonHandlers('support', () => setShowSupportModal(true));
|
||||||
@@ -826,8 +829,11 @@ const MenuPage: React.FC = () => {
|
|||||||
overflow: 'auto',
|
overflow: 'auto',
|
||||||
WebkitOverflowScrolling: 'touch',
|
WebkitOverflowScrolling: 'touch',
|
||||||
}}>
|
}}>
|
||||||
<button {...teacherHandlers} style={getButtonStyle('teacher', true)}>
|
{/* 🔧 ОБНОВЛЕНО (26.09.2026): кнопка 🎓 теперь ведёт на /learning.
|
||||||
<span>🎓</span> {t('teacher')}
|
Иконка и стиль остались те же (teacher-палитра),
|
||||||
|
чтобы не менять визуал. */}
|
||||||
|
<button {...learningHandlers} style={getButtonStyle('teacher', true)}>
|
||||||
|
<span>🎓</span> {t('learning') || 'Обучение'}
|
||||||
</button>
|
</button>
|
||||||
<button {...gamesHandlers} style={getButtonStyle('play')}>
|
<button {...gamesHandlers} style={getButtonStyle('play')}>
|
||||||
<span>🎮</span> {t('games') || 'Games'}
|
<span>🎮</span> {t('games') || 'Games'}
|
||||||
|
|||||||
Reference in New Issue
Block a user