initial
This commit is contained in:
41
frontend/src/api/wheel.ts
Normal file
41
frontend/src/api/wheel.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import client from './client'
|
||||
import type { SpinResult, Assignment, CompleteResult, DropResult } from '@/types'
|
||||
|
||||
export const wheelApi = {
|
||||
spin: async (marathonId: number): Promise<SpinResult> => {
|
||||
const response = await client.post<SpinResult>(`/marathons/${marathonId}/spin`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
getCurrentAssignment: async (marathonId: number): Promise<Assignment | null> => {
|
||||
const response = await client.get<Assignment | null>(`/marathons/${marathonId}/current-assignment`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
complete: async (
|
||||
assignmentId: number,
|
||||
data: { proof_url?: string; comment?: string; proof_file?: File }
|
||||
): Promise<CompleteResult> => {
|
||||
const formData = new FormData()
|
||||
if (data.proof_url) formData.append('proof_url', data.proof_url)
|
||||
if (data.comment) formData.append('comment', data.comment)
|
||||
if (data.proof_file) formData.append('proof_file', data.proof_file)
|
||||
|
||||
const response = await client.post<CompleteResult>(`/assignments/${assignmentId}/complete`, formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
return response.data
|
||||
},
|
||||
|
||||
drop: async (assignmentId: number): Promise<DropResult> => {
|
||||
const response = await client.post<DropResult>(`/assignments/${assignmentId}/drop`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
getHistory: async (marathonId: number, limit = 20, offset = 0): Promise<Assignment[]> => {
|
||||
const response = await client.get<Assignment[]>(`/marathons/${marathonId}/my-history`, {
|
||||
params: { limit, offset },
|
||||
})
|
||||
return response.data
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user