Add challenges preview + makefile

This commit is contained in:
2025-12-14 03:23:50 +07:00
parent 5343a8f2c3
commit bb9e9a6e1d
7 changed files with 590 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
import client from './client'
import type { Game, Challenge } from '@/types'
import type { Game, Challenge, ChallengePreview, ChallengesPreviewResponse } from '@/types'
export interface CreateGameData {
title: string
@@ -63,8 +63,13 @@ export const gamesApi = {
await client.delete(`/challenges/${id}`)
},
generateChallenges: async (marathonId: number): Promise<{ message: string }> => {
const response = await client.post<{ message: string }>(`/marathons/${marathonId}/generate-challenges`)
previewChallenges: async (marathonId: number): Promise<ChallengesPreviewResponse> => {
const response = await client.post<ChallengesPreviewResponse>(`/marathons/${marathonId}/preview-challenges`)
return response.data
},
saveChallenges: async (marathonId: number, challenges: ChallengePreview[]): Promise<{ message: string }> => {
const response = await client.post<{ message: string }>(`/marathons/${marathonId}/save-challenges`, { challenges })
return response.data
},
}