Fix creating and deleting calendars

This fixes the creation and deletion of calendars to include a color and the proper chosen name.
This commit is contained in:
Bruno Bernardino
2025-09-06 19:17:48 +01:00
parent 24944de0f6
commit 49dbc724c8
8 changed files with 30 additions and 10 deletions

View File

@@ -4,7 +4,7 @@ import { FreshContextState } from '/lib/types.ts';
import { Calendar, CalendarEvent, CalendarEventModel, CalendarModel } from '/lib/models/calendar.ts';
import CalendarWrapper from '/islands/calendar/CalendarWrapper.tsx';
import { AppConfig } from '/lib/config.ts';
import { getDateRangeForCalendarView } from '/lib/utils/calendar.ts';
import { getColorAsHex, getDateRangeForCalendarView } from '/lib/utils/calendar.ts';
interface Data {
userCalendars: Calendar[];
@@ -42,7 +42,7 @@ export const handler: Handlers<Data, FreshContextState> = {
// Create default calendar if none exists
if (userCalendars.length === 0) {
await CalendarModel.create(userId, 'Calendar');
await CalendarModel.create(userId, 'Calendar', getColorAsHex('bg-red-700'));
userCalendars = await CalendarModel.list(userId);
}