import client from './client' import type { ActiveEvent, MarathonEvent, EventCreate, DroppedAssignment, SwapCandidate, SwapRequestItem, MySwapRequests, CommonEnemyLeaderboardEntry } from '@/types' export const eventsApi = { getActive: async (marathonId: number): Promise => { const response = await client.get(`/marathons/${marathonId}/event`) return response.data }, list: async (marathonId: number): Promise => { const response = await client.get(`/marathons/${marathonId}/events`) return response.data }, start: async (marathonId: number, data: EventCreate): Promise => { const response = await client.post(`/marathons/${marathonId}/events`, data) return response.data }, stop: async (marathonId: number): Promise => { await client.delete(`/marathons/${marathonId}/event`) }, // Swap requests (two-sided confirmation) createSwapRequest: async (marathonId: number, targetParticipantId: number): Promise => { const response = await client.post(`/marathons/${marathonId}/swap-requests`, { target_participant_id: targetParticipantId, }) return response.data }, getSwapRequests: async (marathonId: number): Promise => { const response = await client.get(`/marathons/${marathonId}/swap-requests`) return response.data }, acceptSwapRequest: async (marathonId: number, requestId: number): Promise => { await client.post(`/marathons/${marathonId}/swap-requests/${requestId}/accept`) }, declineSwapRequest: async (marathonId: number, requestId: number): Promise => { await client.post(`/marathons/${marathonId}/swap-requests/${requestId}/decline`) }, cancelSwapRequest: async (marathonId: number, requestId: number): Promise => { await client.delete(`/marathons/${marathonId}/swap-requests/${requestId}`) }, rematch: async (marathonId: number, assignmentId: number): Promise => { await client.post(`/marathons/${marathonId}/rematch/${assignmentId}`) }, getDroppedAssignments: async (marathonId: number): Promise => { const response = await client.get(`/marathons/${marathonId}/dropped-assignments`) return response.data }, getSwapCandidates: async (marathonId: number): Promise => { const response = await client.get(`/marathons/${marathonId}/swap-candidates`) return response.data }, getCommonEnemyLeaderboard: async (marathonId: number): Promise => { const response = await client.get(`/marathons/${marathonId}/common-enemy-leaderboard`) return response.data }, }