Skip to content

Commit 385ee85

Browse files
authored
Merge pull request #975 from aisaenok/issues-897
#897: Компонент личного кабинета с меню
2 parents 964b8f5 + bc38de3 commit 385ee85

File tree

23 files changed

+334
-6
lines changed

23 files changed

+334
-6
lines changed

frontend/package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dev": "vite",
1212
"build": "tsc -b && vite build",
1313
"lint": "eslint .",
14-
"preview": "vite preview"
14+
"preview": "vite preview --host 0.0.0.0 --port $PORT"
1515
},
1616
"dependencies": {
1717
"@inertiajs/inertia": "^0.11.1",
@@ -20,6 +20,7 @@
2020
"@mantine/core": "^8.2.1",
2121
"@mantine/form": "^8.2.1",
2222
"@mantine/hooks": "^8.2.1",
23+
"@tabler/icons-react": "^3.36.1",
2324
"@types/node": "^24.10.0",
2425
"add": "^2.0.6",
2526
"i18next": "^25.6.3",
@@ -52,4 +53,4 @@
5253
"public"
5354
]
5455
}
55-
}
56+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { http, delay } from 'msw'
2+
import { inertiaJson } from '@mocks/inertia'
3+
import type { MenuItem } from '@shared/types/inertiaSharedData'
4+
5+
const menu: MenuItem[] = [
6+
{ label: 'Мое обучение' },
7+
{ label: 'Покупки и подписки',
8+
link: '/account/purchase' },
9+
{ label: 'Вебинары',
10+
link: '/account/webinars' },
11+
{ label: 'База знаний' },
12+
{ label: 'Интервью' },
13+
{ label: 'Грейдирование' },
14+
{ label: 'Программы обучения' },
15+
]
16+
17+
const makeHandler = ({ component, url}: { component: string, url: string }) =>
18+
http.get(url, async ({ request }) => {
19+
console.log('MSW handler hit:', request.method, request.url)
20+
await delay()
21+
return inertiaJson({
22+
component,
23+
props: {
24+
errors: {},
25+
menu,
26+
},
27+
url,
28+
version: 'msw-dev',
29+
})
30+
})
31+
32+
const routes = [
33+
{
34+
component: 'Account/Purchase/Index',
35+
url: '/account',
36+
},
37+
{
38+
component: 'Account/Purchase/Index',
39+
url: '/account/purchase',
40+
},
41+
{
42+
component: 'Account/Webinars/Index',
43+
url: '/account/webinars',
44+
},
45+
] as const
46+
47+
export const handlers = routes.map(makeHandler)

frontend/src/mocks/handlers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import { handlers as homeHadnlers } from '@mocks/home'
2+
import { handlers as accountHadnlers } from '@mocks/account'
23

3-
export const handlers = [...homeHadnlers]
4+
export const handlers = [...homeHadnlers, ...accountHadnlers]

frontend/src/mocks/home/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { http, delay } from 'msw'
2-
import { inertiaJson } from '../inertia'
2+
import { inertiaJson } from '@mocks/inertia'
33

44
export const handlers = [
55
http.get(/\/(\?.*)?$/, async ({ request }) => {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { InertiaPage } from '@shared/types/inertia'
2+
import { AppLayout } from '../components/AppLayout'
3+
4+
const Purchase: InertiaPage = () => {
5+
return 'Purchase'
6+
}
7+
8+
Purchase.layout = page => (
9+
<AppLayout>
10+
{page}
11+
</AppLayout>
12+
)
13+
14+
export default Purchase
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Страница личного кабинета
2+
3+
## Страницы
4+
5+
- Шапка - данные пользователя, уведомления, кнопка выхода и т п
6+
- Левое меню - данные получаем с сервера
7+
- Активный раздел меню - отображает контект выбранного раздела меню
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { InertiaPage } from '@shared/types/inertia'
2+
import { AppLayout } from '../components/AppLayout'
3+
4+
const Webinars: InertiaPage = () => {
5+
return 'Webinars'
6+
}
7+
8+
Webinars.layout = page => (
9+
<AppLayout>
10+
{page}
11+
</AppLayout>
12+
)
13+
14+
export default Webinars
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Header } from '@widgets/Header'
2+
import { Navbar } from './Navbar'
3+
import { SectionLayout } from './SectionLayout'
4+
import { Flex } from '@mantine/core'
5+
import { Footer } from '@widgets/Footer'
6+
import React from 'react'
7+
8+
type TProps = {
9+
children: React.ReactNode
10+
}
11+
12+
export const AppLayout: React.FC<TProps> = (props) => {
13+
const { children } = props
14+
15+
return (
16+
<Flex direction="column" mih="100vh">
17+
<Header />
18+
<Flex align="stretch" style={{ flex: 1 }}>
19+
<Navbar />
20+
<SectionLayout>{children}</SectionLayout>
21+
</Flex>
22+
<Footer />
23+
</Flex>
24+
)
25+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.header {
2+
height: 56px;
3+
background-color: var(--mantine-color-body);
4+
border-bottom: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
5+
padding-left: var(--mantine-spacing-md);
6+
padding-right: var(--mantine-spacing-md);
7+
}
8+
9+
.inner {
10+
height: 56px;
11+
display: flex;
12+
justify-content: space-between;
13+
align-items: center;
14+
}

0 commit comments

Comments
 (0)