/* * Copyright (C) 2024 Aleksander WilczyƄski (aleks@alekswilc.dev) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * See LICENSE for more. */ import { useEffect, useState } from "react"; import { Route, Routes, useLocation } from "react-router-dom"; import { Loader } from "./components/mini/loaders/PageLoader.tsx"; import { Home } from "./pages/Home"; import DefaultLayout from "./layout/DefaultLayout"; import "./i18n"; import { TrainLeaderboard } from "./pages/leaderboard/TrainLeaderboard.tsx"; import { StationLeaderboard } from "./pages/leaderboard/StationsLeaderboard.tsx"; import { TrainLogs } from "./pages/logs/TrainLogs.tsx"; import { StationLogs } from "./pages/logs/StationLogs.tsx"; import { Profile } from "./pages/profile/Profile.tsx"; import { Log } from "./pages/log/Log.tsx"; import "react-toastify/dist/ReactToastify.css"; import { ToastContainer } from "react-toastify"; import useColorMode from "./hooks/useColorMode.tsx"; import { HelmetProvider } from "react-helmet-async"; import { PageMeta } from "./components/mini/util/PageMeta.tsx"; function App() { const [ loading, setLoading ] = useState(true); const { pathname } = useLocation(); const [ theme ] = useColorMode(); useEffect(() => { window.scrollTo(0, 0); }, [ pathname ]); useEffect(() => { setTimeout(() => setLoading(false), 400); }, []); return { loading ? ( ) : ( <> } /> } /> } /> } /> } /> {/* page meta is modified in component! */ } } /> {/* page title is modified after API response */ } } /> ) } ; } export default App;