generated from yandex-praktikum/client-server-template-with-vite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.tsx
67 lines (63 loc) · 1.81 KB
/
router.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { createRef } from 'react'
import {
MainPage,
StartScreen,
LoginPage,
SignUpPage,
ProfilePage,
LeaderBoard,
ForumPage,
ForumItemPage,
EndPage,
GamePage,
Error500,
Error404,
} from '../pages'
import { protectedRoutes, publicRoutes } from '../constants/browserRoutes'
const {
main,
startScreen,
profile,
board,
forum,
forumItem,
game,
error505,
endScreen,
} = protectedRoutes
const { signUp, login, error404, error500, noMatch } = publicRoutes
export const publilRoutes = {
signUp: { path: signUp, element: <SignUpPage />, nodeRef: createRef() },
login: { path: login, element: <LoginPage />, nodeRef: createRef() },
error404: { path: error404, element: <Error404 />, nodeRef: createRef() },
error500: { path: error500, element: <Error500 />, nodeRef: createRef() },
noMatch: {
path: noMatch,
element: <Error404 />,
nodeRef: createRef(),
},
}
export const privateRoutes = {
mainPage: { path: main, element: <MainPage />, nodeRef: createRef() },
startScreen: {
path: startScreen,
element: <StartScreen />,
nodeRef: createRef(),
},
profile: { path: profile, element: <ProfilePage />, nodeRef: createRef() },
board: { path: board, element: <LeaderBoard />, nodeRef: createRef() },
forum: { path: forum, element: <ForumPage />, nodeRef: createRef() },
forumItem: {
path: forumItem,
element: <ForumItemPage />,
nodeRef: createRef(),
},
end: { path: endScreen, element: <EndPage />, nodeRef: createRef() },
game: { path: game, element: <GamePage />, nodeRef: createRef() },
error505: { path: error505, element: <Error500 />, nodeRef: createRef() },
}
export const getAllRoutes = () => {
const publicArray = Object.values(publilRoutes)
const protectedArray = Object.values(privateRoutes)
return publicArray.concat(protectedArray)
}