This commit is contained in:
Timothy Jaeryang Baek
2026-04-19 21:48:27 +09:00
parent 8d739e2aba
commit 4a5401b417
5 changed files with 73 additions and 14 deletions
+32 -1
View File
@@ -5,7 +5,7 @@ export type CalendarModel = {
user_id: string;
name: string;
color: string | null;
is_system: boolean;
is_default: boolean;
data: Record<string, any> | null;
meta: Record<string, any> | null;
access_grants: any[];
@@ -188,6 +188,37 @@ export const deleteCalendar = async (token: string, calendarId: string): Promise
return res?.status ?? false;
};
export const setDefaultCalendar = async (
token: string,
calendarId: string
): Promise<CalendarModel> => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/calendars/${calendarId}/default`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
authorization: `Bearer ${token}`
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
error = err.detail;
console.error(err);
return null;
});
if (error) {
throw error;
}
return res;
};
// ── Events ─────────────────────────────────
export const getCalendarEvents = async (
+1 -1
View File
@@ -128,7 +128,7 @@
showEventModal = true;
}
$: defaultCalendarId = calendars.find((c) => !c.is_system || c.name === 'Personal')?.id || calendars[0]?.id || '';
$: defaultCalendarId = calendars.find((c) => c.is_default)?.id || calendars[0]?.id || '';
onMount(async () => {
await loadCalendars();