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