diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index a94c4ce..230cdba 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -1,16 +1,18 @@
import { Navigate, Route, RouterProvider, createBrowserRouter, createRoutesFromElements, useLocation, useRouteLoaderData } from 'react-router-dom'
import PropTypes from 'prop-types'
+import { UserProvider } from './store/user'
+import { ajax } from './utils/fetch'
+
import Layout from './components/Layout'
import Index from './pages/Index'
import Login from './pages/Login'
import Register from './pages/Register'
import NoMatch from './pages/NoMatch'
-import { UserProvider } from './store/user'
-import { ajax } from './utils/fetch'
import Engine from './pages/Engine'
import Quests from './pages/Quests'
+import User from './pages/User'
const router = createBrowserRouter(
createRoutesFromElements(
@@ -30,6 +32,7 @@ const router = createBrowserRouter(
element={}
loader={() => ajax('/api/games').catch(x => { console.log(x); return null })}
/>
+ } />
} />
} />
{
@@ -34,65 +34,32 @@ const AppLayout = () => {
link: '/quests'
},
{
- key: 'user',
- label: user.username,
- children: [
- {
- type: 'group',
- key: 'exp',
- label: (
-
- {user.level} уровень
- {user.experience} опыт
- )
- },
- {
- type: 'group',
- key: 'progress',
- label:
- },
- {
- type: 'group',
- key: 'nextLevel',
- label: `Следующий уровень - ${user.expToNextLevel} очков опыта`
- },
- {
- key: 'logout',
- label: 'Выход',
- handler: logout
- }
- ]
+ key: 'me',
+ label: `${user.username} [${user.level}]`,
+ link: '/me'
+ },
+ {
+ key: 'logout',
+ label: 'Выход',
+ onClick: logout
}
]
}
const menuHandler = (x) => {
- const item = getItemByPath(items, x.keyPath)
+ const item = items.find(y => y.key === x.key)
if (item.link) { navigate(item.link) }
- if (item.handler) { item.handler() }
- }
-
- const getItemByPath = (items, path) => {
- const x = path.pop()
- const item = items.find(y => y.key === x)
- if (path.length === 0) {
- return item
- }
- return getItemByPath(item.children, path)
}
return (
-
+
}
+ style={{ width: '100%' }}
/>
diff --git a/frontend/src/pages/Quests.jsx b/frontend/src/pages/Quests.jsx
index 207c844..8c5e509 100644
--- a/frontend/src/pages/Quests.jsx
+++ b/frontend/src/pages/Quests.jsx
@@ -2,10 +2,10 @@ import { useLoaderData, useNavigate } from 'react-router-dom'
import Markdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import moment from 'moment/min/moment-with-locales'
-import { Avatar, Typography, Button, Space, Card } from 'antd'
+import { Avatar, Typography, Button, Space, Card, Popover } from 'antd'
import { UserProvider } from '../store/user'
-const { Title } = Typography
+const { Title, Paragraph } = Typography
const Quests = () => {
moment.locale('ru')
@@ -22,10 +22,25 @@ const Quests = () => {
const renderItem = (user, navigate, item) => {
const actions = [
- Оп: {item.points},
- Ур: {item.taskCount},
+ Квесты бывают двух типов: - Виртуальные - проходимые из дома
- Полевые - проходимые в городе Казани
}
+ title="Тип квеста">
+
+ {item.type === 'city' ? 'Полевой' : 'Виртуальный'}
+
+ ,
+ Вы получите {item.points} очков опыта за выполнение этого квеста.
Чем сложнее квест - тем больше за него опыта!}
+ title='Опыт за выполнения квеста'>
+ {item.points} ОО
+ ,
+
+ {item.taskCount} ур
+ ,
<>{moment(item.createdAt).fromNow()}>,
- <>Автор(ы) {item.authors.map(a => a.username)}>
+ <>Автор {item.authors.map(a => a.username)}>
]
let questAction = (Необходимо войти)
@@ -41,11 +56,9 @@ const renderItem = (user, navigate, item) => {
{item.title}>}
style={{ marginBottom: 8 }}
>
-
-
{item.description}
diff --git a/frontend/src/pages/User.jsx b/frontend/src/pages/User.jsx
new file mode 100644
index 0000000..f7852f9
--- /dev/null
+++ b/frontend/src/pages/User.jsx
@@ -0,0 +1,34 @@
+import { Avatar, Popover, Progress, Space, Typography } from 'antd'
+import { UserProvider } from '../store/user'
+import Markdown from 'react-markdown'
+
+const { Paragraph } = Typography
+
+const User = () => {
+ const { user } = UserProvider.useContainer()
+ if (user == null) {
+ return (Загрузка...)
+ }
+
+ return (<>
+ {user.username}
+ Уровень: {user.level} ур
+ Очков опыта: {user.experience} ОО
+ Следующий уровень: {user.expToNextLevel} ОО
+
+ {user.games.map(item => {item.description}}
+ >
+
+ )}
+ >)
+}
+
+export default User