blob: 7902c9b367805db33d2da93847f007345f2043ed [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 */
simond47ef9e2022-09-28 22:24:28 -040018'use strict';
19import './index.scss';
idillon5815c732022-09-16 13:54:45 -040020import './i18n';
Larbi Gharibe9af9732021-03-31 15:08:01 +010021
Michelle Sepkap Sime51c00452022-10-31 21:26:38 -040022import { ThemeProvider } from '@mui/material/styles';
idillon08f77172022-09-13 19:14:17 -040023import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
simon07b4eb02022-09-29 17:50:26 -040024import { StrictMode } from 'react';
25import { createRoot } from 'react-dom/client';
26import { Provider } from 'react-redux';
simon3f5f3e72022-11-08 21:01:57 -050027import { RouterProvider } from 'react-router-dom';
idillon322e4ac2022-09-14 12:48:43 -040028import socketio from 'socket.io-client';
simon07b4eb02022-09-29 17:50:26 -040029
simon35378692022-10-02 23:25:57 -040030import { SocketProvider } from './contexts/Socket';
simond8ca2f22022-10-11 23:30:55 -040031import { store } from './redux/store';
simon3f5f3e72022-11-08 21:01:57 -050032import { router } from './router';
Michelle Sepkap Sime51c00452022-10-31 21:26:38 -040033import defaultTheme from './themes/Default';
idillon08f77172022-09-13 19:14:17 -040034
35const queryClient = new QueryClient({
36 defaultOptions: {
37 queries: {
38 cacheTime: Infinity, // websocket is responsible to tell when data needs to be updated
39 },
40 },
simond47ef9e2022-09-28 22:24:28 -040041});
idillon5e897432022-09-16 13:28:09 -040042
simond47ef9e2022-09-28 22:24:28 -040043const socket = socketio();
idillon322e4ac2022-09-14 12:48:43 -040044
simond47ef9e2022-09-28 22:24:28 -040045const container = document.getElementById('root');
simon218d3d12022-10-01 17:27:01 -040046if (!container) {
47 throw new Error('Failed to get the root element');
48}
idillon169f64f2022-09-16 14:01:22 -040049const root = createRoot(container);
50root.render(
51 <Provider store={store}>
Adrien Béraud023f7cf2022-09-18 14:57:53 -040052 <StrictMode>
idillon08f77172022-09-13 19:14:17 -040053 <QueryClientProvider client={queryClient}>
idillon322e4ac2022-09-14 12:48:43 -040054 <SocketProvider socket={socket}>
Michelle Sepkap Sime51c00452022-10-31 21:26:38 -040055 <ThemeProvider theme={defaultTheme}>
56 <RouterProvider router={router} />
57 </ThemeProvider>
idillon322e4ac2022-09-14 12:48:43 -040058 </SocketProvider>
idillon08f77172022-09-13 19:14:17 -040059 </QueryClientProvider>
Adrien Béraud023f7cf2022-09-18 14:57:53 -040060 </StrictMode>
idillon169f64f2022-09-16 14:01:22 -040061 </Provider>
62);