|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import { route } from 'preact-router'
|
|
|
|
|
import { useContext, useState } from 'preact/hooks'
|
|
|
|
|
import { isAdministrator, Solution as SolutionModel } from '../../shared/model'
|
|
|
|
|
import { isAdministrator, Problem as ProblemModel, Solution as SolutionModel } from '../../shared/model'
|
|
|
|
|
import { prependBaseUrl, server } from '../api'
|
|
|
|
|
import { Header } from '../components/Header'
|
|
|
|
|
import { MarkdownEditor } from '../components/MarkdownEditor'
|
|
|
|
@ -21,15 +21,13 @@ export const ProblemPage = ({ id }: RouteProps) => {
|
|
|
|
|
|
|
|
|
|
const [source, setSource] = useState('')
|
|
|
|
|
|
|
|
|
|
const [{ content }] = useResource<{ content?: string }>(
|
|
|
|
|
`/api/problem/${id}`,
|
|
|
|
|
{
|
|
|
|
|
content: '',
|
|
|
|
|
},
|
|
|
|
|
() => {
|
|
|
|
|
const [problem] = useResource<ProblemModel | null>(`/api/problem/${id}`, null, problem => {
|
|
|
|
|
if (problem === null) {
|
|
|
|
|
route(prependBaseUrl('/'))
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const content = problem?.content ?? ''
|
|
|
|
|
|
|
|
|
|
const [solutions, refreshSolutions, setSolutionHeuristic] = useListResource<SolutionModel>(
|
|
|
|
|
`/api/solutions?problem=${id}`
|
|
|
|
|