import type { Season } from '../types'; export async function fetchSeasons(): Promise { try { const res = await fetch('/api/seasons'); if (!res.ok) return []; return res.json(); } catch { console.warn('Failed to load seasons, using empty list'); return []; } } export async function createSeason(season: Omit): Promise { const res = await fetch('/api/seasons', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(season), }); if (!res.ok) throw new Error('Failed to create season'); return res.json(); } export async function updateSeason(id: number, season: Partial): Promise { const res = await fetch(`/api/seasons/${id}`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(season), }); if (!res.ok) throw new Error('Failed to update season'); return res.json(); } export async function deleteSeason(id: number): Promise { const res = await fetch(`/api/seasons/${id}`, { method: 'DELETE' }); if (!res.ok) throw new Error('Failed to delete season'); }