import { createBrowserRouter, redirect, RouterProvider } from 'react-router-dom' import MainLayout from './layout/MainLayout' import Home from './pages/Home' import Settings from './pages/Settings/Settings' import Friends from './pages/Settings/Friends' import Password from './pages/Settings/Password' import Themes from './pages/Settings/Themes' import PlayLayout from './pages/Play/Layout' import PlayFriend from './pages/Play/PlayFriend' import Play from './pages/Play/Play' import AuthenticationPage from './pages/Authentication/Authentication' import ChallengeFriend, { playFriendAction } from './pages/Play/ChallengeFriend' import Profile, { action as profileAction } from './pages/Settings/Profile' import { getAuthToken, getUserData } from './utils/auth' import Computer, { playComputerAction } from './pages/Play/Computer' import ComputerGame from './pages/Play/ComputerGame' import MultiplayerGame from './pages/Play/MultiplayerGame' const router = createBrowserRouter([{ path: '/', element: , loader: () => getUserData() || redirect('/login'), children: [ { index: true, element: }, { path: 'home', element: }, { path: 'play', element: , children: [ { index: true, element: }, { path: 'friend/:friend_username', element: , action: playFriendAction }, { path: 'friend', element: }, { path: 'computer', element: , action: playComputerAction }, { path: 'online', element:
Online
} ] }, { path: "game/friend/:roomID", element: }, { path: "game/computer", element: }, { path: 'settings', element: , children: [ { index: true, element: , action: profileAction }, { path: 'profile', element: , action: profileAction }, { path: 'themes', element: }, { path: 'password', element: }, { path: 'friends', element: }, ] }, ] }, { path: '/login', element: , loader: () => { if (getAuthToken()) return redirect('/home'); else return null; } }, { path: '/signup', element: , loader: () => { if (getAuthToken()) return redirect('/signup'); else return null; } }, { path: '/logout', loader: () => { getAuthToken() || redirect('/home') } }]); function App() { return ( ) } export default App