1 import axios from 'axios';
2 import React, { useEffect, useState } from 'react';
3 import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
5 import Footer from './common/Footer';
6 import Header from './common/Header';
7 import AlttpSeed from './pages/AlttpSeed';
8 import Front from './pages/Front';
9 import Technique from './pages/Technique';
10 import Techniques from './pages/Techniques';
11 import Tournament from './pages/Tournament';
12 import User from './pages/User';
13 import AlttpBaseRomProvider from '../helpers/AlttpBaseRomContext';
14 import UserContext from '../helpers/UserContext';
17 const [user, setUser] = useState(null);
19 const checkAuth = async () => {
21 const response = await axios.get('/api/user');
22 setUser(response.data);
28 const doLogout = async () => {
29 await axios.post('/logout');
36 .get('/sanctum/csrf-cookie')
39 timer = setInterval(checkAuth, 15 * 60 * 1000);
42 if (timer) clearInterval(timer);
47 window.Echo.channel('App.Control')
48 .listen('PleaseRefresh', () => {
52 window.Echo.leave('App.Control');
56 return <BrowserRouter>
57 <AlttpBaseRomProvider>
58 <UserContext.Provider value={user}>
59 <Header doLogout={doLogout} />
61 <Route path="h/:hash" element={<AlttpSeed />} />
62 <Route path="tech" element={<Techniques />} />
63 <Route path="tech/:name" element={<Technique />} />
64 <Route path="tournaments/:id" element={<Tournament />} />
65 <Route path="users/:id" element={<User />} />
66 <Route path="/" element={<Front />} />
67 <Route path="*" element={<Navigate to="/" />} />
70 </UserContext.Provider>
71 </AlttpBaseRomProvider>