diff --git a/packages/frontend/src/App.tsx b/packages/frontend/src/App.tsx index d2976a6..c25df66 100644 --- a/packages/frontend/src/App.tsx +++ b/packages/frontend/src/App.tsx @@ -1,52 +1,5 @@ -import { createBrowserRouter, RouterProvider } from 'react-router-dom'; -import { lazy, Suspense, useEffect } from 'react'; -import Layout from '@/components/layout/Layout'; -import LoadingSpinner from '@/components/common/LoadingSpinner'; -import PublicRoute from '@/components/PublicRoute'; -import PrivateRoute from '@/components/PrivateRoute'; - -const LandingPage = lazy(() => import('@/pages/landingPage/index')); -const LobbyPage = lazy(() => import('@/pages/lobbyPage/index')); -const GamePage = lazy(() => import('@/pages/gamePage/index')); - -const router = createBrowserRouter([ - { - path: '/', - element: , - children: [ - { - index: true, - element: ( - - }> - - - - ), - }, - { - path: 'lobby', - element: ( - - }> - - - - ), - }, - { - path: 'game/:gsid', - element: ( - - }> - - - - ), - }, - ], - }, -]); +import { useEffect } from 'react'; +import AppRouter from './routes/router'; function App() { useEffect(() => { @@ -61,7 +14,7 @@ function App() { }; }, []); - return ; + return ; } export default App; diff --git a/packages/frontend/src/routes/router.tsx b/packages/frontend/src/routes/router.tsx new file mode 100644 index 0000000..2b00793 --- /dev/null +++ b/packages/frontend/src/routes/router.tsx @@ -0,0 +1,54 @@ +import LoadingSpinner from '@/components/common/LoadingSpinner'; +import Layout from '@/components/layout/Layout'; +import { lazy } from 'react'; +import PrivateRoute from '@/components/PrivateRoute'; +import PublicRoute from '@/components/PublicRoute'; +import { Suspense } from 'react'; +import { createBrowserRouter, RouterProvider } from 'react-router-dom'; + +const LandingPage = lazy(() => import('@/pages/landingPage/index')); +const LobbyPage = lazy(() => import('@/pages/lobbyPage/index')); +const GamePage = lazy(() => import('@/pages/gamePage/index')); + +export default function AppRouter() { + const router = createBrowserRouter([ + { + path: '/', + element: , + children: [ + { + index: true, + element: ( + + }> + + + + ), + }, + { + path: 'lobby', + element: ( + + }> + + + + ), + }, + { + path: 'game/:gsid', + element: ( + + }> + + + + ), + }, + ], + }, + ]); + + return ; +}