|
|
@ -1,6 +1,8 @@
|
|
|
|
import Router from 'preact-router'
|
|
|
|
import Router from 'preact-router'
|
|
|
|
import { route } 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 { AdminPage } from './pages/Admin'
|
|
|
|
|
|
|
|
|
|
|
|
import { HomePage } from './pages/Home'
|
|
|
|
import { HomePage } from './pages/Home'
|
|
|
@ -21,27 +23,30 @@ const Redirect = ({ to }: { to: string }) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const App = ({ url }: { url?: 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 (
|
|
|
|
return (
|
|
|
|
<Router url={url}>
|
|
|
|
<Router url={url}>
|
|
|
|
<HomePage
|
|
|
|
<HomePage
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
path="/"
|
|
|
|
path={pbu('/')}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<LoginPage
|
|
|
|
<LoginPage
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
path="/login"
|
|
|
|
path={pbu('/login')}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<ProfilePage
|
|
|
|
<ProfilePage
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
path="/profile"
|
|
|
|
path={pbu('/profile')}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<ProblemPage
|
|
|
|
<ProblemPage
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
path="/problem/:id"
|
|
|
|
path={pbu('/problem/:id')}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<AdminPage
|
|
|
|
<AdminPage
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
path="/admin"
|
|
|
|
path={pbu('/admin')}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<Redirect
|
|
|
|
<Redirect
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|