fix: missing problem redirects to homepage

This commit is contained in:
2022-11-24 19:38:25 +01:00
parent 702e40ad05
commit 438ddc8dd7
2 changed files with 16 additions and 7 deletions
+12 -5
View File
@@ -1,6 +1,7 @@
import { route } from 'preact-router'
import { useContext, useState } from 'preact/hooks'
import { isAdministrator, Problem as ProblemModel, Solution as SolutionModel } from '../../shared/model'
import { server } from '../api'
import { isAdministrator, Solution as SolutionModel } from '../../shared/model'
import { prependBaseUrl, server } from '../api'
import { Header } from '../components/Header'
import { MarkdownEditor } from '../components/MarkdownEditor'
import { Problem } from '../components/Problem'
@@ -20,9 +21,15 @@ export const ProblemPage = ({ id }: RouteProps) => {
const [source, setSource] = useState('')
const [{ content }] = useResource<{ content: string }>(`/api/problem/${id}`, {
content: '',
})
const [{ content }] = useResource<{ content?: string }>(
`/api/problem/${id}`,
{
content: '',
},
() => {
route(prependBaseUrl('/'))
}
)
const [solutions, refreshSolutions, setSolutionHeuristic] = useListResource<SolutionModel>(
`/api/solutions?problem=${id}`