import type { AxiosResponse } from 'axios'
import type { Result } from '@cacp/ui'
import request from '@/utils/request'
import type { CacpHoliday } from '@/types/holiday'

const contextPath = '/holiday'

export async function getList(customsCode: string, year: number): Promise<Result<CacpHoliday[]>> {
  const res: AxiosResponse<Result<CacpHoliday[]>> = await request.get(`${contextPath}/get-list`, {
    params:{
        year,
        customsCode
    }
  })
  return res.data
}

export async function saveList(list: CacpHoliday[]): Promise<Result<number>> {
    const res: AxiosResponse<Result<number>> = await request.post(`${contextPath}/save-list`, list)
    return res.data
  }