diff --git a/.changes/contest.md b/.changes/contest.md new file mode 100644 index 0000000..002d142 --- /dev/null +++ b/.changes/contest.md @@ -0,0 +1,5 @@ +--- +"algohub": patch:feat +--- + +Support create new contest. diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ddcbfcd..639758f 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -28,7 +28,7 @@ dependencies = [ [[package]] name = "algohub" -version = "0.1.1-alpha.11" +version = "0.1.1-alpha.12" dependencies = [ "reqwest", "serde", diff --git a/src/components/UniversalToolBar.vue b/src/components/UniversalToolBar.vue index 5d69376..29b1e13 100644 --- a/src/components/UniversalToolBar.vue +++ b/src/components/UniversalToolBar.vue @@ -75,6 +75,16 @@ const createMenuItems = ref([ command: () => { toast.add({ severity: 'info', summary: 'Coming soon...', detail: 'This feature is coming soon...' }) } + }, + { + separator: true + }, + { + label: 'New Contest', + icon: 'pi pi-calendar', + command: () => { + router.push("/contest/create"); + } } ]); const toggleCreateMenu = (event: any) => { diff --git a/src/scripts/api.ts b/src/scripts/api.ts index f7fba4d..12c657f 100644 --- a/src/scripts/api.ts +++ b/src/scripts/api.ts @@ -10,6 +10,7 @@ import type { CreateProblem, Submission, Contest, + CreateContest, } from "./types"; export interface Response { @@ -208,3 +209,12 @@ export const listAllContests = async (auth: Credentials) => { return handleAxiosError(AxiosError.from(error)); } }; + +export const createContest = async (data: CreateContest) => { + try { + const response = await axios.post("/contest/create", data); + return response.data as Response; + } catch (error) { + return handleAxiosError(AxiosError.from(error)); + } +}; diff --git a/src/scripts/types.ts b/src/scripts/types.ts index 70ec937..5b35477 100644 --- a/src/scripts/types.ts +++ b/src/scripts/types.ts @@ -140,3 +140,18 @@ export interface Contest { created_at: string; updated_at: string; } + +export interface ContestData { + name: string; + mode: Mode; + visibility: Visibility; + description: string; + start_time: string; + end_time: string; + owner: RecordId; +} + +export interface CreateContest { + auth: Credentials; + data: ContestData; +} diff --git a/src/views/contest/create.vue b/src/views/contest/create.vue index 02b333c..e403176 100644 --- a/src/views/contest/create.vue +++ b/src/views/contest/create.vue @@ -1,16 +1,15 @@ - - \ No newline at end of file diff --git a/src/views/dashboard.vue b/src/views/dashboard.vue index 9cc2c67..0bd4883 100644 --- a/src/views/dashboard.vue +++ b/src/views/dashboard.vue @@ -1,10 +1,10 @@ @@ -104,9 +110,37 @@ onMounted(async () => {
-
- - Coming soon... +
+
+ + + + + + +
+ No contests found. +
+
+
+ +