You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
910 B
TypeScript
35 lines
910 B
TypeScript
2 years ago
|
import Router from 'preact-router'
|
||
2 years ago
|
import { route } from 'preact-router'
|
||
|
import { useEffect } from 'preact/hooks'
|
||
2 years ago
|
import { AdminPage } from './pages/Admin'
|
||
2 years ago
|
|
||
2 years ago
|
import { HomePage } from './pages/Home'
|
||
|
import { LoginPage } from './pages/Login'
|
||
|
import { ProblemPage } from './pages/Problem'
|
||
|
import { ProfilePage } from './pages/Profile'
|
||
2 years ago
|
|
||
2 years ago
|
const Redirect = ({ to }: { default: boolean; to: string }) => {
|
||
2 years ago
|
useEffect(() => {
|
||
|
route(to, true)
|
||
|
}, [])
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
Redirecting to <pre>{to}</pre>...
|
||
|
</>
|
||
|
)
|
||
|
}
|
||
|
|
||
2 years ago
|
export const App = ({ url }: { url?: string }) => {
|
||
2 years ago
|
return (
|
||
|
<Router url={url}>
|
||
|
<HomePage path="/" />
|
||
|
<LoginPage path="/login" />
|
||
2 years ago
|
<ProfilePage path="/profile" />
|
||
2 years ago
|
<ProblemPage path="/problem/:id" />
|
||
2 years ago
|
<AdminPage path="/admin" />
|
||
2 years ago
|
<Redirect default to="/" />
|
||
|
</Router>
|
||
|
)
|
||
|
}
|