Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c43dfa4092 |
Generated
+60
-43
@@ -8,10 +8,9 @@
|
||||
"name": "store-client",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"immer": "^11.1.8",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"zustand": "^5.0.14"
|
||||
"react-router-dom": "^7.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.25.0",
|
||||
@@ -1369,7 +1368,7 @@
|
||||
"version": "19.1.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.6.tgz",
|
||||
"integrity": "sha512-JeG0rEWak0N6Itr6QUx+X60uQmN+5t3j9r/OVDtWzFXKaj6kD1BwJzOksD0FF6iWxZlbE1kB0q9vtnU2ekqa1Q==",
|
||||
"devOptional": true,
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"csstype": "^3.0.2"
|
||||
@@ -1602,6 +1601,19 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cookie": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz",
|
||||
"integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||
@@ -1621,7 +1633,7 @@
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
|
||||
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
|
||||
"devOptional": true,
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/debug": {
|
||||
@@ -2056,16 +2068,6 @@
|
||||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/immer": {
|
||||
"version": "11.1.8",
|
||||
"resolved": "https://registry.npmjs.org/immer/-/immer-11.1.8.tgz",
|
||||
"integrity": "sha512-/tbkHMW7y10Lx6i1crLjD4/OhNkRG+Fo7byZHtah0547nIeXYcpIXaUh0IAQY6gO5459qpGGYapcEOHtFXkIuA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/immer"
|
||||
}
|
||||
},
|
||||
"node_modules/import-fresh": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
|
||||
@@ -2483,6 +2485,44 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-router": {
|
||||
"version": "7.17.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.17.0.tgz",
|
||||
"integrity": "sha512-FDELK7rTMlCHO5+reyXsPlmfr7N1F91lPHsWYfMEGQm/KQ+F4JFM8jGoeQDmDvdTs93Fw9aSilH+uKRb4/jXvQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cookie": "^1.0.1",
|
||||
"set-cookie-parser": "^2.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18",
|
||||
"react-dom": ">=18"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-router-dom": {
|
||||
"version": "7.17.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.17.0.tgz",
|
||||
"integrity": "sha512-fyU2yjGups/hE6Xz0I5ZYbVL8Gx29eCjgpHaRaTaVU+OOAdfRX05KsvyRm0GO8YQwOkhpU3MurW1jyMUJn+zSw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"react-router": "7.17.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18",
|
||||
"react-dom": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/resolve-from": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
|
||||
@@ -2556,6 +2596,12 @@
|
||||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/set-cookie-parser": {
|
||||
"version": "2.7.2",
|
||||
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.2.tgz",
|
||||
"integrity": "sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/shebang-command": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||
@@ -2806,35 +2852,6 @@
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/zustand": {
|
||||
"version": "5.0.14",
|
||||
"resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.14.tgz",
|
||||
"integrity": "sha512-/8tAspM5LMPr28b3fwLYrtdj77ECpfZviaP75CMTnwO8ISyaE4GDIG/9rDDYq/cH9D2Xw2A2RXglLInmVBQB/g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12.20.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": ">=18.0.0",
|
||||
"immer": ">=9.0.6",
|
||||
"react": ">=18.0.0",
|
||||
"use-sync-external-store": ">=1.2.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"immer": {
|
||||
"optional": true
|
||||
},
|
||||
"react": {
|
||||
"optional": true
|
||||
},
|
||||
"use-sync-external-store": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -10,10 +10,9 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"immer": "^11.1.8",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"zustand": "^5.0.14"
|
||||
"react-router-dom": "^7.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.25.0",
|
||||
|
||||
+22
-5
@@ -1,11 +1,28 @@
|
||||
import Quiz from './components/Quiz'
|
||||
import { Suspense, lazy } from 'react'
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom'
|
||||
|
||||
const HomePage = lazy(() => import('./pages/HomePage'))
|
||||
const AboutPage = lazy(() => import('./pages/AboutPage'))
|
||||
const ContactPage = lazy(() => import('./pages/ContactPage'))
|
||||
const AdminPanel = lazy(() => import('./pages/AdminPanel'))
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<>
|
||||
<h1>Практика по созданию списка задач</h1>
|
||||
<Quiz />
|
||||
</>
|
||||
<BrowserRouter>
|
||||
<div>
|
||||
<nav><a href='/'>Главная</a> <a href='/about'>О нас</a> <a href='/contact'>Контакты</a></nav>
|
||||
<main>
|
||||
<Suspense fallback={<div>Загрузка ...</div>}>
|
||||
<Routes>
|
||||
<Route path='/' element={<HomePage />} />
|
||||
<Route path='/about' element={<AboutPage />} />
|
||||
<Route path='/contact' element={<ContactPage />} />
|
||||
<Route path='/admin' element={<AdminPanel />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
</main>
|
||||
</div>
|
||||
</BrowserRouter>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import { useState } from 'react'
|
||||
|
||||
const Question = ({question, onSubmit}) => {
|
||||
const [selectedOption,setSelectedOption] = useState('')
|
||||
const handleSubmit = () => {
|
||||
console.log(selectedOption);
|
||||
if (selectedOption) onSubmit(selectedOption);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Вопрос {question.id}: {question.text}</h2>
|
||||
<div>
|
||||
{question.options.map((option, index)=>(
|
||||
<label key={index}>
|
||||
<input
|
||||
type="radio"
|
||||
name={`question-${question.id}`}
|
||||
value={option}
|
||||
checked={selectedOption === option}
|
||||
onChange={() => setSelectedOption(option)} />
|
||||
{option}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
<button onClick={handleSubmit} >Следующий вопрос</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Question
|
||||
@@ -1,35 +0,0 @@
|
||||
import useQuizStore from './store/useQuizStore'
|
||||
import Question from './Question'
|
||||
import Result from './Result'
|
||||
|
||||
const Quiz = () => {
|
||||
const {
|
||||
questions,
|
||||
currentQuestion,
|
||||
userAswers,
|
||||
isFinished,
|
||||
submitAnswer,
|
||||
goToNextQuestion,
|
||||
restartQuiz,
|
||||
} = useQuizStore();
|
||||
|
||||
const handleAnswerSubmit = (anwser) => {
|
||||
console.log('Yes')
|
||||
submitAnswer(answer)
|
||||
if (currentQuestion < questions.length - 1 ) {
|
||||
goToNextQuestion()
|
||||
}
|
||||
}
|
||||
if(isFinished) {
|
||||
return (<Result />)
|
||||
}
|
||||
return (
|
||||
<div className="quiz">
|
||||
<Question
|
||||
question={questions[currentQuestion]}
|
||||
onSubmit={handleAnswerSubmit} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Quiz
|
||||
@@ -1,9 +0,0 @@
|
||||
const Result = ({questions, userAswers, onRestart}) => {
|
||||
return (
|
||||
<div>
|
||||
<h2>Результат</h2>
|
||||
<button onClick={onRestart}>Начать заново</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default Result
|
||||
@@ -1,36 +0,0 @@
|
||||
import { create } from 'zustand'
|
||||
|
||||
const useQuizStore = create(set => ({
|
||||
questions: [
|
||||
{
|
||||
id:1,
|
||||
text: 'Сколько будет 2+2?',
|
||||
options: ['3','4','2'],
|
||||
correctAnswer: '4',
|
||||
},
|
||||
{
|
||||
id:2,
|
||||
text: 'Столица России?',
|
||||
options: ['Москва','Париж','Лондон'],
|
||||
correctAnswer: 'Москва',
|
||||
},
|
||||
],
|
||||
currentQuestion: 0,
|
||||
userAnswer:[],
|
||||
isFinished: false,
|
||||
goToNextQuestion: () => set(state => ({
|
||||
currentQuestion: state.currentQuestion + 1,
|
||||
})),
|
||||
submitAnswer: answer => set(state => {
|
||||
const updatedAnswer = [...state.userAnswer, answer];
|
||||
const isFinished = (state.currentQuestion >= state.questions.length - 1);
|
||||
return {userAnswer: updatedAnswer, isFinished};
|
||||
}),/*
|
||||
restartQuiz: () => set({
|
||||
currentQuestion: 0,
|
||||
userAnswer: [],
|
||||
isFinished: false
|
||||
}), */
|
||||
}))
|
||||
|
||||
export default useQuizStore
|
||||
@@ -4,5 +4,7 @@ import { createRoot } from 'react-dom/client'
|
||||
import App from './App.jsx'
|
||||
|
||||
createRoot(document.getElementById('root')).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
export function MyComponent() {
|
||||
return (
|
||||
<>
|
||||
<h1>About Page</h1>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default MyComponent
|
||||
@@ -0,0 +1,9 @@
|
||||
export function MyComponent() {
|
||||
return (
|
||||
<>
|
||||
<h1>Admin Page</h1>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default MyComponent
|
||||
@@ -0,0 +1,9 @@
|
||||
export function MyComponent() {
|
||||
return (
|
||||
<>
|
||||
<h1>Contact Page</h1>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default MyComponent
|
||||
@@ -0,0 +1,9 @@
|
||||
export function MyComponent() {
|
||||
return (
|
||||
<>
|
||||
<h1>Home Page</h1>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default MyComponent
|
||||
Reference in New Issue
Block a user