diff --git a/src/App.jsx b/src/App.jsx
index 6801982..6dfd57d 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -19,7 +19,7 @@ const App = () => {
const [currentAnswerResult, setCurrentAnswerResult] = useState(null);
const [otherPlayersResults, setOtherPlayersResults] = useState([]);
- // Новые состояния для лобби
+ //состояния для лобби
const [showLobby, setShowLobby] = useState(true);
const [currentPlayer, setCurrentPlayer] = useState(null);
const [players, setPlayers] = useState([]);
@@ -381,22 +381,43 @@ const App = () => {
if (quizCompleted) {
const score = calculateScore();
+
+ // Формируем массив всех игроков для таблицы лидеров
const allPlayersScores = [
- { ...currentPlayer, isCurrent: true },
- ...players.filter(p => p.id !== currentPlayer.id)
- ].sort((a, b) => b.score - a.score);
-
+ {
+ ...currentPlayer,
+ isCurrent: true,
+ totalAnswers: userAnswers.filter(a => a && !a.timeExpired).length,
+ correctAnswers: userAnswers.filter(a => {
+ if (!a || a.timeExpired) return false;
+ if (a.id) {
+ const question = quizData.questions[userAnswers.indexOf(a)];
+ return question.answers.find(ans => ans.id === a.id)?.isCorrect;
+ }
+ return false;
+ }).length
+ },
+ ...players
+ .filter(p => p.id !== currentPlayer.id)
+ .map(p => ({
+ ...p,
+ isCurrent: false,
+ totalAnswers: 0, // В реальном приложении здесь были бы данные
+ correctAnswers: 0
+ }))
+ ].sort((a, b) => (b.score || 0) - (a.score || 0));
+
return (
-
{resultMessage}
Правильных ответов: {Math.round(percentage)}%
- {timeExpiredQuestions.length > 0 && ( + {timeExpiredQuestions?.length > 0 && (⚠️ На {timeExpiredQuestions.length} вопрос{(timeExpiredQuestions.length > 1 ? 'ах' : 'е')} время истекло
)} + {currentPlayer && ( ++ 🎯 Всего очков: {currentPlayer.score || 0} +
+ )}