2025-12-31 17:40:34 +00:00
|
|
|
import { useState, useRef } from 'react'
|
2025-12-31 16:53:26 +00:00
|
|
|
import Game from './components/Game'
|
|
|
|
|
import Snowflakes from './components/Snowflakes'
|
2025-12-31 17:40:34 +00:00
|
|
|
import QuestionsModal from './components/QuestionsModal'
|
|
|
|
|
import { questions as initialQuestions } from './data/questions'
|
2025-12-31 16:53:26 +00:00
|
|
|
import './App.css'
|
|
|
|
|
|
|
|
|
|
function App() {
|
2025-12-31 17:40:34 +00:00
|
|
|
const [isQuestionsModalOpen, setIsQuestionsModalOpen] = useState(false)
|
|
|
|
|
const [questions, setQuestions] = useState(initialQuestions)
|
|
|
|
|
const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0)
|
|
|
|
|
const gameRef = useRef(null)
|
|
|
|
|
|
|
|
|
|
const currentQuestion = questions[currentQuestionIndex]
|
|
|
|
|
|
|
|
|
|
const handleUpdateQuestions = (updatedQuestions) => {
|
|
|
|
|
setQuestions(updatedQuestions)
|
|
|
|
|
// Если текущий вопрос был удален, сбрасываем индекс
|
|
|
|
|
if (currentQuestionIndex >= updatedQuestions.length) {
|
|
|
|
|
setCurrentQuestionIndex(0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleOpenPlayersModal = () => {
|
|
|
|
|
if (gameRef.current) {
|
|
|
|
|
gameRef.current.openPlayersModal()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-31 16:53:26 +00:00
|
|
|
return (
|
|
|
|
|
<div className="app">
|
|
|
|
|
<Snowflakes />
|
|
|
|
|
<div className="app-content">
|
2025-12-31 17:40:34 +00:00
|
|
|
<div className="app-title-bar">
|
|
|
|
|
<div className="app-control-buttons">
|
|
|
|
|
<button
|
|
|
|
|
className="control-button control-button-players"
|
|
|
|
|
onClick={handleOpenPlayersModal}
|
|
|
|
|
title="Управление участниками"
|
|
|
|
|
>
|
|
|
|
|
👥
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
className="control-button control-button-questions"
|
|
|
|
|
onClick={() => setIsQuestionsModalOpen(true)}
|
|
|
|
|
title="Управление вопросами"
|
|
|
|
|
>
|
|
|
|
|
❓
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<h1 className="app-title">
|
|
|
|
|
<span className="title-number">100</span>
|
|
|
|
|
<span className="title-to">к</span>
|
|
|
|
|
<span className="title-number">1</span>
|
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
|
|
{questions.length > 0 && currentQuestion && (
|
|
|
|
|
<div className="question-counter">
|
|
|
|
|
{currentQuestionIndex + 1}/{questions.length}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<QuestionsModal
|
|
|
|
|
isOpen={isQuestionsModalOpen}
|
|
|
|
|
onClose={() => setIsQuestionsModalOpen(false)}
|
|
|
|
|
questions={questions}
|
|
|
|
|
onUpdateQuestions={handleUpdateQuestions}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<Game
|
|
|
|
|
ref={gameRef}
|
|
|
|
|
questions={questions}
|
|
|
|
|
currentQuestionIndex={currentQuestionIndex}
|
|
|
|
|
onQuestionIndexChange={setCurrentQuestionIndex}
|
|
|
|
|
onQuestionsChange={setQuestions}
|
|
|
|
|
/>
|
2025-12-31 16:53:26 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App
|
|
|
|
|
|