revert(teacher): откат режима карточек, возврат к ленте (22.09.2026)
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
||||
<meta name="version" content="3.7.2" />
|
||||
<meta name="version" content="3.7.4" />
|
||||
<title>Filwords PL - Nauka polskiego przez grę</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
|
||||
@@ -1,465 +0,0 @@
|
||||
import React from 'react';
|
||||
import { radius } from '../styles/theme';
|
||||
|
||||
// ============ Типы ============
|
||||
|
||||
export type CardType = 'intro' | 'question' | 'result' | 'test_summary';
|
||||
|
||||
export interface LessonCardOption {
|
||||
option_key: string;
|
||||
text_pl: string;
|
||||
text_ru: string;
|
||||
text_uk: string;
|
||||
text_en: string;
|
||||
is_correct: boolean;
|
||||
wrong_because?: string | null;
|
||||
}
|
||||
|
||||
export interface LessonCardData {
|
||||
type: CardType;
|
||||
|
||||
// Для intro
|
||||
levelCode?: string;
|
||||
topicName?: string;
|
||||
lessonNumber?: number;
|
||||
lessonTitle?: string;
|
||||
explanation?: string;
|
||||
examples?: Array<{ text_pl: string; text_user: string }>;
|
||||
|
||||
// Для question
|
||||
questionId?: string;
|
||||
questionType?: 'recognition' | 'production';
|
||||
prompt?: string;
|
||||
options?: LessonCardOption[];
|
||||
optionsLanguage?: 'pl' | 'user';
|
||||
|
||||
// Для result / test_summary
|
||||
resultText?: string;
|
||||
correctCount?: number;
|
||||
totalCount?: number;
|
||||
weakSkill?: string;
|
||||
}
|
||||
|
||||
interface LessonCardProps {
|
||||
data: LessonCardData;
|
||||
cardIndex: number;
|
||||
totalCards: number;
|
||||
selectedAnswer: string | null;
|
||||
textInput: string;
|
||||
hintUsed: boolean;
|
||||
isFlipping: boolean;
|
||||
rotation: number;
|
||||
|
||||
onSelectAnswer: (optionKey: string) => void;
|
||||
onTextChange: (text: string) => void;
|
||||
onNext: () => void;
|
||||
onShowHint: () => void;
|
||||
onStartLesson?: () => void;
|
||||
}
|
||||
|
||||
const LessonCard: React.FC<LessonCardProps> = ({
|
||||
data,
|
||||
cardIndex,
|
||||
totalCards,
|
||||
selectedAnswer,
|
||||
textInput,
|
||||
hintUsed,
|
||||
isFlipping,
|
||||
rotation,
|
||||
onSelectAnswer,
|
||||
onTextChange,
|
||||
onNext,
|
||||
onShowHint,
|
||||
onStartLesson,
|
||||
}) => {
|
||||
const textColor = '#1A1A2E';
|
||||
const subColor = '#6B7280';
|
||||
const brandColor = '#2ECC71';
|
||||
const teacherColor = '#8B5CF6';
|
||||
|
||||
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,
|
||||
});
|
||||
|
||||
// ============ Титульная ============
|
||||
const renderIntro = () => (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', height: '100%' }}>
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<div style={{
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
color: teacherColor,
|
||||
marginBottom: '4px',
|
||||
letterSpacing: '0.5px',
|
||||
textTransform: 'uppercase',
|
||||
}}>
|
||||
{data.levelCode} · {data.topicName}
|
||||
</div>
|
||||
<div style={{ fontSize: '12px', color: subColor, marginBottom: '8px' }}>
|
||||
Урок {data.lessonNumber}
|
||||
</div>
|
||||
<h2 style={{
|
||||
fontSize: '22px',
|
||||
fontWeight: 900,
|
||||
color: textColor,
|
||||
margin: 0,
|
||||
lineHeight: '1.3',
|
||||
}}>
|
||||
{data.lessonTitle}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
{data.explanation && (
|
||||
<div style={{
|
||||
padding: '14px',
|
||||
background: `${brandColor}10`,
|
||||
borderRadius: radius.md,
|
||||
fontSize: '14px',
|
||||
color: textColor,
|
||||
lineHeight: '1.6',
|
||||
whiteSpace: 'pre-line',
|
||||
}}>
|
||||
{data.explanation}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{data.examples && data.examples.length > 0 && (
|
||||
<div style={{
|
||||
padding: '12px',
|
||||
background: `${teacherColor}08`,
|
||||
borderRadius: radius.md,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '8px',
|
||||
}}>
|
||||
<div style={{ fontSize: '11px', fontWeight: 700, color: teacherColor, textTransform: 'uppercase', letterSpacing: '0.5px' }}>
|
||||
Przykłady
|
||||
</div>
|
||||
{data.examples.map((ex, i) => (
|
||||
<div key={i} style={{ fontSize: '13px', lineHeight: '1.5' }}>
|
||||
<span style={{ fontWeight: 700, color: textColor }}>🇵🇱 {ex.text_pl}</span>
|
||||
{ex.text_user && (
|
||||
<span style={{ color: subColor }}> → {ex.text_user}</span>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ flex: 1 }} />
|
||||
|
||||
<button
|
||||
onClick={onStartLesson}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '16px',
|
||||
borderRadius: radius.lg,
|
||||
border: 'none',
|
||||
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '15px',
|
||||
fontWeight: 800,
|
||||
cursor: 'pointer',
|
||||
boxShadow: `0 4px 15px ${teacherColor}40`,
|
||||
transition: 'all 0.2s ease',
|
||||
}}
|
||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.96)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
Перейти к заданию →
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
|
||||
// ============ Вопрос ============
|
||||
const renderQuestion = () => {
|
||||
const isProduction = data.questionType === 'production';
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', height: '100%' }}>
|
||||
{!hintUsed && (
|
||||
<button
|
||||
onClick={onShowHint}
|
||||
title="Подсказка"
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: '16px',
|
||||
right: '16px',
|
||||
width: '36px',
|
||||
height: '36px',
|
||||
borderRadius: '50%',
|
||||
border: `1px solid ${brandColor}40`,
|
||||
background: `${brandColor}15`,
|
||||
color: brandColor,
|
||||
fontSize: '18px',
|
||||
cursor: 'pointer',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
padding: 0,
|
||||
boxShadow: '0 2px 8px rgba(31,38,73,0.10)',
|
||||
transition: 'all 0.2s ease',
|
||||
zIndex: 2,
|
||||
}}
|
||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.9)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
💡
|
||||
</button>
|
||||
)}
|
||||
|
||||
{hintUsed && (
|
||||
<div style={{
|
||||
position: 'absolute',
|
||||
top: '16px',
|
||||
right: '16px',
|
||||
fontSize: '11px',
|
||||
color: subColor,
|
||||
fontWeight: 700,
|
||||
padding: '4px 10px',
|
||||
background: 'rgba(0,0,0,0.05)',
|
||||
borderRadius: radius.sm,
|
||||
zIndex: 2,
|
||||
}}>
|
||||
🔒 подсказка
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ paddingRight: '48px' }}>
|
||||
<div style={{ fontSize: '11px', fontWeight: 700, color: subColor, marginBottom: '6px', textTransform: 'uppercase', letterSpacing: '0.5px' }}>
|
||||
Задание {cardIndex}
|
||||
</div>
|
||||
<div style={{ fontSize: '17px', fontWeight: 700, color: textColor, lineHeight: '1.4' }}>
|
||||
{data.prompt}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isProduction ? (
|
||||
<input
|
||||
type="text"
|
||||
value={textInput}
|
||||
onChange={(e) => onTextChange(e.target.value)}
|
||||
placeholder="Введите ответ..."
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '14px',
|
||||
borderRadius: radius.md,
|
||||
border: textInput ? `2px solid ${brandColor}` : '1px solid rgba(0,0,0,0.08)',
|
||||
background: 'rgba(255,255,255,0.9)',
|
||||
color: textColor,
|
||||
fontSize: '16px',
|
||||
fontWeight: 600,
|
||||
outline: 'none',
|
||||
boxSizing: 'border-box',
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
||||
{(data.options || []).map((opt) => {
|
||||
const isSelected = selectedAnswer === opt.option_key;
|
||||
const displayText = data.optionsLanguage === 'user'
|
||||
? (opt.text_ru || opt.text_en || opt.text_pl)
|
||||
: opt.text_pl;
|
||||
|
||||
return (
|
||||
<button
|
||||
key={opt.option_key}
|
||||
onClick={() => onSelectAnswer(opt.option_key)}
|
||||
style={{
|
||||
padding: '14px 16px',
|
||||
borderRadius: radius.md,
|
||||
border: isSelected ? `2px solid ${brandColor}` : '1px solid rgba(0,0,0,0.08)',
|
||||
background: isSelected ? `${brandColor}15` : 'rgba(255,255,255,0.7)',
|
||||
color: textColor,
|
||||
fontSize: '15px',
|
||||
fontWeight: isSelected ? 700 : 500,
|
||||
cursor: 'pointer',
|
||||
textAlign: 'left',
|
||||
transition: 'all 0.2s ease',
|
||||
}}
|
||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.98)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
<span style={{ fontWeight: 800, color: brandColor, marginRight: '8px' }}>
|
||||
{opt.option_key}.
|
||||
</span>
|
||||
{displayText}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ flex: 1 }} />
|
||||
|
||||
<button
|
||||
onClick={onNext}
|
||||
disabled={!selectedAnswer && !textInput.trim()}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '16px',
|
||||
borderRadius: radius.lg,
|
||||
border: 'none',
|
||||
background: (selectedAnswer || textInput.trim())
|
||||
? `linear-gradient(135deg, ${brandColor}, #27AE60)`
|
||||
: 'rgba(0,0,0,0.1)',
|
||||
color: '#FFFFFF',
|
||||
fontSize: '15px',
|
||||
fontWeight: 800,
|
||||
cursor: (selectedAnswer || textInput.trim()) ? 'pointer' : 'default',
|
||||
boxShadow: (selectedAnswer || textInput.trim()) ? `0 4px 15px ${brandColor}40` : 'none',
|
||||
transition: 'all 0.2s ease',
|
||||
}}
|
||||
onTouchStart={(e) => {
|
||||
if (selectedAnswer || textInput.trim()) e.currentTarget.style.transform = 'scale(0.96)';
|
||||
}}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
Далее →
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// ============ Результат урока ============
|
||||
const renderResult = () => (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '20px',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
textAlign: 'center',
|
||||
}}>
|
||||
<div style={{ fontSize: '64px' }}>🎉</div>
|
||||
<div style={{ fontSize: '20px', fontWeight: 800, color: textColor, lineHeight: '1.4' }}>
|
||||
{data.resultText || 'Отличная работа!'}
|
||||
</div>
|
||||
{data.correctCount !== undefined && data.totalCount !== undefined && (
|
||||
<div style={{
|
||||
padding: '14px 24px',
|
||||
background: `${brandColor}15`,
|
||||
borderRadius: radius.lg,
|
||||
fontSize: '18px',
|
||||
fontWeight: 800,
|
||||
color: brandColor,
|
||||
}}>
|
||||
{data.correctCount} / {data.totalCount}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ flex: 1 }} />
|
||||
</div>
|
||||
);
|
||||
|
||||
// ============ Сводка теста ============
|
||||
const renderTestSummary = () => {
|
||||
const percent = data.totalCount && data.correctCount !== undefined
|
||||
? Math.round((data.correctCount / data.totalCount) * 100)
|
||||
: 0;
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '20px',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
textAlign: 'center',
|
||||
}}>
|
||||
<div style={{ fontSize: '56px' }}>📊</div>
|
||||
<div style={{ fontSize: '18px', fontWeight: 800, color: textColor }}>
|
||||
Результат теста
|
||||
</div>
|
||||
<div style={{
|
||||
fontSize: '32px',
|
||||
fontWeight: 900,
|
||||
color: percent >= 70 ? brandColor : '#E74C3C',
|
||||
}}>
|
||||
{data.correctCount} / {data.totalCount}
|
||||
</div>
|
||||
<div style={{ fontSize: '14px', color: subColor }}>
|
||||
{percent}%
|
||||
</div>
|
||||
{data.weakSkill && (
|
||||
<div style={{
|
||||
padding: '12px 18px',
|
||||
background: '#E74C3C10',
|
||||
borderRadius: radius.md,
|
||||
fontSize: '13px',
|
||||
color: textColor,
|
||||
fontWeight: 600,
|
||||
border: '1px solid #E74C3C30',
|
||||
}}>
|
||||
⚠️ Слабое место: {data.weakSkill}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ flex: 1 }} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// ============ Рендер ============
|
||||
const renderContent = () => {
|
||||
switch (data.type) {
|
||||
case 'intro': return renderIntro();
|
||||
case 'question': return renderQuestion();
|
||||
case 'result': return renderResult();
|
||||
case 'test_summary': return renderTestSummary();
|
||||
default: return null;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ perspective: '1200px', width: '100%', height: '100%' }}>
|
||||
<div style={{
|
||||
...glass({
|
||||
borderRadius: radius.lg,
|
||||
padding: '24px',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
transform: `rotateY(${rotation}deg)`,
|
||||
// 🔧 ФИКС (22.09.2026): скорость flip 0.4 → 0.6 (0.3 на пол-оборота).
|
||||
transition: isFlipping ? 'transform 0.3s ease-in-out' : 'none',
|
||||
transformStyle: 'preserve-3d',
|
||||
backfaceVisibility: 'hidden',
|
||||
boxShadow: '0 24px 60px rgba(31,38,73,0.20), inset 0 1px 0 rgba(255,255,255,0.85)',
|
||||
}),
|
||||
}}>
|
||||
{/*
|
||||
🔧 ФИКС (22.09.2026): убран прогресс-бар сверху карточки.
|
||||
Он визуально сливался с верхним бордером и выглядел как «зелёная полоса».
|
||||
Оставили только счётчик `1 / N`.
|
||||
*/}
|
||||
|
||||
{/* Счётчик */}
|
||||
<div style={{
|
||||
position: 'absolute',
|
||||
top: '12px',
|
||||
left: '24px',
|
||||
fontSize: '12px',
|
||||
fontWeight: 700,
|
||||
color: subColor,
|
||||
}}>
|
||||
{cardIndex} / {totalCards}
|
||||
</div>
|
||||
|
||||
{/* Контент */}
|
||||
<div style={{ flex: 1, paddingTop: '24px', display: 'flex', flexDirection: 'column' }}>
|
||||
{renderContent()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default LessonCard;
|
||||
@@ -1,113 +0,0 @@
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import LessonCard, { type LessonCardData } from './LessonCard';
|
||||
|
||||
interface LessonCardStackProps {
|
||||
cards: LessonCardData[];
|
||||
onComplete: () => void;
|
||||
onAnswer?: (questionId: string, answer: string, hintUsed: boolean) => Promise<void>;
|
||||
}
|
||||
|
||||
const LessonCardStack: React.FC<LessonCardStackProps> = ({
|
||||
cards,
|
||||
onComplete,
|
||||
onAnswer,
|
||||
}) => {
|
||||
const [currentIndex, setCurrentIndex] = useState(0);
|
||||
const [rotation, setRotation] = useState(0);
|
||||
const [isFlipping, setIsFlipping] = useState(false);
|
||||
const [selectedAnswer, setSelectedAnswer] = useState<string | null>(null);
|
||||
const [textInput, setTextInput] = useState('');
|
||||
const [hintUsed, setHintUsed] = useState(false);
|
||||
const cardsRef = useRef(cards);
|
||||
|
||||
// 🔧 ФИКС (22.09.2026): cardsRef — актуальный массив cards для setTimeout.
|
||||
useEffect(() => {
|
||||
cardsRef.current = cards;
|
||||
}, [cards]);
|
||||
|
||||
const currentCard = cards[currentIndex];
|
||||
const totalCards = cards.length;
|
||||
|
||||
// 🔧 ФИКС (22.09.2026): скорость flip 0.4 → 0.6 (по просьбе).
|
||||
const FLIP_HALF_MS = 300; // половина от 0.6 сек
|
||||
|
||||
const flip = (nextIndex: number) => {
|
||||
if (isFlipping) return;
|
||||
|
||||
setIsFlipping(true);
|
||||
setRotation(180);
|
||||
|
||||
setTimeout(() => {
|
||||
setCurrentIndex(nextIndex);
|
||||
setRotation(360);
|
||||
|
||||
setSelectedAnswer(null);
|
||||
setTextInput('');
|
||||
setHintUsed(false);
|
||||
|
||||
setTimeout(() => {
|
||||
setRotation(0);
|
||||
setIsFlipping(false);
|
||||
}, FLIP_HALF_MS);
|
||||
}, FLIP_HALF_MS);
|
||||
};
|
||||
|
||||
const handleNext = async () => {
|
||||
if (currentCard.type === 'question') {
|
||||
const answer = currentCard.questionType === 'production' ? textInput : (selectedAnswer || '');
|
||||
if (onAnswer && currentCard.questionId) {
|
||||
await onAnswer(currentCard.questionId, answer, hintUsed);
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 ФИКС (22.09.2026): ждём, пока родитель обновит cards.
|
||||
// Используем cardsRef — видим АКТУАЛЬНОЕ количество.
|
||||
setTimeout(() => {
|
||||
const actualTotal = cardsRef.current.length;
|
||||
if (currentIndex + 1 < actualTotal) {
|
||||
flip(currentIndex + 1);
|
||||
} else {
|
||||
onComplete();
|
||||
}
|
||||
}, 200);
|
||||
};
|
||||
|
||||
const handleStartLesson = () => {
|
||||
if (currentIndex < totalCards - 1) {
|
||||
flip(currentIndex + 1);
|
||||
}
|
||||
};
|
||||
|
||||
const handleShowHint = () => {
|
||||
setHintUsed(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
padding: '16px',
|
||||
}}>
|
||||
<div style={{ flex: 1, position: 'relative' }}>
|
||||
<LessonCard
|
||||
data={currentCard}
|
||||
cardIndex={currentIndex + 1}
|
||||
totalCards={totalCards}
|
||||
selectedAnswer={selectedAnswer}
|
||||
textInput={textInput}
|
||||
hintUsed={hintUsed}
|
||||
isFlipping={isFlipping}
|
||||
rotation={rotation}
|
||||
onSelectAnswer={setSelectedAnswer}
|
||||
onTextChange={setTextInput}
|
||||
onNext={handleNext}
|
||||
onShowHint={handleShowHint}
|
||||
onStartLesson={handleStartLesson}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default LessonCardStack;
|
||||
+323
-387
@@ -19,8 +19,6 @@ import {
|
||||
import TeacherMenuModal from '../components/TeacherMenuModal';
|
||||
import TypingModal from '../components/TypingModal';
|
||||
import PronunciationModal from '../components/PronunciationModal';
|
||||
import LessonCardStack from '../components/LessonCardStack';
|
||||
import { type LessonCardData } from '../components/LessonCard';
|
||||
|
||||
interface TeacherMessage {
|
||||
id: number;
|
||||
@@ -87,11 +85,6 @@ const TeacherChatPage: React.FC = () => {
|
||||
const [showTyping, setShowTyping] = useState(false);
|
||||
const [showPronunciation, setShowPronunciation] = useState(false);
|
||||
|
||||
// 🔧 НОВОЕ (22.09.2026): режим карточек для уроков.
|
||||
// Если lessonCards !== null → рендерим LessonCardStack вместо ленты.
|
||||
const [lessonCards, setLessonCards] = useState<LessonCardData[] | null>(null);
|
||||
const [cardSessionId, setCardSessionId] = useState<number | null>(null);
|
||||
|
||||
const [explanationData, setExplanationData] = useState<{
|
||||
wrongAnswer: string;
|
||||
correctAnswer: string;
|
||||
@@ -388,45 +381,44 @@ const TeacherChatPage: React.FC = () => {
|
||||
try {
|
||||
const data = await teacherStart();
|
||||
|
||||
if (data.session_id) {
|
||||
setSessionId(data.session_id);
|
||||
setCardSessionId(data.session_id);
|
||||
}
|
||||
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);
|
||||
|
||||
// 🔧 НОВОЕ (22.09.2026): собираем массив карточек.
|
||||
if (data.question) {
|
||||
const cards: LessonCardData[] = [];
|
||||
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,
|
||||
};
|
||||
setMessages(prev => [...prev, lessonCardMsg]);
|
||||
|
||||
// 🔧 ФИКС (22.09.2026): убираем title из explanation, чтобы не дублировался.
|
||||
const textLines = data.text.split('\n');
|
||||
const lessonTitle = textLines[0] || '';
|
||||
const explanationRest = textLines.slice(1).join('\n').trim();
|
||||
await new Promise(resolve => setTimeout(resolve, 400));
|
||||
|
||||
cards.push({
|
||||
type: 'intro',
|
||||
levelCode: 'A1',
|
||||
topicName: data.topic_name || '',
|
||||
lessonNumber: 1,
|
||||
lessonTitle,
|
||||
explanation: explanationRest,
|
||||
examples: [],
|
||||
});
|
||||
|
||||
// 2. Первый вопрос
|
||||
cards.push({
|
||||
type: 'question',
|
||||
questionId: data.question.question.question_id,
|
||||
const questionMsg: TeacherMessage = {
|
||||
id: idRef.current++,
|
||||
type: 'bot',
|
||||
text: getLocalized(data.question.question, 'prompt'),
|
||||
isQuestion: true,
|
||||
questionType: data.question.question.question_type,
|
||||
prompt: getLocalized(data.question.question, 'prompt'),
|
||||
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,
|
||||
};
|
||||
|
||||
setLessonCards(cards);
|
||||
setCurrentQuestionId(data.question.question.question_id);
|
||||
setMessages(prev => [...prev, questionMsg]);
|
||||
setIsStarted(true);
|
||||
} else {
|
||||
const botMessage: TeacherMessage = {
|
||||
@@ -446,47 +438,6 @@ const TeacherChatPage: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 🔧 НОВОЕ (22.09.2026): обработка ответа в режиме карточек.
|
||||
const handleCardAnswer = async (questionId: string, answer: string, _hintUsed: boolean) => {
|
||||
if (!cardSessionId) return;
|
||||
|
||||
try {
|
||||
const timeTaken = Date.now() - startTimeRef.current;
|
||||
startTimeRef.current = Date.now();
|
||||
|
||||
const data = await teacherAnswer(cardSessionId, questionId, answer, timeTaken);
|
||||
|
||||
// Если сессия завершена — добавляем result-карточку
|
||||
if (data.session_completed && lessonCards) {
|
||||
const stats = data.session_stats || { total: 0, correct_count: 0 };
|
||||
const resultCard: LessonCardData = {
|
||||
type: 'result',
|
||||
resultText: data.reaction || 'Отличная работа!',
|
||||
correctCount: stats.correct_count,
|
||||
totalCount: stats.total,
|
||||
};
|
||||
setLessonCards(prev => prev ? [...prev, resultCard] : [resultCard]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Если есть следующий вопрос — добавляем карточку
|
||||
if (data.question && lessonCards) {
|
||||
const nextCard: LessonCardData = {
|
||||
type: 'question',
|
||||
questionId: data.question.question.question_id,
|
||||
questionType: data.question.question.question_type,
|
||||
prompt: getLocalized(data.question.question, 'prompt'),
|
||||
options: data.question.options,
|
||||
optionsLanguage: data.question.question.options_language || 'pl',
|
||||
};
|
||||
setLessonCards(prev => prev ? [...prev, nextCard] : [nextCard]);
|
||||
setCurrentQuestionId(data.question.question.question_id);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error in handleCardAnswer:', e);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAnswer = async (answer: string) => {
|
||||
if (!sessionId || !currentQuestionId || isLoading) return;
|
||||
|
||||
@@ -1116,342 +1067,327 @@ const TeacherChatPage: React.FC = () => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 🔧 НОВОЕ (22.09.2026): если урок в режиме карточек — рендерим LessonCardStack */}
|
||||
{lessonCards ? (
|
||||
<div style={{ flex: 1, minHeight: 0 }}>
|
||||
<LessonCardStack
|
||||
cards={lessonCards}
|
||||
onAnswer={handleCardAnswer}
|
||||
onComplete={() => {
|
||||
setLessonCards(null);
|
||||
setCardSessionId(null);
|
||||
setIsStarted(false);
|
||||
handleStart();
|
||||
{/* Сообщения */}
|
||||
<div style={{
|
||||
flex: 1,
|
||||
overflowY: 'auto',
|
||||
overflowX: 'hidden',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '10px',
|
||||
paddingBottom: '12px',
|
||||
WebkitOverflowScrolling: 'touch',
|
||||
minHeight: 0,
|
||||
}}>
|
||||
{messages.length === 0 && !isStarted && (
|
||||
<div style={{ textAlign: 'center', padding: '40px 20px', 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',
|
||||
}}
|
||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.96)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
{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>
|
||||
)}
|
||||
|
||||
{showContinueButton && (
|
||||
<div style={{ textAlign: 'center', padding: '16px' }}>
|
||||
<button
|
||||
onClick={handleStart}
|
||||
disabled={isLoading}
|
||||
style={{
|
||||
padding: '12px 24px',
|
||||
borderRadius: radius.md,
|
||||
border: 'none',
|
||||
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
cursor: 'pointer',
|
||||
boxShadow: `0 4px 12px ${teacherColor}40`,
|
||||
}}
|
||||
>
|
||||
{t('teacherContinue')} →
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{messages.map((msg) => (
|
||||
<div
|
||||
key={msg.id}
|
||||
style={{
|
||||
alignSelf: msg.type === 'user' ? 'flex-end' : msg.type === 'system' ? 'center' : 'flex-start',
|
||||
maxWidth: '85%',
|
||||
position: 'relative',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div style={{
|
||||
flex: 1,
|
||||
overflowY: 'auto',
|
||||
overflowX: 'hidden',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '10px',
|
||||
paddingBottom: '12px',
|
||||
WebkitOverflowScrolling: 'touch',
|
||||
minHeight: 0,
|
||||
}}>
|
||||
{messages.length === 0 && !isStarted && (
|
||||
<div style={{ textAlign: 'center', padding: '40px 20px', animation: 'fadeInUp 0.3s ease' }}>
|
||||
<div style={{ fontSize: '64px', marginBottom: '16px' }}>🎓</div>
|
||||
<p style={{ fontSize: '16px', color: subColor, marginBottom: '24px' }}>
|
||||
{t('teacherWelcome')}
|
||||
</p>
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
padding: '12px 16px',
|
||||
borderRadius: msg.type === 'user' ? '16px 16px 4px 16px' : msg.type === 'system' ? '16px' : '16px 16px 16px 4px',
|
||||
background: msg.type === 'user'
|
||||
? `linear-gradient(135deg, ${brandColor}, #27AE60)`
|
||||
: msg.type === 'system'
|
||||
? `${teacherColor}20`
|
||||
: 'rgba(255,255,255,0.8)',
|
||||
color: msg.type === 'user' ? '#FFFFFF' : textColor,
|
||||
fontSize: '14px',
|
||||
lineHeight: '1.5',
|
||||
whiteSpace: 'pre-line',
|
||||
border: msg.type === 'user' ? 'none' : `1px solid ${msg.type === 'system' ? teacherColor : 'rgba(0,0,0,0.06)'}`,
|
||||
boxShadow: msg.type === 'user' ? `0 2px 10px ${brandColor}30` : '0 2px 8px rgba(31,38,73,0.06)',
|
||||
animation: 'messageIn 0.3s ease',
|
||||
wordBreak: 'break-word',
|
||||
}}
|
||||
>
|
||||
{msg.text}
|
||||
</div>
|
||||
|
||||
{msg.type === 'bot' && !msg.isQuestion && msg.hasPolishText && (
|
||||
<button
|
||||
onClick={() => playText(msg.text, msg.id)}
|
||||
style={{
|
||||
position: 'absolute',
|
||||
bottom: '-8px',
|
||||
right: '-4px',
|
||||
width: '24px',
|
||||
height: '24px',
|
||||
borderRadius: '50%',
|
||||
border: `1px solid ${brandColor}40`,
|
||||
background: isPlaying === msg.id ? `${brandColor}30` : 'rgba(255,255,255,0.9)',
|
||||
color: brandColor,
|
||||
fontSize: '10px',
|
||||
cursor: 'pointer',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
animation: isPlaying === msg.id ? 'pulse 0.5s ease infinite' : 'none',
|
||||
boxShadow: '0 2px 8px rgba(31,38,73,0.08)',
|
||||
}}
|
||||
>
|
||||
🔊
|
||||
</button>
|
||||
)}
|
||||
|
||||
{msg.isQuestion && msg.options && msg.options.length > 0 && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px', marginTop: '10px' }}>
|
||||
{msg.options.map((option) => (
|
||||
<button
|
||||
key={option.option_key}
|
||||
onClick={() => handleOptionClick(option)}
|
||||
disabled={isLoading}
|
||||
style={{
|
||||
padding: '12px 16px',
|
||||
borderRadius: radius.md,
|
||||
border: `1px solid ${teacherColor}30`,
|
||||
background: `${teacherColor}10`,
|
||||
color: textColor,
|
||||
fontSize: '14px',
|
||||
fontWeight: 600,
|
||||
cursor: 'pointer',
|
||||
transition: 'all 0.2s ease',
|
||||
textAlign: 'left',
|
||||
}}
|
||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.97)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
{msg.optionsLanguage === 'user' ? getLocalized(option, 'text') : option.text_pl}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{msg.commands && msg.commands.length > 0 && (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '8px',
|
||||
marginTop: '12px',
|
||||
width: '100%',
|
||||
maxWidth: '280px',
|
||||
}}>
|
||||
{msg.commands.map((cmd) => {
|
||||
if (cmd === '/show-answer') {
|
||||
return (
|
||||
<button
|
||||
key={cmd}
|
||||
onClick={() => handleCommand(cmd)}
|
||||
disabled={isLoading}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '14px 20px',
|
||||
borderRadius: radius.lg,
|
||||
border: 'none',
|
||||
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
cursor: 'pointer',
|
||||
boxShadow: `0 4px 15px ${teacherColor}40`,
|
||||
transition: 'all 0.2s ease',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.96)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
✅ {t('teacherShowAnswer')}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
if (cmd === '/examples') {
|
||||
return (
|
||||
<button
|
||||
key={cmd}
|
||||
onClick={() => handleCommand(cmd)}
|
||||
disabled={isLoading || isLoadingExamples}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '14px 20px',
|
||||
borderRadius: radius.lg,
|
||||
border: 'none',
|
||||
background: isLoadingExamples
|
||||
? 'rgba(0,0,0,0.1)'
|
||||
: `linear-gradient(135deg, #4FA9E8, #3B82F6)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
cursor: isLoadingExamples ? 'default' : 'pointer',
|
||||
boxShadow: isLoadingExamples ? 'none' : '0 4px 15px rgba(79,169,232,0.4)',
|
||||
transition: 'all 0.2s ease',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
onTouchStart={(e) => { if (!isLoadingExamples) e.currentTarget.style.transform = 'scale(0.96)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
💡 {t('testExamplesButton')}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
if (cmd === '/practice') {
|
||||
return (
|
||||
<button
|
||||
key={cmd}
|
||||
onClick={() => handleCommand(cmd)}
|
||||
disabled={isLoading || isStartingPractice}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '14px 20px',
|
||||
borderRadius: radius.lg,
|
||||
border: 'none',
|
||||
background: isStartingPractice
|
||||
? 'rgba(0,0,0,0.1)'
|
||||
: `linear-gradient(135deg, ${brandColor}, #27AE60)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
cursor: isStartingPractice ? 'default' : 'pointer',
|
||||
boxShadow: isStartingPractice ? 'none' : `0 4px 15px ${brandColor}40`,
|
||||
transition: 'all 0.2s ease',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
onTouchStart={(e) => { if (!isStartingPractice) e.currentTarget.style.transform = 'scale(0.96)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
🎯 {t('testPracticeButton')}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{msg.isCompleted && (
|
||||
<button
|
||||
onClick={handleStart}
|
||||
disabled={isLoading}
|
||||
style={{
|
||||
padding: '16px 32px',
|
||||
marginTop: '10px',
|
||||
padding: '14px 20px',
|
||||
borderRadius: radius.lg,
|
||||
border: 'none',
|
||||
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '16px',
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
cursor: 'pointer',
|
||||
boxShadow: `0 4px 15px ${teacherColor}40`,
|
||||
marginBottom: '10px',
|
||||
transition: 'all 0.2s ease',
|
||||
width: '100%',
|
||||
maxWidth: '280px',
|
||||
}}
|
||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.96)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
{t('teacherStart')}
|
||||
{t('teacherNewLesson')} →
|
||||
</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>
|
||||
)}
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
|
||||
{showContinueButton && (
|
||||
<div style={{ textAlign: 'center', padding: '16px' }}>
|
||||
<button
|
||||
onClick={handleStart}
|
||||
disabled={isLoading}
|
||||
style={{
|
||||
padding: '12px 24px',
|
||||
borderRadius: radius.md,
|
||||
border: 'none',
|
||||
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
cursor: 'pointer',
|
||||
boxShadow: `0 4px 12px ${teacherColor}40`,
|
||||
}}
|
||||
>
|
||||
{t('teacherContinue')} →
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{messages.map((msg) => (
|
||||
<div
|
||||
key={msg.id}
|
||||
style={{
|
||||
alignSelf: msg.type === 'user' ? 'flex-end' : msg.type === 'system' ? 'center' : 'flex-start',
|
||||
maxWidth: '85%',
|
||||
position: 'relative',
|
||||
}}
|
||||
>
|
||||
{isLoading && (
|
||||
<div style={{
|
||||
alignSelf: 'flex-start',
|
||||
padding: '10px 14px',
|
||||
borderRadius: '16px 16px 16px 4px',
|
||||
background: 'rgba(255,255,255,0.8)',
|
||||
border: '1px solid rgba(0,0,0,0.06)',
|
||||
display: 'flex',
|
||||
gap: '4px',
|
||||
alignItems: 'center',
|
||||
}}>
|
||||
{[0, 1, 2].map((i) => (
|
||||
<div
|
||||
key={i}
|
||||
style={{
|
||||
padding: '12px 16px',
|
||||
borderRadius: msg.type === 'user' ? '16px 16px 4px 16px' : msg.type === 'system' ? '16px' : '16px 16px 16px 4px',
|
||||
background: msg.type === 'user'
|
||||
? `linear-gradient(135deg, ${brandColor}, #27AE60)`
|
||||
: msg.type === 'system'
|
||||
? `${teacherColor}20`
|
||||
: 'rgba(255,255,255,0.8)',
|
||||
color: msg.type === 'user' ? '#FFFFFF' : textColor,
|
||||
fontSize: '14px',
|
||||
lineHeight: '1.5',
|
||||
whiteSpace: 'pre-line',
|
||||
border: msg.type === 'user' ? 'none' : `1px solid ${msg.type === 'system' ? teacherColor : 'rgba(0,0,0,0.06)'}`,
|
||||
boxShadow: msg.type === 'user' ? `0 2px 10px ${brandColor}30` : '0 2px 8px rgba(31,38,73,0.06)',
|
||||
animation: 'messageIn 0.3s ease',
|
||||
wordBreak: 'break-word',
|
||||
width: '6px',
|
||||
height: '6px',
|
||||
borderRadius: '50%',
|
||||
background: teacherColor,
|
||||
animation: `typingDot 0.8s ease infinite ${i * 0.15}s`,
|
||||
}}
|
||||
>
|
||||
{msg.text}
|
||||
</div>
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{msg.type === 'bot' && !msg.isQuestion && msg.hasPolishText && (
|
||||
<button
|
||||
onClick={() => playText(msg.text, msg.id)}
|
||||
style={{
|
||||
position: 'absolute',
|
||||
bottom: '-8px',
|
||||
right: '-4px',
|
||||
width: '24px',
|
||||
height: '24px',
|
||||
borderRadius: '50%',
|
||||
border: `1px solid ${brandColor}40`,
|
||||
background: isPlaying === msg.id ? `${brandColor}30` : 'rgba(255,255,255,0.9)',
|
||||
color: brandColor,
|
||||
fontSize: '10px',
|
||||
cursor: 'pointer',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
animation: isPlaying === msg.id ? 'pulse 0.5s ease infinite' : 'none',
|
||||
boxShadow: '0 2px 8px rgba(31,38,73,0.08)',
|
||||
}}
|
||||
>
|
||||
🔊
|
||||
</button>
|
||||
)}
|
||||
|
||||
{msg.isQuestion && msg.options && msg.options.length > 0 && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px', marginTop: '10px' }}>
|
||||
{msg.options.map((option) => (
|
||||
<button
|
||||
key={option.option_key}
|
||||
onClick={() => handleOptionClick(option)}
|
||||
disabled={isLoading}
|
||||
style={{
|
||||
padding: '12px 16px',
|
||||
borderRadius: radius.md,
|
||||
border: `1px solid ${teacherColor}30`,
|
||||
background: `${teacherColor}10`,
|
||||
color: textColor,
|
||||
fontSize: '14px',
|
||||
fontWeight: 600,
|
||||
cursor: 'pointer',
|
||||
transition: 'all 0.2s ease',
|
||||
textAlign: 'left',
|
||||
}}
|
||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.97)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
{msg.optionsLanguage === 'user' ? getLocalized(option, 'text') : option.text_pl}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{msg.commands && msg.commands.length > 0 && (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '8px',
|
||||
marginTop: '12px',
|
||||
width: '100%',
|
||||
maxWidth: '280px',
|
||||
}}>
|
||||
{msg.commands.map((cmd) => {
|
||||
if (cmd === '/show-answer') {
|
||||
return (
|
||||
<button
|
||||
key={cmd}
|
||||
onClick={() => handleCommand(cmd)}
|
||||
disabled={isLoading}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '14px 20px',
|
||||
borderRadius: radius.lg,
|
||||
border: 'none',
|
||||
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
cursor: 'pointer',
|
||||
boxShadow: `0 4px 15px ${teacherColor}40`,
|
||||
transition: 'all 0.2s ease',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.96)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
✅ {t('teacherShowAnswer')}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
if (cmd === '/examples') {
|
||||
return (
|
||||
<button
|
||||
key={cmd}
|
||||
onClick={() => handleCommand(cmd)}
|
||||
disabled={isLoading || isLoadingExamples}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '14px 20px',
|
||||
borderRadius: radius.lg,
|
||||
border: 'none',
|
||||
background: isLoadingExamples
|
||||
? 'rgba(0,0,0,0.1)'
|
||||
: `linear-gradient(135deg, #4FA9E8, #3B82F6)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
cursor: isLoadingExamples ? 'default' : 'pointer',
|
||||
boxShadow: isLoadingExamples ? 'none' : '0 4px 15px rgba(79,169,232,0.4)',
|
||||
transition: 'all 0.2s ease',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
onTouchStart={(e) => { if (!isLoadingExamples) e.currentTarget.style.transform = 'scale(0.96)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
💡 {t('testExamplesButton')}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
if (cmd === '/practice') {
|
||||
return (
|
||||
<button
|
||||
key={cmd}
|
||||
onClick={() => handleCommand(cmd)}
|
||||
disabled={isLoading || isStartingPractice}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '14px 20px',
|
||||
borderRadius: radius.lg,
|
||||
border: 'none',
|
||||
background: isStartingPractice
|
||||
? 'rgba(0,0,0,0.1)'
|
||||
: `linear-gradient(135deg, ${brandColor}, #27AE60)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
cursor: isStartingPractice ? 'default' : 'pointer',
|
||||
boxShadow: isStartingPractice ? 'none' : `0 4px 15px ${brandColor}40`,
|
||||
transition: 'all 0.2s ease',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
onTouchStart={(e) => { if (!isStartingPractice) e.currentTarget.style.transform = 'scale(0.96)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
🎯 {t('testPracticeButton')}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{msg.isCompleted && (
|
||||
<button
|
||||
onClick={handleStart}
|
||||
disabled={isLoading}
|
||||
style={{
|
||||
marginTop: '10px',
|
||||
padding: '14px 20px',
|
||||
borderRadius: radius.lg,
|
||||
border: 'none',
|
||||
background: `linear-gradient(135deg, ${teacherColor}, #6B46C1)`,
|
||||
color: '#FFFFFF',
|
||||
fontSize: '14px',
|
||||
fontWeight: 700,
|
||||
cursor: 'pointer',
|
||||
boxShadow: `0 4px 15px ${teacherColor}40`,
|
||||
transition: 'all 0.2s ease',
|
||||
width: '100%',
|
||||
maxWidth: '280px',
|
||||
}}
|
||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.96)'; }}
|
||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||
>
|
||||
{t('teacherNewLesson')} →
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
|
||||
{isLoading && (
|
||||
<div style={{
|
||||
alignSelf: 'flex-start',
|
||||
padding: '10px 14px',
|
||||
borderRadius: '16px 16px 16px 4px',
|
||||
background: 'rgba(255,255,255,0.8)',
|
||||
border: '1px solid rgba(0,0,0,0.06)',
|
||||
display: 'flex',
|
||||
gap: '4px',
|
||||
alignItems: 'center',
|
||||
}}>
|
||||
{[0, 1, 2].map((i) => (
|
||||
<div
|
||||
key={i}
|
||||
style={{
|
||||
width: '6px',
|
||||
height: '6px',
|
||||
borderRadius: '50%',
|
||||
background: teacherColor,
|
||||
animation: `typingDot 0.8s ease infinite ${i * 0.15}s`,
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div ref={messagesEndRef} />
|
||||
</div>
|
||||
)}
|
||||
<div ref={messagesEndRef} />
|
||||
</div>
|
||||
|
||||
{isQuestionActive && (
|
||||
<div style={{
|
||||
|
||||
Reference in New Issue
Block a user