Add 3 roles, settings for marathons
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import client from './client'
|
||||
import type { Game, Challenge, ChallengePreview, ChallengesPreviewResponse } from '@/types'
|
||||
import type { Game, GameStatus, Challenge, ChallengePreview, ChallengesPreviewResponse } from '@/types'
|
||||
|
||||
export interface CreateGameData {
|
||||
title: string
|
||||
@@ -20,8 +20,14 @@ export interface CreateChallengeData {
|
||||
}
|
||||
|
||||
export const gamesApi = {
|
||||
list: async (marathonId: number): Promise<Game[]> => {
|
||||
const response = await client.get<Game[]>(`/marathons/${marathonId}/games`)
|
||||
list: async (marathonId: number, status?: GameStatus): Promise<Game[]> => {
|
||||
const params = status ? { status } : {}
|
||||
const response = await client.get<Game[]>(`/marathons/${marathonId}/games`, { params })
|
||||
return response.data
|
||||
},
|
||||
|
||||
listPending: async (marathonId: number): Promise<Game[]> => {
|
||||
const response = await client.get<Game[]>(`/marathons/${marathonId}/games/pending`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
@@ -39,6 +45,16 @@ export const gamesApi = {
|
||||
await client.delete(`/games/${id}`)
|
||||
},
|
||||
|
||||
approve: async (id: number): Promise<Game> => {
|
||||
const response = await client.post<Game>(`/games/${id}/approve`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
reject: async (id: number): Promise<Game> => {
|
||||
const response = await client.post<Game>(`/games/${id}/reject`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
uploadCover: async (id: number, file: File): Promise<Game> => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
||||
Reference in New Issue
Block a user