1 | import { Outlet, MakeGenerics, ReactLocation, Router } from 'react-location' |
||
2 | import { Main } from 'pages' |
||
3 | import { Header } from 'shared/ui' |
||
4 | import { ErrorBoundary } from 'entities/ErrorBoundary' |
||
5 | |||
6 | import { fetchMovieDetails } from 'pages/movie/model' |
||
7 | |||
8 | import { IMovieDetails } from 'types/common' |
||
9 | |||
10 | export type LocationGenerics = MakeGenerics<{ |
||
11 | LoaderData: { movie: IMovieDetails } |
||
12 | }> |
||
13 | |||
14 | const location = new ReactLocation<LocationGenerics>() |
||
15 | |||
16 | const Routes = () => ( |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
17 | <> |
||
0 ignored issues
–
show
|
|||
18 | <Router |
||
0 ignored issues
–
show
|
|||
19 | location={location} |
||
0 ignored issues
–
show
|
|||
20 | routes={[ |
||
0 ignored issues
–
show
|
|||
21 | { path: '/', element: <Main /> }, |
||
22 | { |
||
23 | path: 'movie', |
||
24 | children: [ |
||
25 | { |
||
26 | path: ':movieId', |
||
27 | element: () => import('pages/movie').then(mod => <mod.default />), |
||
0 ignored issues
–
show
|
|||
28 | loader: async ({ params: { movieId } }) => { |
||
29 | return { |
||
30 | movie: await fetchMovieDetails(Number(movieId)), |
||
31 | } |
||
32 | }, |
||
33 | }, |
||
34 | ], |
||
35 | }, |
||
36 | ]} |
||
37 | > |
||
38 | <Header /> |
||
0 ignored issues
–
show
|
|||
39 | <ErrorBoundary> |
||
0 ignored issues
–
show
|
|||
40 | <Outlet /> |
||
0 ignored issues
–
show
|
|||
41 | </ErrorBoundary> |
||
42 | </Router> |
||
43 | </> |
||
44 | ) |
||
45 | |||
46 | export { Routes } |
||
47 |