import { get, post } from './request'
import type { DispatchSchedule } from './schedule'

export interface DailyCheckItem {
  id: string
  category: string
  name: string
  required: boolean
  checked: boolean
}

export interface DailyCheckRecord {
  checkId?: number
  checkDate: string
  vehicleId?: number
  vehicleNo?: string
  userId: number
  userName?: string
  checkStatus?: string
  checkItems: DailyCheckItem[] | string
  photoUrls?: string[] | string
  videoUrls?: string[] | string
  remark?: string
  createTime?: string
}

export interface DailyCheckScheduleToday {
  schedule: DispatchSchedule | null
  vehicles: {
    vehicleId?: number
    plateNo?: string
    vehicleType?: string
    status?: string
    driverName?: string
    driverPhone?: string
  }[]
}

export function getTodaySchedule(userId: number) {
  return get<DailyCheckScheduleToday>('/daily-check/schedule-today', { userId })
}

export function getTodayCheckRecord(userId: number) {
  return get<DailyCheckRecord | null>('/daily-check/today', { userId })
}

export function submitDailyCheck(data: DailyCheckRecord) {
  return post<void>('/daily-check/submit', data)
}
