Ka-Note/ka-note/client/src/lib/utils/calendarApi.ts

17 lines
534 B
TypeScript

import { authFetch } from '$lib/auth/apiClient';
export interface CalendarEvent {
id: string;
subject: string;
start: string; // "HH:MM"
end: string; // "HH:MM"
body: string;
attendees: { name: string; email: string }[];
}
export async function fetchCalendarEvents(date: string): Promise<CalendarEvent[]> {
const res = await authFetch(`/api/calendar/events?date=${encodeURIComponent(date)}`);
if (!res.ok) throw new Error(`calendar fetch failed: ${res.status}`);
return res.json() as Promise<CalendarEvent[]>;
}