Initialize GovOPlaN calendar module

This commit is contained in:
2026-07-07 02:49:44 +02:00
commit 3bcb04ff76
36 changed files with 3410 additions and 0 deletions

92
webui/src/api/calendar.ts Normal file
View File

@@ -0,0 +1,92 @@
import { apiFetch, type ApiSettings } from "@govoplan/core-webui";
export type CalendarCollection = {
id: string;
tenant_id: string;
slug: string;
name: string;
description?: string | null;
timezone: string;
color?: string | null;
owner_type: string;
owner_id?: string | null;
visibility: string;
is_default: boolean;
created_at: string;
updated_at: string;
metadata?: Record<string, unknown> | null;
};
export type CalendarEvent = {
id: string;
tenant_id: string;
calendar_id: string;
uid: string;
recurrence_id?: string | null;
sequence: number;
summary: string;
description?: string | null;
location?: string | null;
status: string;
transparency: string;
classification: string;
start_at: string;
end_at?: string | null;
duration_seconds?: number | null;
all_day: boolean;
timezone?: string | null;
organizer?: Record<string, unknown> | null;
attendees: Record<string, unknown>[];
categories: string[];
rrule?: Record<string, unknown> | null;
rdate: Record<string, unknown>[];
exdate: Record<string, unknown>[];
reminders: Record<string, unknown>[];
attachments: Record<string, unknown>[];
related_to: Record<string, unknown>[];
source_kind: string;
source_href?: string | null;
etag?: string | null;
icalendar: Record<string, unknown>;
created_at: string;
updated_at: string;
metadata?: Record<string, unknown> | null;
};
export type CalendarCollectionListResponse = { calendars: CalendarCollection[] };
export type CalendarEventListResponse = { events: CalendarEvent[] };
export type CalendarEventCreatePayload = {
calendar_id?: string | null;
summary: string;
description?: string | null;
location?: string | null;
start_at: string;
end_at?: string | null;
all_day?: boolean;
timezone?: string | null;
status?: string;
transparency?: string;
classification?: string;
categories?: string[];
};
export function listCalendars(settings: ApiSettings): Promise<CalendarCollectionListResponse> {
return apiFetch<CalendarCollectionListResponse>(settings, "/api/v1/calendar/calendars");
}
export function listCalendarEvents(
settings: ApiSettings,
params: { calendar_id?: string; start_at?: string; end_at?: string } = {}
): Promise<CalendarEventListResponse> {
const search = new URLSearchParams();
if (params.calendar_id) search.set("calendar_id", params.calendar_id);
if (params.start_at) search.set("start_at", params.start_at);
if (params.end_at) search.set("end_at", params.end_at);
const suffix = search.toString() ? `?${search.toString()}` : "";
return apiFetch<CalendarEventListResponse>(settings, `/api/v1/calendar/events${suffix}`);
}
export function createCalendarEvent(settings: ApiSettings, payload: CalendarEventCreatePayload): Promise<CalendarEvent> {
return apiFetch<CalendarEvent>(settings, "/api/v1/calendar/events", { method: "POST", body: JSON.stringify(payload) });
}