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 './common/Header';
6 import Front from './pages/Front';
7 import UserContext from '../helpers/UserContext';
10 const [user, setUser] = useState(null);
12 const checkAuth = async () => {
14 const response = await axios.get('/api/user');
15 setUser(response.data);
21 const doLogout = async () => {
22 await axios.post('/logout');
29 .get('/sanctum/csrf-cookie')
32 timer = setInterval(checkAuth, 15 * 60 * 1000);
35 if (timer) clearInterval(timer);
39 return <BrowserRouter>
40 <UserContext.Provider value={user}>
41 <Header doLogout={doLogout} />
44 <Route path="*" element={<Front />} />
47 </UserContext.Provider>