|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
import Router from 'preact-router'
|
|
|
|
|
import { route } from 'preact-router'
|
|
|
|
|
import { useEffect } from 'preact/hooks'
|
|
|
|
|
import { useContext, useEffect } from 'preact/hooks'
|
|
|
|
|
import { prependBaseUrl } from './api'
|
|
|
|
|
import { ServerContext } from './hooks'
|
|
|
|
|
import { AdminPage } from './pages/Admin'
|
|
|
|
|
|
|
|
|
|
import { HomePage } from './pages/Home'
|
|
|
|
@ -21,27 +23,30 @@ const Redirect = ({ to }: { to: string }) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const App = ({ url }: { url?: string }) => {
|
|
|
|
|
// during server side rendering don't prepend the BASE_URL
|
|
|
|
|
const pbu = useContext(ServerContext) ? (s: string) => s : prependBaseUrl
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Router url={url}>
|
|
|
|
|
<HomePage
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
path="/"
|
|
|
|
|
path={pbu('/')}
|
|
|
|
|
/>
|
|
|
|
|
<LoginPage
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
path="/login"
|
|
|
|
|
path={pbu('/login')}
|
|
|
|
|
/>
|
|
|
|
|
<ProfilePage
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
path="/profile"
|
|
|
|
|
path={pbu('/profile')}
|
|
|
|
|
/>
|
|
|
|
|
<ProblemPage
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
path="/problem/:id"
|
|
|
|
|
path={pbu('/problem/:id')}
|
|
|
|
|
/>
|
|
|
|
|
<AdminPage
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
path="/admin"
|
|
|
|
|
path={pbu('/admin')}
|
|
|
|
|
/>
|
|
|
|
|
<Redirect
|
|
|
|
|
// @ts-ignore
|
|
|
|
|