2022-06-10 23:32:53 +02:00
|
|
|
import { Route, BrowserRouter, Routes, useLocation } from 'react-router-dom';
|
2022-01-23 23:23:09 +01:00
|
|
|
import Home from './pages/Home';
|
2022-01-22 20:41:25 +01:00
|
|
|
import './App.css';
|
2022-01-23 23:23:09 +01:00
|
|
|
import '@revoltchat/ui/src/styles/dark.css';
|
|
|
|
import '@revoltchat/ui/src/styles/common.css';
|
|
|
|
import RequireAuth from './components/RequireAuth';
|
2022-01-24 19:01:18 +01:00
|
|
|
import DashboardHome from './pages/DashboardHome';
|
2022-03-16 20:34:24 +01:00
|
|
|
import ServerDashboard from './pages/ServerDashboard/ServerDashboard';
|
2022-06-10 23:32:53 +02:00
|
|
|
import localforage from 'localforage';
|
2022-01-23 23:23:09 +01:00
|
|
|
|
2022-02-05 20:17:00 +01:00
|
|
|
const API_URL = import.meta.env.VITE_API_URL?.toString()
|
|
|
|
|| 'http://localhost:9000';
|
|
|
|
|
|
|
|
const BOT_PREFIX = import.meta.env.VITE_BOT_PREFIX?.toString()
|
|
|
|
|| '/';
|
2022-01-22 20:41:25 +01:00
|
|
|
|
|
|
|
function App() {
|
2022-06-10 23:32:53 +02:00
|
|
|
const authConfig = new URLSearchParams(window.location.search).get('setAuth');
|
|
|
|
|
|
|
|
if (authConfig) {
|
|
|
|
console.log('Using provided auth data');
|
|
|
|
|
|
|
|
const [ user, token ] = authConfig.split(':');
|
|
|
|
localforage.setItem('auth', {
|
|
|
|
user: decodeURIComponent(user),
|
|
|
|
token: decodeURIComponent(token),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-01-22 20:41:25 +01:00
|
|
|
return (
|
|
|
|
<BrowserRouter>
|
|
|
|
<Routes>
|
2022-01-23 23:23:09 +01:00
|
|
|
<Route path='/' element={<Home />} />
|
2022-01-24 19:01:18 +01:00
|
|
|
<Route path='/dashboard' element={<RequireAuth><DashboardHome /></RequireAuth>} />
|
|
|
|
<Route path='/dashboard/:serverid' element={<RequireAuth><ServerDashboard /></RequireAuth>} />
|
2022-01-22 20:41:25 +01:00
|
|
|
</Routes>
|
|
|
|
</BrowserRouter>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-23 23:23:09 +01:00
|
|
|
export default App;
|
2022-02-05 20:17:00 +01:00
|
|
|
export { API_URL, BOT_PREFIX }
|