1 import axios from 'axios';
2 import React, { useEffect, useState } from 'react';
3 import { Helmet } from 'react-helmet';
4 import { useTranslation } from 'react-i18next';
5 import { BrowserRouter } from 'react-router-dom';
7 import Routes from './Routes';
8 import AlttpBaseRomProvider from '../helpers/AlttpBaseRomContext';
9 import UserContext from '../helpers/UserContext';
10 import i18n from '../i18n';
13 const [user, setUser] = useState(null);
15 const { t } = useTranslation();
17 const checkAuth = async () => {
19 const response = await axios.get('/api/user');
20 setUser(response.data);
26 const doLogout = async () => {
27 await axios.post('/logout');
34 .get('/sanctum/csrf-cookie')
37 timer = setInterval(checkAuth, 15 * 60 * 1000);
40 if (timer) clearInterval(timer);
45 window.Echo.channel('App.Control')
46 .listen('PleaseRefresh', () => {
50 window.Echo.leave('App.Control');
54 return <BrowserRouter>
55 <AlttpBaseRomProvider>
56 <UserContext.Provider value={user}>
58 <html lang={i18n.language} />
59 <title>{t('general.appName')}</title>
60 <meta name="description" content={t('general.appDescription')} />
62 <Routes doLogout={doLogout} />
63 </UserContext.Provider>
64 </AlttpBaseRomProvider>