blob: fdd2fe76ad228e4f17e0894308b8da557d2fccd5 [file] [log] [blame]
simon26e79f72022-10-05 22:16:08 -04001/*
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 */
simon218d3d12022-10-01 17:27:01 -040018/// <reference types="webpack/module" />
simond47ef9e2022-09-28 22:24:28 -040019'use strict';
20import './index.scss';
idillon5815c732022-09-16 13:54:45 -040021import './i18n';
Larbi Gharibe9af9732021-03-31 15:08:01 +010022
idillon8e6c0062022-09-16 13:34:43 -040023// import config from "../sentry-client.config.json"
idillon08f77172022-09-13 19:14:17 -040024import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
simon07b4eb02022-09-29 17:50:26 -040025import { StrictMode } from 'react';
simon218d3d12022-10-01 17:27:01 -040026import { render } from 'react-dom';
simon07b4eb02022-09-29 17:50:26 -040027import { createRoot } from 'react-dom/client';
28import { Provider } from 'react-redux';
29import { BrowserRouter as Router } from 'react-router-dom';
idillon322e4ac2022-09-14 12:48:43 -040030import socketio from 'socket.io-client';
simon07b4eb02022-09-29 17:50:26 -040031
32import { store } from '../redux/store';
simon218d3d12022-10-01 17:27:01 -040033import App from './App';
simon35378692022-10-02 23:25:57 -040034import { SocketProvider } from './contexts/Socket';
idillon08f77172022-09-13 19:14:17 -040035
36const queryClient = new QueryClient({
37 defaultOptions: {
38 queries: {
39 cacheTime: Infinity, // websocket is responsible to tell when data needs to be updated
40 },
41 },
simond47ef9e2022-09-28 22:24:28 -040042});
idillon5e897432022-09-16 13:28:09 -040043
simond47ef9e2022-09-28 22:24:28 -040044const socket = socketio();
idillon322e4ac2022-09-14 12:48:43 -040045
simond47ef9e2022-09-28 22:24:28 -040046const container = document.getElementById('root');
simon218d3d12022-10-01 17:27:01 -040047if (!container) {
48 throw new Error('Failed to get the root element');
49}
idillon169f64f2022-09-16 14:01:22 -040050const root = createRoot(container);
51root.render(
52 <Provider store={store}>
Adrien Béraud023f7cf2022-09-18 14:57:53 -040053 <StrictMode>
idillon08f77172022-09-13 19:14:17 -040054 <QueryClientProvider client={queryClient}>
idillon322e4ac2022-09-14 12:48:43 -040055 <SocketProvider socket={socket}>
56 <Router>
simond47ef9e2022-09-28 22:24:28 -040057 <App />
idillon322e4ac2022-09-14 12:48:43 -040058 </Router>
59 </SocketProvider>
idillon08f77172022-09-13 19:14:17 -040060 </QueryClientProvider>
Adrien Béraud023f7cf2022-09-18 14:57:53 -040061 </StrictMode>
idillon169f64f2022-09-16 14:01:22 -040062 </Provider>
63);
Adrien Béraude74741b2021-04-19 13:22:54 -040064
idillond858c182022-09-16 13:18:26 -040065if (import.meta.webpackHot)
simond47ef9e2022-09-28 22:24:28 -040066 import.meta.webpackHot.accept('./App', () => {
idillond858c182022-09-16 13:18:26 -040067 try {
simon218d3d12022-10-01 17:27:01 -040068 render(<App />, container);
idillond858c182022-09-16 13:18:26 -040069 } catch (e) {
70 location.reload();
71 }
72 });