20 lines
704 B
TypeScript
20 lines
704 B
TypeScript
import apiClient from './client';
|
|
import { CalendarEvent } from '../types/calendar';
|
|
|
|
export const getCalendarEvents = async (start?: Date, end?: Date): Promise<CalendarEvent[]> => {
|
|
try {
|
|
const params: Record<string, string> = {};
|
|
if (start instanceof Date) {
|
|
params.start = start.toISOString();
|
|
}
|
|
if (end instanceof Date) {
|
|
params.end = end.toISOString();
|
|
}
|
|
const response = await apiClient.get('/calendar/events', { params });
|
|
console.log("[CAM] Got calendar:", response);
|
|
return response.data;
|
|
} catch (error) {
|
|
console.error("Error fetching calendar events", error);
|
|
throw error;
|
|
}
|
|
} |