Some checks are pending
E2E / Playwright e2e (push) Waiting to run
- Introduced turbopack alias for canvas in next.config.mjs. - Updated package.json scripts for development and branding tasks. - Added new dependencies for Tiptap extensions. - Implemented new demo layouts for agenda, contacts, drive, and mail applications. - Enhanced globals.css for improved theming and splash screen animations. - Added OAuth callback handling for drive mounts. - Updated layout components to integrate new demo shells and improve structure.
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { calendarColor } from "./agenda-events.ts"
|
|
import type { AgendaCalendar, AgendaEvent, AgendaEventDraft } from "./agenda-types.ts"
|
|
|
|
const PENDING_KEY = "__agenda_pending__"
|
|
|
|
/** Convertit un brouillon ouvert en événement fantôme affiché sur la grille. */
|
|
export function draftToPendingEvent(
|
|
draft: AgendaEventDraft,
|
|
calendars: AgendaCalendar[],
|
|
): AgendaEvent {
|
|
const cal = calendars.find((c) => c.id === draft.calendarId) ?? calendars[0]
|
|
const color = draft.color ?? (cal ? calendarColor(cal) : "#039be5")
|
|
const title = draft.title.trim() || "(Sans titre)"
|
|
return {
|
|
key: PENDING_KEY,
|
|
calendarId: draft.calendarId,
|
|
path: "",
|
|
etag: "",
|
|
uid: PENDING_KEY,
|
|
title,
|
|
description: draft.description ?? "",
|
|
location: draft.location ?? "",
|
|
meetUrl: "",
|
|
organizer: "",
|
|
attendees: draft.attendees ?? [],
|
|
start: draft.start,
|
|
end: draft.end,
|
|
allDay: draft.allDay,
|
|
color,
|
|
rrule: draft.rrule ?? "",
|
|
recurring: false,
|
|
master: {
|
|
uid: PENDING_KEY,
|
|
summary: title,
|
|
description: draft.description ?? "",
|
|
location: draft.location ?? "",
|
|
start: "",
|
|
end: "",
|
|
all_day: draft.allDay,
|
|
color: draft.color,
|
|
},
|
|
}
|
|
}
|
|
|
|
export function isPendingEvent(event: AgendaEvent): boolean {
|
|
return event.key === PENDING_KEY
|
|
}
|