simon | 26e79f7 | 2022-10-05 22:16:08 -0400 | [diff] [blame] | 1 | /* |
| 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 | */ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 18 | 'use strict'; |
| 19 | import './index.scss'; |
idillon | 5815c73 | 2022-09-16 13:54:45 -0400 | [diff] [blame] | 20 | import './i18n'; |
Larbi Gharib | e9af973 | 2021-03-31 15:08:01 +0100 | [diff] [blame] | 21 | |
idillon | 8e6c006 | 2022-09-16 13:34:43 -0400 | [diff] [blame] | 22 | // import config from "../sentry-client.config.json" |
idillon | 08f7717 | 2022-09-13 19:14:17 -0400 | [diff] [blame] | 23 | import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 24 | import { StrictMode } from 'react'; |
| 25 | import { createRoot } from 'react-dom/client'; |
| 26 | import { Provider } from 'react-redux'; |
| 27 | import { BrowserRouter as Router } from 'react-router-dom'; |
idillon | 322e4ac | 2022-09-14 12:48:43 -0400 | [diff] [blame] | 28 | import socketio from 'socket.io-client'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 29 | |
simon | 218d3d1 | 2022-10-01 17:27:01 -0400 | [diff] [blame] | 30 | import App from './App'; |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 31 | import { SocketProvider } from './contexts/Socket'; |
simon | d8ca2f2 | 2022-10-11 23:30:55 -0400 | [diff] [blame] | 32 | import { store } from './redux/store'; |
idillon | 08f7717 | 2022-09-13 19:14:17 -0400 | [diff] [blame] | 33 | |
| 34 | const queryClient = new QueryClient({ |
| 35 | defaultOptions: { |
| 36 | queries: { |
| 37 | cacheTime: Infinity, // websocket is responsible to tell when data needs to be updated |
| 38 | }, |
| 39 | }, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 40 | }); |
idillon | 5e89743 | 2022-09-16 13:28:09 -0400 | [diff] [blame] | 41 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 42 | const socket = socketio(); |
idillon | 322e4ac | 2022-09-14 12:48:43 -0400 | [diff] [blame] | 43 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 44 | const container = document.getElementById('root'); |
simon | 218d3d1 | 2022-10-01 17:27:01 -0400 | [diff] [blame] | 45 | if (!container) { |
| 46 | throw new Error('Failed to get the root element'); |
| 47 | } |
idillon | 169f64f | 2022-09-16 14:01:22 -0400 | [diff] [blame] | 48 | const root = createRoot(container); |
| 49 | root.render( |
| 50 | <Provider store={store}> |
Adrien Béraud | 023f7cf | 2022-09-18 14:57:53 -0400 | [diff] [blame] | 51 | <StrictMode> |
idillon | 08f7717 | 2022-09-13 19:14:17 -0400 | [diff] [blame] | 52 | <QueryClientProvider client={queryClient}> |
idillon | 322e4ac | 2022-09-14 12:48:43 -0400 | [diff] [blame] | 53 | <SocketProvider socket={socket}> |
| 54 | <Router> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 55 | <App /> |
idillon | 322e4ac | 2022-09-14 12:48:43 -0400 | [diff] [blame] | 56 | </Router> |
| 57 | </SocketProvider> |
idillon | 08f7717 | 2022-09-13 19:14:17 -0400 | [diff] [blame] | 58 | </QueryClientProvider> |
Adrien Béraud | 023f7cf | 2022-09-18 14:57:53 -0400 | [diff] [blame] | 59 | </StrictMode> |
idillon | 169f64f | 2022-09-16 14:01:22 -0400 | [diff] [blame] | 60 | </Provider> |
| 61 | ); |