diff --git a/src/admin/api.ts b/src/admin/api.ts index a667840..c1a4833 100644 --- a/src/admin/api.ts +++ b/src/admin/api.ts @@ -1,9 +1,15 @@ import http from "utils/http" import { Problem, User } from "~/utils/types" -export async function getProblemList(offset = 0, limit = 10, keyword: string) { - const res = await http.get("admin/problem", { - params: { paging: true, offset, limit, keyword }, +export async function getProblemList( + offset = 0, + limit = 10, + keyword: string, + contestID?: string +) { + const endpoint = !!contestID ? "admin/contest/problem" : "admin/problem" + const res = await http.get(endpoint, { + params: { paging: true, offset, limit, keyword, contest_id: contestID }, }) return { results: res.data.results.map((result: Problem) => ({ @@ -22,14 +28,26 @@ export function deleteProblem(id: number) { return http.delete("admin/problem", { params: { id } }) } +export function deleteContestProblem(id: number) { + return http.delete("admin/contest/problem", { params: { id } }) +} + export function editProblem(problem: Problem) { return http.put("admin/problem", problem) } +export function editContestProblem(problem: Problem) { + return http.put("admin/contest/problem", problem) +} + export function getProblem(id: number) { return http.get("admin/problem", { params: { id } }) } +export function getContestProblem(id: number) { + return http.get("admin/contest/problem", { params: { id } }) +} + export function getUserList(offset = 0, limit = 10, keyword: string) { return http.get("admin/user", { params: { paging: true, offset, limit, keyword }, diff --git a/src/admin/contest/components/Actions.vue b/src/admin/contest/components/Actions.vue index 3020fd4..48022dc 100644 --- a/src/admin/contest/components/Actions.vue +++ b/src/admin/contest/components/Actions.vue @@ -16,7 +16,7 @@ function goEdit() { function goEditProblems() { router.push({ - name: "admin contest problems", + name: "admin contest problem list", params: { contestID: props.contest.id }, }) } diff --git a/src/admin/contest/problems.vue b/src/admin/contest/problems.vue deleted file mode 100644 index b2d548a..0000000 --- a/src/admin/contest/problems.vue +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/src/admin/problem/components/Actions.vue b/src/admin/problem/components/Actions.vue index 1e6fbc6..6006b46 100644 --- a/src/admin/problem/components/Actions.vue +++ b/src/admin/problem/components/Actions.vue @@ -1,5 +1,5 @@