1 import axios from 'axios';
2 import React, { useEffect, useState } from 'react';
3 import { BrowserRouter, Route, Routes } from 'react-router-dom';
5 import Header from './Header';
6 import AosFront from '../pages/AosFront';
7 import AosSeed from '../pages/AosSeed';
8 import User from '../pages/User';
9 import AosBaseRomProvider from '../../helpers/AosBaseRomContext';
10 import UserContext from '../../helpers/UserContext';
13 const [user, setUser] = useState(null);
15 const checkAuth = async () => {
17 const response = await axios.get('/api/user');
18 setUser(response.data);
24 const doLogout = async () => {
25 await axios.post('/logout');
32 .get('/sanctum/csrf-cookie')
35 timer = setInterval(checkAuth, 15 * 60 * 1000);
38 if (timer) clearInterval(timer);
43 window.Echo.channel('App.Control')
44 .listen('PleaseRefresh', () => {
48 window.Echo.leave('App.Control');
52 return <BrowserRouter>
54 <UserContext.Provider value={user}>
55 <Header doLogout={doLogout} />
57 <Route path="h/:hash" element={<AosSeed />} />
58 <Route path="users/:id" element={<User />} />
59 <Route path="*" element={<AosFront />} />
61 </UserContext.Provider>