1
1
import React , { useContext } from 'react' ;
2
- import { MemoryRouter , HashRouter , BrowserRouter , Routes , Route } from 'react-router-dom' ;
3
- import { Box , Slide , Typography , styled } from '@mui/material' ;
2
+ import { MemoryRouter , HashRouter , BrowserRouter } from 'react-router-dom' ;
3
+ import { Box , Typography , styled } from '@mui/material' ;
4
4
import { type UseAppStoreType , AppContext , closeAll } from '../contexts/AppContext' ;
5
5
6
- import { RobotPage , MakerPage , BookPage , OrderPage , SettingsPage , NavBar , MainDialogs } from './' ;
6
+ import { NavBar , MainDialogs } from './' ;
7
7
import RobotAvatar from '../components/RobotAvatar' ;
8
8
import Notifications from '../components/Notifications' ;
9
9
10
10
import { useTranslation } from 'react-i18next' ;
11
11
import { GarageContext , type UseGarageStoreType } from '../contexts/GarageContext' ;
12
+ import Routes from './Routes' ;
12
13
13
- function getRouter ( ) {
14
+ const getRouter = ( ) : any => {
14
15
if ( window . NativeRobosats === undefined && window . RobosatsClient === undefined ) {
15
16
return BrowserRouter ;
16
17
} else if ( window . RobosatsClient === 'desktop-app' ) {
17
18
return HashRouter ;
18
19
} else {
19
20
return MemoryRouter ;
20
21
}
21
- }
22
+ } ;
22
23
const Router = getRouter ( ) ;
23
24
24
25
const TestnetTypography = styled ( Typography ) ( {
@@ -38,7 +39,7 @@ const MainBox = styled(Box)<MainBoxProps>((props) => ({
38
39
39
40
const Main : React . FC = ( ) => {
40
41
const { t } = useTranslation ( ) ;
41
- const { settings, page, slideDirection , setOpen, windowSize, navbarHeight } =
42
+ const { settings, page, setOpen, windowSize, navbarHeight } =
42
43
useContext < UseAppStoreType > ( AppContext ) ;
43
44
const { garage } = useContext < UseGarageStoreType > ( GarageContext ) ;
44
45
@@ -62,88 +63,7 @@ const Main: React.FC = () => {
62
63
) }
63
64
64
65
< MainBox navbarHeight = { navbarHeight } >
65
-
66
- < Routes >
67
- { [ '/robot/:token?' , '/' , '' ] . map ( ( path , index ) => {
68
- return (
69
- < Route
70
- path = { path }
71
- element = {
72
- < Slide
73
- direction = { page === 'robot' ? slideDirection . in : slideDirection . out }
74
- in = { page === 'robot' }
75
- appear = { slideDirection . in !== undefined }
76
- >
77
- < div >
78
- < RobotPage />
79
- </ div >
80
- </ Slide >
81
- }
82
- key = { index }
83
- />
84
- ) ;
85
- } ) }
86
-
87
- < Route
88
- path = { '/offers' }
89
- element = {
90
- < Slide
91
- direction = { page === 'offers' ? slideDirection . in : slideDirection . out }
92
- in = { page === 'offers' }
93
- appear = { slideDirection . in !== undefined }
94
- >
95
- < div >
96
- < BookPage />
97
- </ div >
98
- </ Slide >
99
- }
100
- />
101
-
102
- < Route
103
- path = '/create'
104
- element = {
105
- < Slide
106
- direction = { page === 'create' ? slideDirection . in : slideDirection . out }
107
- in = { page === 'create' }
108
- appear = { slideDirection . in !== undefined }
109
- >
110
- < div >
111
- < MakerPage />
112
- </ div >
113
- </ Slide >
114
- }
115
- />
116
-
117
- < Route
118
- path = '/order/:shortAlias/:orderId'
119
- element = {
120
- < Slide
121
- direction = { page === 'order' ? slideDirection . in : slideDirection . out }
122
- in = { page === 'order' }
123
- appear = { slideDirection . in !== undefined }
124
- >
125
- < div >
126
- < OrderPage />
127
- </ div >
128
- </ Slide >
129
- }
130
- />
131
-
132
- < Route
133
- path = '/settings'
134
- element = {
135
- < Slide
136
- direction = { page === 'settings' ? slideDirection . in : slideDirection . out }
137
- in = { page === 'settings' }
138
- appear = { slideDirection . in !== undefined }
139
- >
140
- < div >
141
- < SettingsPage />
142
- </ div >
143
- </ Slide >
144
- }
145
- />
146
- </ Routes >
66
+ < Routes />
147
67
</ MainBox >
148
68
< NavBar />
149
69
< MainDialogs />
0 commit comments