import {Button, Layout, Space, theme, Typography} from "antd"; import {Link, Navigate, Route, Routes, useLocation, useNavigate} from "react-router-dom"; import TextPage from "./pages/TextPage"; import DomainSearchPage from "./pages/search/DomainSearchPage"; import EntitySearchPage from "./pages/search/EntitySearchPage"; import NameserverSearchPage from "./pages/search/NameserverSearchPage"; import TldPage from "./pages/search/TldPage"; import StatisticsPage from "./pages/StatisticsPage"; import WatchlistPage from "./pages/tracking/WatchlistPage"; import UserPage from "./pages/UserPage"; import React, {useCallback, useEffect, useMemo, useState} from "react"; import {getUser} from "./utils/api"; import LoginPage, {AuthenticatedContext} from "./pages/LoginPage"; import ConnectorsPage from "./pages/tracking/ConnectorsPage"; import NotFoundPage from "./pages/NotFoundPage"; import useBreakpoint from "./hooks/useBreakpoint"; import {Sider} from "./components/Sider"; import {jt, t} from "ttag"; const ProjectLink = Domain Watchdog const LicenseLink = AGPL-3.0-or-later export default function App() { const { token: {colorBgContainer, borderRadiusLG}, } = theme.useToken() const navigate = useNavigate() const location = useLocation() const sm = useBreakpoint('sm') const [isAuthenticated, setIsAuthenticated] = useState(false) const authenticated = useCallback((authenticated: boolean) => { setIsAuthenticated(authenticated) }, []); const contextValue = useMemo(() => ({ authenticated, setIsAuthenticated }), [authenticated, setIsAuthenticated]) useEffect(() => { getUser().then(() => { setIsAuthenticated(true) if (location.pathname === '/login') navigate('/home') }).catch(() => { setIsAuthenticated(false) const pathname = location.pathname if (!['/login', '/tos', '/faq', '/privacy'].includes(pathname)) navigate('/home') }) }, []); return {/* Ant will use a break-off tab to toggle the collapse of the sider when collapseWidth = 0*/}
}/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/>
{jt`${ProjectLink} is an open source project distributed under the ${LicenseLink} license.`}
}