import { get, post, put, del } from './request'

export interface DispatchSchedule {
  scheduleId?: number
  teamId?: number
  teamName?: string
  workDate?: string
  shiftType?: 'month_plan' | 'emergency' | string
  vehicleIds?: string
  staffIds?: string
  status?: string
  remark?: string
}

export function getScheduleList(year?: number, month?: number) {
  return get('/schedule/list', { year, month })
}

export function getSchedulesByDate(workDate: string) {
  return get<DispatchSchedule[]>(`/schedule/date/${workDate}`)
}

export function getScheduleDetail(scheduleId: number) {
  return get(`/schedule/${scheduleId}`)
}

export function createSchedule(data: DispatchSchedule) {
  return post<number>('/schedule', data)
}

export function updateSchedule(scheduleId: number, data: DispatchSchedule) {
  return put('/schedule', { scheduleId, ...data })
}

export function deleteSchedule(scheduleId: number) {
  return del(`/schedule/${scheduleId}`)
}
