Изменено: - Страница урока вместо ленты - Заголовок: A1 · Тема · Урок N/M - Карточки объяснения и задания - Кнопка «Следующий вопрос» после ответа - Экран «Урок завершён» - Убраны неиспользуемые: useCallback, loadTeacherHistory, teacherFreeMessage, wrongAnswerText, explanationText, handleFreeMessage
1226 lines
46 KiB
TypeScript
1226 lines
46 KiB
TypeScript
import { useState, useEffect, useRef } from 'react';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { useLanguage } from '../i18n/LanguageContext';
|
|
import { useLocalized } from '../hooks/useLocalized';
|
|
import { fonts, radius } from '../styles/theme';
|
|
import {
|
|
teacherStart,
|
|
teacherResume,
|
|
teacherAnswer,
|
|
teacherExamples,
|
|
getLearningAnalytics,
|
|
startWeakSkillsPractice,
|
|
getTTS,
|
|
saveTeacherHistory,
|
|
clearTeacherHistory,
|
|
} from '../api';
|
|
import TeacherMenuModal from '../components/TeacherMenuModal';
|
|
import TypingModal from '../components/TypingModal';
|
|
import PronunciationModal from '../components/PronunciationModal';
|
|
|
|
interface TeacherMessage {
|
|
id: number;
|
|
type: 'bot' | 'user' | 'system';
|
|
text: string;
|
|
isQuestion?: boolean;
|
|
questionType?: 'recognition' | 'production';
|
|
questionId?: string;
|
|
options?: Array<{
|
|
option_key: string;
|
|
text_pl: string;
|
|
text_ru: string;
|
|
text_uk: string;
|
|
text_en: string;
|
|
is_correct: boolean;
|
|
}>;
|
|
optionsLanguage?: 'pl' | 'user';
|
|
sessionId?: number;
|
|
lessonId?: string;
|
|
topicId?: string;
|
|
topicName?: string;
|
|
questionIndex?: number;
|
|
totalQuestions?: number;
|
|
commands?: string[];
|
|
isCorrect?: boolean;
|
|
isCompleted?: boolean;
|
|
hasPolishText?: boolean;
|
|
isLessonCard?: boolean;
|
|
}
|
|
|
|
// Экран: что показываем сейчас
|
|
type ScreenState =
|
|
| { kind: 'start' }
|
|
| { kind: 'lesson' }
|
|
| { kind: 'after-answer' }
|
|
| { kind: 'completed'; correct: number; total: number };
|
|
|
|
const STORAGE_KEY = 'filwords_teacher_chat_v2';
|
|
|
|
const TeacherChatPage: React.FC = () => {
|
|
const navigate = useNavigate();
|
|
const { t } = useLanguage();
|
|
const getLocalized = useLocalized();
|
|
|
|
// ============ СОСТОЯНИЕ ============
|
|
const [messages, setMessages] = useState<TeacherMessage[]>([]);
|
|
const [screen, setScreen] = useState<ScreenState>({ kind: 'start' });
|
|
const [inputValue, setInputValue] = useState('');
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
const [sessionId, setSessionId] = useState<number | null>(null);
|
|
const [currentLessonId, setCurrentLessonId] = useState<string>('');
|
|
const [currentTopicId, setCurrentTopicId] = useState<string>('');
|
|
const [currentTopicName, setCurrentTopicName] = useState<string>('');
|
|
const [currentLevel, setCurrentLevel] = useState<string>('A1');
|
|
const [currentQuestionId, setCurrentQuestionId] = useState<string>('');
|
|
const [isPlaying, setIsPlaying] = useState<number | null>(null);
|
|
const [showMenuModal, setShowMenuModal] = useState(false);
|
|
const [showTyping, setShowTyping] = useState(false);
|
|
const [showPronunciation, setShowPronunciation] = useState(false);
|
|
const [showExamplesModal, setShowExamplesModal] = useState(false);
|
|
const [examplesText, setExamplesText] = useState('');
|
|
const [isLoadingExamples, setIsLoadingExamples] = useState(false);
|
|
const [examplesError, setExamplesError] = useState<string | null>(null);
|
|
const [isStartingPractice, setIsStartingPractice] = useState(false);
|
|
const [playingExampleLine, setPlayingExampleLine] = useState<number | null>(null);
|
|
const [toastMessage, setToastMessage] = useState<string | null>(null);
|
|
|
|
// ============ REFS ============
|
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
const audioRef = useRef<HTMLAudioElement | null>(null);
|
|
const audioUrlRef = useRef<string | null>(null);
|
|
const idRef = useRef(0);
|
|
const toastTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
const historySaveTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
const startTimeRef = useRef<number>(Date.now());
|
|
const contentRef = useRef<HTMLDivElement>(null);
|
|
|
|
// ============ ЦВЕТА ============
|
|
const brandColor = '#2ECC71';
|
|
const teacherColor = '#8B5CF6';
|
|
const lectureColor = '#4FA9E8';
|
|
const textColor = '#1A1A2E';
|
|
const subColor = '#6B7280';
|
|
const bgColor = '#F4F5F7';
|
|
const cardBg = 'rgba(255,255,255,0.55)';
|
|
|
|
const glass = (extra: React.CSSProperties = {}): React.CSSProperties => ({
|
|
background: cardBg,
|
|
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,
|
|
});
|
|
|
|
// ============ HELPERS ============
|
|
const showToast = (msg: string) => {
|
|
setToastMessage(msg);
|
|
if (toastTimeoutRef.current) clearTimeout(toastTimeoutRef.current);
|
|
toastTimeoutRef.current = setTimeout(() => setToastMessage(null), 2500);
|
|
};
|
|
|
|
const hasPolishContent = (text: string): boolean => {
|
|
return text.includes('🇵🇱') || text.includes('→') || /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/.test(text);
|
|
};
|
|
|
|
const extractPolishText = (text: string): string => {
|
|
const lines = text.split('\n');
|
|
for (const line of lines) {
|
|
if (!line.trim()) continue;
|
|
if (line.includes('🇵🇱')) {
|
|
const polish = line.split('🇵🇱')[1]?.split('→')[0]?.trim();
|
|
if (polish) return polish;
|
|
}
|
|
if (line.includes('→')) {
|
|
const polish = line.split('→')[0]?.trim();
|
|
if (polish) return polish;
|
|
}
|
|
}
|
|
return '';
|
|
};
|
|
|
|
// ============ АУДИО ============
|
|
const stopAudio = () => {
|
|
if (audioRef.current) {
|
|
audioRef.current.pause();
|
|
audioRef.current = null;
|
|
}
|
|
if (audioUrlRef.current) {
|
|
try { URL.revokeObjectURL(audioUrlRef.current); } catch { /* ignore */ }
|
|
audioUrlRef.current = null;
|
|
}
|
|
if ('speechSynthesis' in window) {
|
|
window.speechSynthesis.cancel();
|
|
}
|
|
};
|
|
|
|
const playText = async (text: string, msgId: number) => {
|
|
const polishText = extractPolishText(text);
|
|
if (!polishText) return;
|
|
|
|
stopAudio();
|
|
setIsPlaying(msgId);
|
|
|
|
try {
|
|
const audioBlob = await getTTS(polishText, 'male');
|
|
const audioUrl = URL.createObjectURL(audioBlob);
|
|
audioUrlRef.current = audioUrl;
|
|
|
|
const audio = new Audio(audioUrl);
|
|
audioRef.current = audio;
|
|
|
|
audio.onended = () => {
|
|
setIsPlaying(null);
|
|
if (audioUrlRef.current === audioUrl) {
|
|
try { URL.revokeObjectURL(audioUrl); } catch { /* ignore */ }
|
|
audioUrlRef.current = null;
|
|
}
|
|
};
|
|
audio.onerror = () => {
|
|
setIsPlaying(null);
|
|
if (audioUrlRef.current === audioUrl) {
|
|
try { URL.revokeObjectURL(audioUrl); } catch { /* ignore */ }
|
|
audioUrlRef.current = null;
|
|
}
|
|
};
|
|
|
|
await audio.play();
|
|
} catch (e) {
|
|
console.error('TTS error:', e);
|
|
setIsPlaying(null);
|
|
}
|
|
};
|
|
|
|
const playExampleLine = async (line: string, index: number) => {
|
|
let polishText = '';
|
|
if (line.includes('🇵🇱')) {
|
|
polishText = line.split('🇵🇱')[1]?.split('→')[0]?.trim() || '';
|
|
} else if (line.includes('→')) {
|
|
polishText = line.split('→')[0]?.trim() || '';
|
|
}
|
|
if (!polishText) return;
|
|
|
|
stopAudio();
|
|
setPlayingExampleLine(index);
|
|
|
|
try {
|
|
const audioBlob = await getTTS(polishText, 'male');
|
|
const audioUrl = URL.createObjectURL(audioBlob);
|
|
audioUrlRef.current = audioUrl;
|
|
const audio = new Audio(audioUrl);
|
|
audioRef.current = audio;
|
|
audio.onended = () => {
|
|
setPlayingExampleLine(null);
|
|
if (audioUrlRef.current === audioUrl) {
|
|
try { URL.revokeObjectURL(audioUrl); } catch { /* ignore */ }
|
|
audioUrlRef.current = null;
|
|
}
|
|
};
|
|
audio.onerror = () => {
|
|
setPlayingExampleLine(null);
|
|
if (audioUrlRef.current === audioUrl) {
|
|
try { URL.revokeObjectURL(audioUrl); } catch { /* ignore */ }
|
|
audioUrlRef.current = null;
|
|
}
|
|
};
|
|
await audio.play();
|
|
} catch (e) {
|
|
console.error('TTS error:', e);
|
|
setPlayingExampleLine(null);
|
|
}
|
|
};
|
|
|
|
// ============ ВОССТАНОВЛЕНИЕ ============
|
|
useEffect(() => {
|
|
// 1. Загружаем историю из localStorage
|
|
try {
|
|
const saved = localStorage.getItem(STORAGE_KEY);
|
|
if (saved) {
|
|
const parsed = JSON.parse(saved);
|
|
if (Array.isArray(parsed) && parsed.length > 0) {
|
|
setMessages(parsed);
|
|
const maxId = Math.max(...parsed.map((m: TeacherMessage) => m.id));
|
|
idRef.current = maxId + 1;
|
|
|
|
// Восстанавливаем текущий экран
|
|
const lastQuestion = [...parsed].reverse().find((m: TeacherMessage) => m.isQuestion);
|
|
const lastMsg = parsed[parsed.length - 1];
|
|
|
|
if (lastMsg?.isCompleted) {
|
|
setScreen({ kind: 'completed', correct: 0, total: 0 });
|
|
} else if (lastQuestion) {
|
|
setCurrentQuestionId(lastQuestion.questionId || '');
|
|
setSessionId(lastQuestion.sessionId || null);
|
|
setCurrentLessonId(lastQuestion.lessonId || '');
|
|
setCurrentTopicId(lastQuestion.topicId || '');
|
|
setCurrentTopicName(lastQuestion.topicName || '');
|
|
setScreen({ kind: 'lesson' });
|
|
}
|
|
}
|
|
}
|
|
} catch (e) {
|
|
// ignore
|
|
}
|
|
|
|
// 2. Запрашиваем resume с сервера
|
|
teacherResume()
|
|
.then((resumeData) => {
|
|
if (resumeData.has_active_session && resumeData.question) {
|
|
setSessionId(resumeData.session_id || null);
|
|
setCurrentTopicId(resumeData.topic_id || '');
|
|
setCurrentLevel((resumeData as any).level_code || 'A1');
|
|
|
|
const questionId = resumeData.question.question.question_id;
|
|
|
|
setMessages(prev => {
|
|
const existingQuestion = [...prev].reverse().find(m => m.isQuestion);
|
|
if (existingQuestion) {
|
|
setCurrentQuestionId(existingQuestion.questionId || questionId);
|
|
setScreen({ kind: 'lesson' });
|
|
return prev;
|
|
}
|
|
|
|
setCurrentQuestionId(questionId);
|
|
setScreen({ kind: 'lesson' });
|
|
|
|
const questionMsg: TeacherMessage = {
|
|
id: idRef.current++,
|
|
type: 'bot',
|
|
text: getLocalized(resumeData.question.question, 'prompt'),
|
|
isQuestion: true,
|
|
questionType: resumeData.question.question.question_type,
|
|
questionId: questionId,
|
|
options: resumeData.question.options,
|
|
optionsLanguage: resumeData.question.question.options_language || 'pl',
|
|
sessionId: resumeData.session_id,
|
|
topicId: resumeData.topic_id,
|
|
questionIndex: resumeData.question_index,
|
|
totalQuestions: resumeData.total_questions,
|
|
};
|
|
|
|
return [...prev, questionMsg];
|
|
});
|
|
}
|
|
})
|
|
.catch(() => {});
|
|
}, []);
|
|
|
|
// ============ СОХРАНЕНИЕ ============
|
|
useEffect(() => {
|
|
try {
|
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(messages));
|
|
} catch (e) {
|
|
// ignore
|
|
}
|
|
if (messages.length === 0) return;
|
|
if (historySaveTimeoutRef.current) clearTimeout(historySaveTimeoutRef.current);
|
|
historySaveTimeoutRef.current = setTimeout(() => {
|
|
saveTeacherHistory(messages).catch(() => {});
|
|
}, 500);
|
|
return () => {
|
|
if (historySaveTimeoutRef.current) clearTimeout(historySaveTimeoutRef.current);
|
|
};
|
|
}, [messages]);
|
|
|
|
// ============ ФОКУС ============
|
|
useEffect(() => {
|
|
if (screen.kind === 'lesson') {
|
|
const lastQuestion = [...messages].reverse().find(m => m.isQuestion);
|
|
if (lastQuestion?.questionType === 'production') {
|
|
setTimeout(() => inputRef.current?.focus(), 300);
|
|
}
|
|
}
|
|
}, [screen.kind, messages]);
|
|
|
|
// ============ ФОКУС ============
|
|
useEffect(() => {
|
|
return () => {
|
|
stopAudio();
|
|
if (toastTimeoutRef.current) {
|
|
clearTimeout(toastTimeoutRef.current);
|
|
toastTimeoutRef.current = null;
|
|
}
|
|
};
|
|
}, []);
|
|
|
|
// ============ СКРОЛЛ НАВЕРХ ПРИ СМЕНЕ ЭКРАНА ============
|
|
useEffect(() => {
|
|
if (contentRef.current) {
|
|
contentRef.current.scrollTop = 0;
|
|
}
|
|
}, [screen.kind, currentQuestionId]);
|
|
|
|
// ============ HANDLERS ============
|
|
const handleClearChat = () => {
|
|
setMessages([]);
|
|
setScreen({ kind: 'start' });
|
|
setSessionId(null);
|
|
setCurrentQuestionId('');
|
|
setCurrentLessonId('');
|
|
setCurrentTopicId('');
|
|
setCurrentTopicName('');
|
|
localStorage.removeItem(STORAGE_KEY);
|
|
clearTeacherHistory().catch(() => {});
|
|
idRef.current = 0;
|
|
setShowMenuModal(false);
|
|
};
|
|
|
|
const handleCloseTyping = () => {
|
|
setShowTyping(false);
|
|
setShowMenuModal(true);
|
|
};
|
|
|
|
const handleClosePronunciation = () => {
|
|
setShowPronunciation(false);
|
|
setShowMenuModal(true);
|
|
};
|
|
|
|
const handleStart = async () => {
|
|
if (isLoading) return;
|
|
|
|
setShowMenuModal(false);
|
|
setIsLoading(true);
|
|
setSessionId(null);
|
|
setCurrentQuestionId('');
|
|
startTimeRef.current = Date.now();
|
|
|
|
try {
|
|
const data = await teacherStart();
|
|
|
|
if (data.session_id) setSessionId(data.session_id);
|
|
if (data.lesson_id) setCurrentLessonId(data.lesson_id);
|
|
if (data.topic_id) setCurrentTopicId(data.topic_id);
|
|
if (data.topic_name) setCurrentTopicName(data.topic_name);
|
|
if ((data as any).level_code) setCurrentLevel((data as any).level_code);
|
|
|
|
if (data.question) {
|
|
// Сохраняем сообщение-объяснение (без вопроса)
|
|
const lessonCardMsg: TeacherMessage = {
|
|
id: idRef.current++,
|
|
type: 'bot',
|
|
text: data.text,
|
|
topicId: data.topic_id,
|
|
topicName: data.topic_name,
|
|
hasPolishText: hasPolishContent(data.text),
|
|
isLessonCard: true,
|
|
};
|
|
|
|
// Сохраняем сообщение-вопрос
|
|
const questionMsg: TeacherMessage = {
|
|
id: idRef.current++,
|
|
type: 'bot',
|
|
text: getLocalized(data.question.question, 'prompt'),
|
|
isQuestion: true,
|
|
questionType: data.question.question.question_type,
|
|
questionId: data.question.question.question_id,
|
|
options: data.question.options,
|
|
optionsLanguage: data.question.question.options_language || 'pl',
|
|
sessionId: data.session_id,
|
|
lessonId: data.lesson_id,
|
|
topicId: data.topic_id,
|
|
topicName: data.topic_name,
|
|
questionIndex: data.question_index,
|
|
totalQuestions: data.total_questions,
|
|
};
|
|
|
|
setMessages(prev => [...prev, lessonCardMsg, questionMsg]);
|
|
setCurrentQuestionId(data.question.question.question_id);
|
|
setScreen({ kind: 'lesson' });
|
|
} else {
|
|
// Нет вопроса — урок завершён или тест
|
|
const botMessage: TeacherMessage = {
|
|
id: idRef.current++,
|
|
type: 'bot',
|
|
text: data.text,
|
|
topicId: data.topic_id,
|
|
topicName: data.topic_name,
|
|
hasPolishText: hasPolishContent(data.text),
|
|
isCompleted: data.message_type === 'completed',
|
|
};
|
|
setMessages(prev => [...prev, botMessage]);
|
|
|
|
if (data.message_type === 'completed') {
|
|
setScreen({ kind: 'completed', correct: 0, total: 0 });
|
|
}
|
|
}
|
|
} catch (e) {
|
|
console.error('Error starting teacher:', e);
|
|
showToast(t('teacherAIError') || 'Ошибка');
|
|
} finally {
|
|
setIsLoading(false);
|
|
}
|
|
};
|
|
|
|
const handleAnswer = async (answer: string) => {
|
|
if (!sessionId || !currentQuestionId || isLoading) return;
|
|
|
|
const timeTaken = Date.now() - startTimeRef.current;
|
|
startTimeRef.current = Date.now();
|
|
|
|
setIsLoading(true);
|
|
|
|
try {
|
|
const data = await teacherAnswer(sessionId, currentQuestionId, answer, timeTaken);
|
|
|
|
let correctAnswerText = data.correct_answer || '';
|
|
|
|
if (!correctAnswerText) {
|
|
const currentQuestion = messages.find(m => m.isQuestion && m.questionId === currentQuestionId);
|
|
if (currentQuestion && currentQuestion.options) {
|
|
const correctOption = currentQuestion.options.find(o => o.is_correct);
|
|
if (correctOption) {
|
|
correctAnswerText = correctOption.text_pl;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Сохраняем reaction-сообщение
|
|
const reactionMessage: TeacherMessage = {
|
|
id: idRef.current++,
|
|
type: 'bot',
|
|
text: data.reaction,
|
|
isCorrect: data.is_correct,
|
|
commands: [
|
|
...(!data.is_correct ? ['/show-answer'] : []),
|
|
],
|
|
hasPolishText: false,
|
|
};
|
|
setMessages(prev => [...prev, reactionMessage]);
|
|
|
|
// Если сессия завершена
|
|
if (data.session_completed) {
|
|
const stats = data.session_stats || { total: 0, correct_count: 0 };
|
|
|
|
const completedMessage: TeacherMessage = {
|
|
id: idRef.current++,
|
|
type: 'system',
|
|
text: t('teacherCompleted') || 'Урок завершён!',
|
|
isCompleted: true,
|
|
};
|
|
setMessages(prev => [...prev, completedMessage]);
|
|
|
|
setScreen({
|
|
kind: 'completed',
|
|
correct: stats.correct_count,
|
|
total: stats.total,
|
|
});
|
|
setIsLoading(false);
|
|
return;
|
|
}
|
|
|
|
// Если есть следующий вопрос
|
|
if (data.question) {
|
|
const nextQuestionMessage: TeacherMessage = {
|
|
id: idRef.current++,
|
|
type: 'bot',
|
|
text: getLocalized(data.question.question, 'prompt'),
|
|
isQuestion: true,
|
|
questionType: data.question.question.question_type,
|
|
questionId: data.question.question.question_id,
|
|
options: data.question.options,
|
|
optionsLanguage: data.question.question.options_language || 'pl',
|
|
questionIndex: data.question_index,
|
|
totalQuestions: data.question.total_questions,
|
|
};
|
|
setMessages(prev => [...prev, nextQuestionMessage]);
|
|
setCurrentQuestionId(data.question.question.question_id);
|
|
}
|
|
|
|
// Показываем экран "after-answer" — с реакцией и кнопкой "Следующий вопрос"
|
|
setScreen({ kind: 'after-answer' });
|
|
} catch (e) {
|
|
console.error('Error answering:', e);
|
|
showToast(t('teacherAIError') || 'Ошибка');
|
|
} finally {
|
|
setIsLoading(false);
|
|
}
|
|
};
|
|
|
|
// Переход к следующему вопросу (после ответа)
|
|
const handleNextQuestion = () => {
|
|
// Ищем последний вопрос в messages (последний добавленный)
|
|
const lastQuestion = [...messages].reverse().find(m => m.isQuestion);
|
|
|
|
if (lastQuestion) {
|
|
setCurrentQuestionId(lastQuestion.questionId || '');
|
|
setScreen({ kind: 'lesson' });
|
|
} else {
|
|
// Нет вопроса — урок завершён
|
|
setScreen({ kind: 'completed', correct: 0, total: 0 });
|
|
}
|
|
};
|
|
|
|
const handleLoadExamples = async () => {
|
|
if (isLoadingExamples) return;
|
|
setIsLoadingExamples(true);
|
|
setExamplesError(null);
|
|
setExamplesText('');
|
|
setShowExamplesModal(true);
|
|
|
|
try {
|
|
const data = await teacherExamples('', currentLessonId, currentTopicId);
|
|
if (data.limit_exceeded && data.message) {
|
|
setExamplesError(data.message);
|
|
} else if (data.response) {
|
|
setExamplesText(data.response);
|
|
} else {
|
|
setExamplesError(t('testNoExamples') || 'Примеры недоступны');
|
|
}
|
|
} catch (e) {
|
|
console.error('Error loading examples:', e);
|
|
setExamplesError(t('teacherAIError') || 'Ошибка');
|
|
} finally {
|
|
setIsLoadingExamples(false);
|
|
}
|
|
};
|
|
|
|
const handleStartPractice = async () => {
|
|
if (isStartingPractice) return;
|
|
setIsStartingPractice(true);
|
|
|
|
try {
|
|
const analytics = await getLearningAnalytics();
|
|
if (!analytics.has_practice_available) {
|
|
showToast(t('testPracticeNoWeak') || 'Нет слабых навыков');
|
|
setIsStartingPractice(false);
|
|
return;
|
|
}
|
|
|
|
const data = await startWeakSkillsPractice();
|
|
if (data.has_weak_skills && data.session_id) {
|
|
navigate('/lessons/practice', {
|
|
state: {
|
|
sessionId: data.session_id,
|
|
questions: data.questions,
|
|
explanations: data.explanations,
|
|
},
|
|
});
|
|
} else {
|
|
showToast(data.message || t('testPracticeNoWeak') || 'Нет слабых навыков');
|
|
setIsStartingPractice(false);
|
|
}
|
|
} catch (e) {
|
|
console.error('Error starting practice:', e);
|
|
showToast(t('teacherAIError') || 'Ошибка');
|
|
setIsStartingPractice(false);
|
|
}
|
|
};
|
|
|
|
const handleOptionClick = (option: any) => {
|
|
handleAnswer(option.option_key);
|
|
};
|
|
|
|
const handleSubmitAnswer = () => {
|
|
const text = inputValue.trim();
|
|
if (!text) return;
|
|
handleAnswer(text);
|
|
};
|
|
|
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
e.preventDefault();
|
|
handleSubmitAnswer();
|
|
}
|
|
};
|
|
|
|
// ============ COMPUTED ============
|
|
// Текущий вопрос (последний в messages)
|
|
const currentQuestion = [...messages].reverse().find(m => m.isQuestion) || null;
|
|
|
|
// Текущее объяснение (последнее isLessonCard)
|
|
const currentLesson = [...messages].reverse().find(m => m.isLessonCard) || null;
|
|
|
|
// Последняя реакция (если есть)
|
|
const lastReaction = [...messages].reverse().find(m => m.isCorrect !== undefined && !m.isQuestion) || null;
|
|
|
|
// ============ RENDER ============
|
|
return (
|
|
<div style={{
|
|
height: '100vh',
|
|
background: bgColor,
|
|
color: textColor,
|
|
fontFamily: fonts.main,
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
position: 'relative',
|
|
overflow: 'hidden',
|
|
}}>
|
|
{/* Фоновые градиенты */}
|
|
<div style={{ position: 'fixed', top: '-80px', right: '-60px', width: '260px', height: '260px', borderRadius: '50%', background: teacherColor, opacity: 0.18, filter: 'blur(90px)', pointerEvents: 'none', zIndex: 0 }} />
|
|
<div style={{ position: 'fixed', bottom: '-50px', left: '-40px', width: '240px', height: '240px', borderRadius: '50%', background: brandColor, opacity: 0.14, filter: 'blur(80px)', pointerEvents: 'none', zIndex: 0 }} />
|
|
|
|
<style>{`
|
|
@keyframes fadeInUp {
|
|
0% { transform: translateY(10px); opacity: 0; }
|
|
100% { transform: translateY(0); opacity: 1; }
|
|
}
|
|
@keyframes pulse {
|
|
0%, 100% { transform: scale(1); }
|
|
50% { transform: scale(1.1); }
|
|
}
|
|
@keyframes modalFadeIn {
|
|
0% { opacity: 0; }
|
|
100% { opacity: 1; }
|
|
}
|
|
@keyframes modalSlideUp {
|
|
0% { transform: translateY(20px); opacity: 0; }
|
|
100% { transform: translateY(0); opacity: 1; }
|
|
}
|
|
@keyframes typingDot {
|
|
0%, 100% { opacity: 0.3; }
|
|
50% { opacity: 1; }
|
|
}
|
|
`}</style>
|
|
|
|
{/* Toast */}
|
|
{toastMessage && (
|
|
<div style={{
|
|
position: 'fixed', top: '20px', left: '50%', transform: 'translateX(-50%)',
|
|
zIndex: 999, padding: '12px 20px', background: 'rgba(26,26,46,0.95)',
|
|
color: '#FFFFFF', fontSize: '14px', fontWeight: 600, borderRadius: radius.md,
|
|
boxShadow: '0 8px 24px rgba(0,0,0,0.25)', maxWidth: '90vw', textAlign: 'center',
|
|
}}>
|
|
{toastMessage}
|
|
</div>
|
|
)}
|
|
|
|
{/* Модалка примеров */}
|
|
{showExamplesModal && (
|
|
<div
|
|
style={{
|
|
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
|
|
background: 'rgba(20,22,35,0.25)', zIndex: 500,
|
|
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
animation: 'modalFadeIn 0.2s ease', padding: '20px',
|
|
backdropFilter: 'blur(4px)', WebkitBackdropFilter: 'blur(4px)',
|
|
}}
|
|
onClick={(e) => { if (e.target === e.currentTarget) setShowExamplesModal(false); }}
|
|
>
|
|
<div style={{
|
|
...glass({
|
|
borderRadius: radius.lg, padding: '24px', width: '100%',
|
|
maxWidth: '400px', maxHeight: '80vh', overflow: 'auto',
|
|
}),
|
|
animation: 'modalSlideUp 0.3s ease',
|
|
}}>
|
|
<h3 style={{ margin: '0 0 16px 0', fontSize: '18px', fontWeight: 800, textAlign: 'center', color: textColor }}>
|
|
💡 {t('testExamplesTitle') || 'Примеры'}
|
|
</h3>
|
|
|
|
{isLoadingExamples ? (
|
|
<div style={{ textAlign: 'center', padding: '30px', color: subColor }}>
|
|
{t('loading') || 'Загрузка...'}
|
|
</div>
|
|
) : examplesError ? (
|
|
<div style={{ textAlign: 'center', padding: '20px', color: '#E74C3C', fontWeight: 600 }}>
|
|
⚠️ {examplesError}
|
|
</div>
|
|
) : (
|
|
<>
|
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px', marginBottom: '16px' }}>
|
|
{examplesText.split('\n').filter(line => line.trim()).map((line, idx) => (
|
|
<div
|
|
key={idx}
|
|
onClick={() => playExampleLine(line, idx)}
|
|
style={{
|
|
padding: '12px 14px',
|
|
background: playingExampleLine === idx ? 'rgba(79,169,232,0.18)' : 'rgba(79,169,232,0.08)',
|
|
borderRadius: radius.md, fontSize: '14px', lineHeight: '1.6',
|
|
color: textColor, cursor: 'pointer',
|
|
border: playingExampleLine === idx ? '1px solid rgba(79,169,232,0.5)' : '1px solid transparent',
|
|
display: 'flex', alignItems: 'center', gap: '10px',
|
|
}}
|
|
>
|
|
<span style={{ flex: 1 }}>{line}</span>
|
|
<span style={{ fontSize: '14px', color: lectureColor, animation: playingExampleLine === idx ? 'pulse 0.5s ease infinite' : 'none' }}>
|
|
🔊
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
<button
|
|
onClick={() => setShowExamplesModal(false)}
|
|
style={{
|
|
width: '100%', padding: '12px', borderRadius: radius.md, border: 'none',
|
|
background: `linear-gradient(135deg, ${lectureColor}, #3B82F6)`,
|
|
color: '#FFFFFF', fontSize: '14px', fontWeight: 700, cursor: 'pointer',
|
|
}}
|
|
>
|
|
{t('teacherClose') || 'Закрыть'}
|
|
</button>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{/* Модалки */}
|
|
<TeacherMenuModal
|
|
isOpen={showMenuModal}
|
|
onClose={() => setShowMenuModal(false)}
|
|
onStartLesson={handleStart}
|
|
onClearChat={handleClearChat}
|
|
onOpenTyping={() => setShowTyping(true)}
|
|
onOpenPronunciation={() => setShowPronunciation(true)}
|
|
/>
|
|
|
|
<TypingModal isOpen={showTyping} onClose={handleCloseTyping} />
|
|
<PronunciationModal isOpen={showPronunciation} onClose={handleClosePronunciation} />
|
|
|
|
{/* ============ ОСНОВНОЙ КОНТЕНТ ============ */}
|
|
<div style={{ position: 'relative', zIndex: 1, display: 'flex', flexDirection: 'column', flex: 1, minHeight: 0, padding: '16px' }}>
|
|
|
|
{/* ЗАГОЛОВОК */}
|
|
<div style={{
|
|
display: 'flex', alignItems: 'center', gap: '10px',
|
|
marginBottom: '12px', flexShrink: 0,
|
|
}}>
|
|
<button
|
|
onClick={() => navigate('/learning')}
|
|
style={{
|
|
...glass({ padding: '8px 14px', borderRadius: radius.sm }),
|
|
color: textColor, fontSize: '13px', fontWeight: 600, cursor: 'pointer',
|
|
}}
|
|
>
|
|
←
|
|
</button>
|
|
|
|
{screen.kind === 'lesson' || screen.kind === 'after-answer' ? (
|
|
<div style={{ flex: 1, display: 'flex', alignItems: 'center', gap: '8px', minWidth: 0 }}>
|
|
<span style={{
|
|
...glass({ padding: '4px 10px', borderRadius: radius.sm }),
|
|
fontSize: '12px', fontWeight: 800, color: teacherColor, flexShrink: 0,
|
|
}}>
|
|
{currentLevel}
|
|
</span>
|
|
{currentQuestion?.questionIndex !== undefined && currentQuestion?.totalQuestions !== undefined && (
|
|
<span style={{
|
|
fontSize: '13px', fontWeight: 700, color: subColor, flexShrink: 0,
|
|
}}>
|
|
{currentQuestion.questionIndex + 1}/{currentQuestion.totalQuestions}
|
|
</span>
|
|
)}
|
|
<span style={{
|
|
fontSize: '15px', fontWeight: 800, color: textColor,
|
|
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
|
|
}}>
|
|
{currentTopicName || currentLesson?.topicName || t('lessons') || 'Уроки'}
|
|
</span>
|
|
</div>
|
|
) : (
|
|
<h1 style={{ fontSize: '18px', fontWeight: 800, margin: 0, color: textColor, flex: 1 }}>
|
|
📚 {t('lessons') || 'Уроки'}
|
|
</h1>
|
|
)}
|
|
|
|
<button
|
|
onClick={() => setShowMenuModal(true)}
|
|
style={{
|
|
...glass({ padding: '6px 10px', borderRadius: radius.sm }),
|
|
color: subColor, fontSize: '16px', cursor: 'pointer', flexShrink: 0,
|
|
}}
|
|
>
|
|
☰
|
|
</button>
|
|
|
|
{messages.length > 0 && (
|
|
<button
|
|
onClick={handleClearChat}
|
|
style={{
|
|
...glass({ padding: '6px 10px', borderRadius: radius.sm }),
|
|
color: subColor, fontSize: '14px', cursor: 'pointer', flexShrink: 0,
|
|
}}
|
|
>
|
|
🗑️
|
|
</button>
|
|
)}
|
|
</div>
|
|
|
|
{/* КОНТЕНТ */}
|
|
<div
|
|
ref={contentRef}
|
|
style={{
|
|
flex: 1, overflowY: 'auto', overflowX: 'hidden',
|
|
WebkitOverflowScrolling: 'touch', minHeight: 0,
|
|
display: 'flex', flexDirection: 'column', gap: '16px',
|
|
paddingBottom: '16px',
|
|
}}
|
|
>
|
|
|
|
{/* ЭКРАН START */}
|
|
{screen.kind === 'start' && (
|
|
<div style={{
|
|
display: 'flex', flexDirection: 'column',
|
|
alignItems: 'center', justifyContent: 'center',
|
|
flex: 1, padding: '40px 20px', textAlign: 'center',
|
|
animation: 'fadeInUp 0.3s ease',
|
|
}}>
|
|
<div style={{ fontSize: '64px', marginBottom: '16px' }}>🎓</div>
|
|
<p style={{ fontSize: '16px', color: subColor, marginBottom: '24px' }}>
|
|
{t('teacherWelcome') || 'Добро пожаловать!'}
|
|
</p>
|
|
<button
|
|
onClick={handleStart}
|
|
disabled={isLoading}
|
|
style={{
|
|
padding: '16px 32px', borderRadius: radius.lg, border: 'none',
|
|
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
|
color: '#FFFFFF', fontSize: '16px', fontWeight: 700,
|
|
cursor: 'pointer', boxShadow: `0 4px 15px ${teacherColor}40`,
|
|
marginBottom: '10px', width: '100%', maxWidth: '280px',
|
|
opacity: isLoading ? 0.6 : 1,
|
|
}}
|
|
>
|
|
{isLoading ? '...' : (t('teacherStart') || 'Начать урок')}
|
|
</button>
|
|
<button
|
|
onClick={() => setShowMenuModal(true)}
|
|
disabled={isLoading}
|
|
style={{
|
|
...glass({ padding: '14px 24px', borderRadius: radius.lg }),
|
|
color: textColor, fontSize: '14px', fontWeight: 600,
|
|
cursor: 'pointer', width: '100%', maxWidth: '280px',
|
|
}}
|
|
>
|
|
☰ {t('teacherMenu') || 'Меню'}
|
|
</button>
|
|
</div>
|
|
)}
|
|
|
|
{/* ЭКРАН LESSON — один урок = одна страница */}
|
|
{screen.kind === 'lesson' && (
|
|
<>
|
|
{/* Заголовок страницы */}
|
|
<div style={{
|
|
textAlign: 'center',
|
|
padding: '16px 0',
|
|
animation: 'fadeInUp 0.3s ease',
|
|
}}>
|
|
<div style={{
|
|
fontSize: '13px', fontWeight: 700, color: subColor,
|
|
letterSpacing: '0.5px', textTransform: 'uppercase',
|
|
marginBottom: '6px',
|
|
}}>
|
|
{currentLevel} · {t('level') || 'Уровень'}
|
|
</div>
|
|
{(currentTopicName || currentLesson?.topicName) && (
|
|
<div style={{
|
|
fontSize: '20px', fontWeight: 800, color: textColor,
|
|
marginBottom: '8px',
|
|
}}>
|
|
{t('topic') || 'Тема'}: {currentTopicName || currentLesson?.topicName}
|
|
</div>
|
|
)}
|
|
<div style={{
|
|
width: '60px', height: '2px',
|
|
background: `${teacherColor}40`,
|
|
margin: '12px auto',
|
|
borderRadius: '1px',
|
|
}} />
|
|
{currentLesson && (
|
|
<div style={{
|
|
fontSize: '16px', fontWeight: 700, color: teacherColor,
|
|
}}>
|
|
{currentLesson.text.split('\n')[0]}
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
{/* Объяснение + примеры (из lessonCard) */}
|
|
{currentLesson && (
|
|
<div style={{
|
|
...glass({ borderRadius: radius.lg, padding: '20px' }),
|
|
animation: 'fadeInUp 0.3s ease 0.1s both',
|
|
}}>
|
|
<div style={{
|
|
display: 'flex', alignItems: 'center', gap: '8px',
|
|
marginBottom: '12px',
|
|
}}>
|
|
<span style={{ fontSize: '18px' }}>📖</span>
|
|
<span style={{
|
|
fontSize: '13px', fontWeight: 700, color: subColor,
|
|
letterSpacing: '0.5px', textTransform: 'uppercase',
|
|
}}>
|
|
{t('teacherExplanation') || 'Объяснение'}
|
|
</span>
|
|
</div>
|
|
<div style={{
|
|
fontSize: '15px', lineHeight: '1.7', color: textColor,
|
|
whiteSpace: 'pre-line',
|
|
textAlign: 'left',
|
|
}}>
|
|
{currentLesson.text}
|
|
</div>
|
|
{currentLesson.hasPolishText && (
|
|
<button
|
|
onClick={() => playText(currentLesson.text, currentLesson.id)}
|
|
style={{
|
|
marginTop: '12px',
|
|
padding: '8px 16px',
|
|
borderRadius: radius.md,
|
|
border: `1px solid ${brandColor}40`,
|
|
background: isPlaying === currentLesson.id ? `${brandColor}20` : 'rgba(255,255,255,0.6)',
|
|
color: brandColor,
|
|
fontSize: '13px',
|
|
fontWeight: 700,
|
|
cursor: 'pointer',
|
|
display: 'inline-flex',
|
|
alignItems: 'center',
|
|
gap: '6px',
|
|
}}
|
|
>
|
|
🔊 {isPlaying === currentLesson.id ? '...' : (t('listen') || 'Слушать')}
|
|
</button>
|
|
)}
|
|
</div>
|
|
)}
|
|
|
|
{/* Задание (текущий вопрос) */}
|
|
{currentQuestion && (
|
|
<div style={{
|
|
...glass({ borderRadius: radius.lg, padding: '20px' }),
|
|
animation: 'fadeInUp 0.3s ease 0.2s both',
|
|
}}>
|
|
<div style={{
|
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
|
marginBottom: '12px',
|
|
}}>
|
|
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
<span style={{ fontSize: '18px' }}>✏️</span>
|
|
<span style={{
|
|
fontSize: '13px', fontWeight: 700, color: subColor,
|
|
letterSpacing: '0.5px', textTransform: 'uppercase',
|
|
}}>
|
|
{t('teacherTask') || 'Задание'}
|
|
</span>
|
|
</div>
|
|
{currentQuestion.questionIndex !== undefined && currentQuestion.totalQuestions !== undefined && (
|
|
<span style={{
|
|
fontSize: '13px', fontWeight: 700, color: subColor,
|
|
}}>
|
|
{currentQuestion.questionIndex + 1} / {currentQuestion.totalQuestions}
|
|
</span>
|
|
)}
|
|
</div>
|
|
|
|
<div style={{
|
|
fontSize: '16px', fontWeight: 600, color: textColor,
|
|
textAlign: 'center', marginBottom: '16px',
|
|
lineHeight: '1.5',
|
|
}}>
|
|
{currentQuestion.text}
|
|
</div>
|
|
|
|
{/* Варианты ответа (recognition) */}
|
|
{currentQuestion.questionType === 'recognition' && currentQuestion.options && (
|
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
|
{currentQuestion.options.map((option) => (
|
|
<button
|
|
key={option.option_key}
|
|
onClick={() => handleOptionClick(option)}
|
|
disabled={isLoading}
|
|
style={{
|
|
padding: '14px 16px',
|
|
borderRadius: radius.md,
|
|
border: `1px solid ${teacherColor}30`,
|
|
background: `${teacherColor}10`,
|
|
color: textColor,
|
|
fontSize: '15px', fontWeight: 600,
|
|
cursor: isLoading ? 'default' : 'pointer',
|
|
textAlign: 'left',
|
|
opacity: isLoading ? 0.6 : 1,
|
|
transition: 'all 0.2s ease',
|
|
}}
|
|
>
|
|
{currentQuestion.optionsLanguage === 'user' ? getLocalized(option, 'text') : option.text_pl}
|
|
</button>
|
|
))}
|
|
</div>
|
|
)}
|
|
|
|
{/* Ввод (production) */}
|
|
{currentQuestion.questionType === 'production' && (
|
|
<div style={{ display: 'flex', gap: '8px' }}>
|
|
<input
|
|
ref={inputRef}
|
|
type="text"
|
|
value={inputValue}
|
|
onChange={(e) => setInputValue(e.target.value)}
|
|
onKeyDown={handleKeyDown}
|
|
placeholder={t('teacherPlaceholder') || 'Введите ответ'}
|
|
disabled={isLoading}
|
|
style={{
|
|
flex: 1, padding: '12px 16px', borderRadius: radius.md,
|
|
border: `1px solid ${teacherColor}30`,
|
|
background: 'rgba(255,255,255,0.8)',
|
|
color: textColor, fontSize: '15px',
|
|
fontFamily: fonts.main, outline: 'none',
|
|
}}
|
|
/>
|
|
<button
|
|
onClick={handleSubmitAnswer}
|
|
disabled={isLoading || !inputValue.trim()}
|
|
style={{
|
|
padding: '12px 18px', borderRadius: radius.md, border: 'none',
|
|
background: isLoading || !inputValue.trim()
|
|
? 'rgba(0,0,0,0.1)'
|
|
: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
|
color: '#FFFFFF', fontSize: '14px', fontWeight: 700,
|
|
cursor: isLoading || !inputValue.trim() ? 'default' : 'pointer',
|
|
}}
|
|
>
|
|
{t('teacherSend') || 'Ответить'}
|
|
</button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
)}
|
|
</>
|
|
)}
|
|
|
|
{/* ЭКРАН AFTER-ANSWER — реакция + кнопка "Следующий вопрос" */}
|
|
{screen.kind === 'after-answer' && (
|
|
<div style={{
|
|
display: 'flex', flexDirection: 'column',
|
|
gap: '16px',
|
|
animation: 'fadeInUp 0.3s ease',
|
|
paddingTop: '20px',
|
|
}}>
|
|
{/* Реакция */}
|
|
{lastReaction && (
|
|
<div style={{
|
|
...glass({ borderRadius: radius.lg, padding: '24px' }),
|
|
borderLeft: `4px solid ${lastReaction.isCorrect ? brandColor : '#E74C3C'}`,
|
|
textAlign: 'center',
|
|
}}>
|
|
<div style={{ fontSize: '48px', marginBottom: '8px' }}>
|
|
{lastReaction.isCorrect ? '✅' : '❌'}
|
|
</div>
|
|
<div style={{
|
|
fontSize: '20px', fontWeight: 800,
|
|
color: lastReaction.isCorrect ? brandColor : '#E74C3C',
|
|
marginBottom: '12px',
|
|
}}>
|
|
{lastReaction.text}
|
|
</div>
|
|
{lastReaction.commands?.includes('/show-answer') && (
|
|
<button
|
|
onClick={() => {
|
|
// Показываем правильный ответ
|
|
if (currentQuestion) {
|
|
const correct = currentQuestion.options?.find(o => o.is_correct);
|
|
if (correct) {
|
|
showToast(`✅ ${correct.text_pl}`);
|
|
}
|
|
}
|
|
}}
|
|
style={{
|
|
padding: '10px 20px', borderRadius: radius.md, border: 'none',
|
|
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
|
color: '#FFFFFF', fontSize: '14px', fontWeight: 700,
|
|
cursor: 'pointer', marginTop: '8px',
|
|
}}
|
|
>
|
|
✅ {t('teacherShowAnswer') || 'Показать ответ'}
|
|
</button>
|
|
)}
|
|
</div>
|
|
)}
|
|
|
|
{/* Кнопка "Следующий вопрос" */}
|
|
<button
|
|
onClick={handleNextQuestion}
|
|
disabled={isLoading}
|
|
style={{
|
|
padding: '16px 24px', borderRadius: radius.lg, border: 'none',
|
|
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
|
color: '#FFFFFF', fontSize: '16px', fontWeight: 700,
|
|
cursor: isLoading ? 'default' : 'pointer',
|
|
boxShadow: `0 4px 15px ${teacherColor}40`,
|
|
opacity: isLoading ? 0.6 : 1,
|
|
width: '100%',
|
|
}}
|
|
>
|
|
{t('teacherNextQuestion') || 'Следующий вопрос'} →
|
|
</button>
|
|
</div>
|
|
)}
|
|
|
|
{/* ЭКРАН COMPLETED */}
|
|
{screen.kind === 'completed' && (
|
|
<div style={{
|
|
display: 'flex', flexDirection: 'column',
|
|
alignItems: 'center', justifyContent: 'center',
|
|
flex: 1, padding: '40px 20px', textAlign: 'center',
|
|
animation: 'fadeInUp 0.3s ease',
|
|
}}>
|
|
<div style={{ fontSize: '64px', marginBottom: '16px' }}>🎉</div>
|
|
<h2 style={{
|
|
fontSize: '22px', fontWeight: 800, color: textColor,
|
|
margin: '0 0 8px 0',
|
|
}}>
|
|
{t('teacherLessonCompleted') || 'Урок завершён!'}
|
|
</h2>
|
|
{screen.total > 0 && (
|
|
<p style={{
|
|
fontSize: '16px', color: subColor, margin: '0 0 24px 0',
|
|
}}>
|
|
{screen.correct} / {screen.total} ({Math.round((screen.correct / screen.total) * 100)}%)
|
|
</p>
|
|
)}
|
|
|
|
<button
|
|
onClick={handleStart}
|
|
disabled={isLoading}
|
|
style={{
|
|
padding: '16px 32px', borderRadius: radius.lg, border: 'none',
|
|
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
|
color: '#FFFFFF', fontSize: '16px', fontWeight: 700,
|
|
cursor: isLoading ? 'default' : 'pointer',
|
|
boxShadow: `0 4px 15px ${teacherColor}40`,
|
|
marginBottom: '10px', width: '100%', maxWidth: '280px',
|
|
opacity: isLoading ? 0.6 : 1,
|
|
}}
|
|
>
|
|
{isLoading ? '...' : (t('teacherNewLesson') || 'Следующий урок')} →
|
|
</button>
|
|
|
|
<button
|
|
onClick={handleLoadExamples}
|
|
disabled={isLoadingExamples}
|
|
style={{
|
|
padding: '14px 24px', borderRadius: radius.lg, border: 'none',
|
|
background: `linear-gradient(135deg, ${lectureColor}, #3B82F6)`,
|
|
color: '#FFFFFF', fontSize: '14px', fontWeight: 700,
|
|
cursor: isLoadingExamples ? 'default' : 'pointer',
|
|
marginBottom: '10px', width: '100%', maxWidth: '280px',
|
|
opacity: isLoadingExamples ? 0.6 : 1,
|
|
}}
|
|
>
|
|
💡 {t('testExamplesButton') || 'Примеры'}
|
|
</button>
|
|
|
|
<button
|
|
onClick={handleStartPractice}
|
|
disabled={isStartingPractice}
|
|
style={{
|
|
padding: '14px 24px', borderRadius: radius.lg, border: 'none',
|
|
background: `linear-gradient(135deg, ${brandColor}, #27AE60)`,
|
|
color: '#FFFFFF', fontSize: '14px', fontWeight: 700,
|
|
cursor: isStartingPractice ? 'default' : 'pointer',
|
|
width: '100%', maxWidth: '280px',
|
|
opacity: isStartingPractice ? 0.6 : 1,
|
|
}}
|
|
>
|
|
🎯 {t('testPracticeButton') || 'Практика'}
|
|
</button>
|
|
</div>
|
|
)}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default TeacherChatPage; |