import { apiClient } from './client'
import type {
  MaintenanceSchedule,
  MaintenanceScheduleCreate,
  MaintenanceScheduleUpdate,
  BatchLaunchRequest,
  BatchLaunchResponse,
} from '@/types'

export const maintenanceSchedulesApi = {
  getForTree: (treeId: string): Promise<MaintenanceSchedule> =>
    apiClient.get(`/maintenance-schedules/tree/${treeId}`).then(r => r.data),

  create: (data: MaintenanceScheduleCreate): Promise<MaintenanceSchedule> =>
    apiClient.post('/maintenance-schedules', data).then(r => r.data),

  update: (id: string, data: MaintenanceScheduleUpdate): Promise<MaintenanceSchedule> =>
    apiClient.patch(`/maintenance-schedules/${id}`, data).then(r => r.data),
}

export const batchLaunchApi = {
  launch: (data: BatchLaunchRequest): Promise<BatchLaunchResponse> =>
    apiClient.post('/sessions/batch', data).then(r => r.data),
}
