export type PublicHolidaysResponse =
  | { days?: Record<string, string> }
  | Record<string, string>

export const listPublicHolidays = async (zone: string, year: number) => {
  const api = useApi()
  const data = await api.get<PublicHolidaysResponse>(
    `/public-holidays/${zone}/${year}`,
    {},
    { toast: false }
  )

  if (data && typeof data === 'object' && 'days' in data) {
    return (data.days ?? {}) as Record<string, string>
  }

  return (data ?? {}) as Record<string, string>
}
