blob: 442473fdab401d521ff2d786354792c8c982cdc9 [file] [log] [blame]
simon3f5f3e72022-11-08 21:01:57 -05001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
18import { createBrowserRouter, createRoutesFromElements, Outlet, Route } from 'react-router-dom';
19
20import App from './App';
21import ContactList from './components/ContactList';
22import AuthProvider from './contexts/AuthProvider';
23import WebSocketProvider from './contexts/WebSocketProvider';
24import AccountSettings from './pages/AccountSettings';
25import CallInterface from './pages/CallInterface';
26import Messenger from './pages/Messenger';
27import ServerSetup from './pages/ServerSetup';
28import Welcome from './pages/Welcome';
29import { ThemeDemonstrator } from './themes/ThemeDemonstrator';
30import { RouteParams } from './utils/hooks';
31
32export type MessengerRouteParams = RouteParams<{ conversationId?: string; contactId?: string }, Record<string, never>>;
33export type CallRouteParams = RouteParams<{ conversationId: string }, { video?: 'true' }>;
34
35export const router = createBrowserRouter(
36 createRoutesFromElements(
37 <Route path="/" element={<App />}>
38 <Route path="login" element={<Welcome />} />
39 <Route path="theme" element={<ThemeDemonstrator />} />
40 <Route
41 element={
42 <AuthProvider>
43 <WebSocketProvider>
44 <Outlet />
45 </WebSocketProvider>
46 </AuthProvider>
47 }
48 >
49 <Route path="addContact/:contactId" element={<Messenger />} />
50 <Route path="conversation/:conversationId" element={<Messenger />} />
51 <Route path="call/:conversationId" element={<CallInterface />} />
52 <Route path="settings" element={<AccountSettings />} />
53 <Route path="contacts" element={<ContactList />} />
54 <Route index element={<Messenger />} />
55 </Route>
56 <Route path="setup" element={<ServerSetup />} />
57 </Route>
58 )
59);