@rapidmx/web-client 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/admin/domains/[uid].tsx +3 -2
- package/apps/shared/appearance/AppearanceForm.tsx +9 -1
- package/apps/shared/calendar/bookingPlugin.ts +100 -0
- package/apps/shared/calendar/calendarLiveUpdates.ts +27 -0
- package/apps/shared/components/admin/layout/AdminShell.tsx +37 -5
- package/apps/shared/components/admin/settings/MailboxCreateForm.tsx +3 -1
- package/apps/shared/components/admin/settings/PluginsManager.tsx +1545 -1491
- package/apps/shared/components/calendar/AppointmentQuickForm.tsx +327 -0
- package/apps/shared/components/calendar/DescriptionEditor.tsx +274 -0
- package/apps/shared/components/calendar/EventDescriptionView.tsx +70 -0
- package/apps/shared/components/calendar/EventDetails.tsx +401 -0
- package/apps/shared/components/calendar/EventEditor.tsx +640 -0
- package/apps/shared/components/calendar/EventExpandedForm.tsx +210 -0
- package/apps/shared/components/calendar/EventFormParts.tsx +622 -0
- package/apps/shared/components/calendar/EventModal.tsx +126 -862
- package/apps/shared/components/calendar/EventQuickForm.tsx +116 -0
- package/apps/shared/components/calendar/EventShell.tsx +202 -0
- package/apps/shared/components/calendar/FindATime.tsx +379 -0
- package/apps/shared/components/calendar/LazyDescriptionEditor.tsx +70 -0
- package/apps/shared/components/calendar/MonthView.tsx +15 -3
- package/apps/shared/components/calendar/QuickCreateFaces.tsx +87 -0
- package/apps/shared/components/calendar/QuickCreateTabs.tsx +81 -0
- package/apps/shared/components/calendar/QuickFaceFrame.tsx +81 -0
- package/apps/shared/components/calendar/RecurrenceEditor.tsx +10 -5
- package/apps/shared/components/calendar/RequestChangeForm.tsx +271 -0
- package/apps/shared/components/calendar/SplitDayView.tsx +6 -5
- package/apps/shared/components/calendar/TaskQuickForm.tsx +289 -0
- package/apps/shared/components/calendar/TimeGridView.tsx +8 -6
- package/apps/shared/components/calendar/eventDialogFields.ts +86 -0
- package/apps/shared/components/calendar/eventForm.ts +108 -0
- package/apps/shared/components/calendar/eventFormat.ts +183 -0
- package/apps/shared/components/calendar/findTimeGrid.ts +90 -0
- package/apps/shared/components/calendar/swipeNavigation.ts +14 -0
- package/apps/shared/components/layout/UserMenu.tsx +80 -28
- package/apps/shared/components/mail/ConversationList.tsx +100 -48
- package/apps/shared/components/mail/ConversationThreadPane.tsx +490 -486
- package/apps/shared/components/mail/InviteCard.tsx +387 -0
- package/apps/shared/components/mail/MessageDetailPane.tsx +24 -2
- package/apps/shared/components/mail/SwipeRow.tsx +120 -0
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +7 -3
- package/apps/shared/components/mail/invite/InviteRowChip.tsx +104 -0
- package/apps/shared/components/mail/invite/InviteRsvpPopover.tsx +271 -0
- package/apps/shared/components/mail/invite/InviteTimeline.tsx +200 -0
- package/apps/shared/components/mail/invite/ProposeTimeForm.tsx +109 -0
- package/apps/shared/components/mail/invite/inviteFormat.ts +110 -0
- package/apps/shared/components/mail/invite/inviteStore.ts +114 -0
- package/apps/shared/components/mail/layout/MailShell.tsx +522 -490
- package/apps/shared/components/settings/layout/SettingsShell.tsx +1 -0
- package/apps/shared/gestures/useEnterSlide.ts +54 -0
- package/apps/shared/gestures/useSwipe.ts +114 -0
- package/apps/shared/gestures/useSwipeSlide.ts +113 -0
- package/apps/shared/gestures/useWheelPaging.ts +107 -0
- package/apps/shared/mail/newMailNotifications.ts +171 -183
- package/apps/shared/mail/useNewMailNotifications.ts +178 -178
- package/apps/shared/notifications/preferences.ts +36 -0
- package/apps/shared/notifications/store.ts +560 -551
- package/apps/www/_routes.ts +1 -0
- package/apps/www/calendar/index.tsx +139 -37
- package/apps/www/index.tsx +273 -126
- package/apps/www/messages/[uid].tsx +31 -4
- package/apps/www/settings/profile/index.tsx +248 -0
- package/dist/apps/admin/domains/[uid].js +4 -2
- package/dist/apps/shared/appearance/AppearanceForm.js +9 -1
- package/dist/apps/shared/calendar/bookingPlugin.d.ts +50 -0
- package/dist/apps/shared/calendar/bookingPlugin.js +57 -0
- package/dist/apps/shared/calendar/calendarLiveUpdates.d.ts +11 -0
- package/dist/apps/shared/calendar/calendarLiveUpdates.js +23 -0
- package/dist/apps/shared/components/admin/layout/AdminShell.d.ts +1 -1
- package/dist/apps/shared/components/admin/layout/AdminShell.js +7 -3
- package/dist/apps/shared/components/admin/settings/MailboxCreateForm.js +3 -1
- package/dist/apps/shared/components/admin/settings/PluginsManager.js +40 -6
- package/dist/apps/shared/components/calendar/AppointmentQuickForm.d.ts +47 -0
- package/dist/apps/shared/components/calendar/AppointmentQuickForm.js +135 -0
- package/dist/apps/shared/components/calendar/DescriptionEditor.d.ts +26 -0
- package/dist/apps/shared/components/calendar/DescriptionEditor.js +192 -0
- package/dist/apps/shared/components/calendar/EventDescriptionView.d.ts +14 -0
- package/dist/apps/shared/components/calendar/EventDescriptionView.js +39 -0
- package/dist/apps/shared/components/calendar/EventDetails.d.ts +33 -0
- package/dist/apps/shared/components/calendar/EventDetails.js +137 -0
- package/dist/apps/shared/components/calendar/EventEditor.d.ts +59 -0
- package/dist/apps/shared/components/calendar/EventEditor.js +549 -0
- package/dist/apps/shared/components/calendar/EventExpandedForm.d.ts +14 -0
- package/dist/apps/shared/components/calendar/EventExpandedForm.js +44 -0
- package/dist/apps/shared/components/calendar/EventFormParts.d.ts +69 -0
- package/dist/apps/shared/components/calendar/EventFormParts.js +202 -0
- package/dist/apps/shared/components/calendar/EventModal.d.ts +26 -13
- package/dist/apps/shared/components/calendar/EventModal.js +57 -455
- package/dist/apps/shared/components/calendar/EventQuickForm.d.ts +18 -0
- package/dist/apps/shared/components/calendar/EventQuickForm.js +25 -0
- package/dist/apps/shared/components/calendar/EventShell.d.ts +64 -0
- package/dist/apps/shared/components/calendar/EventShell.js +134 -0
- package/dist/apps/shared/components/calendar/FindATime.d.ts +18 -0
- package/dist/apps/shared/components/calendar/FindATime.js +190 -0
- package/dist/apps/shared/components/calendar/LazyDescriptionEditor.d.ts +8 -0
- package/dist/apps/shared/components/calendar/LazyDescriptionEditor.js +44 -0
- package/dist/apps/shared/components/calendar/MonthView.d.ts +5 -1
- package/dist/apps/shared/components/calendar/MonthView.js +11 -5
- package/dist/apps/shared/components/calendar/QuickCreateFaces.d.ts +30 -0
- package/dist/apps/shared/components/calendar/QuickCreateFaces.js +44 -0
- package/dist/apps/shared/components/calendar/QuickCreateTabs.d.ts +24 -0
- package/dist/apps/shared/components/calendar/QuickCreateTabs.js +46 -0
- package/dist/apps/shared/components/calendar/QuickFaceFrame.d.ts +25 -0
- package/dist/apps/shared/components/calendar/QuickFaceFrame.js +19 -0
- package/dist/apps/shared/components/calendar/RecurrenceEditor.d.ts +4 -1
- package/dist/apps/shared/components/calendar/RecurrenceEditor.js +2 -2
- package/dist/apps/shared/components/calendar/RequestChangeForm.d.ts +36 -0
- package/dist/apps/shared/components/calendar/RequestChangeForm.js +138 -0
- package/dist/apps/shared/components/calendar/SplitDayView.d.ts +3 -2
- package/dist/apps/shared/components/calendar/SplitDayView.js +3 -2
- package/dist/apps/shared/components/calendar/TaskQuickForm.d.ts +40 -0
- package/dist/apps/shared/components/calendar/TaskQuickForm.js +101 -0
- package/dist/apps/shared/components/calendar/TimeGridView.d.ts +4 -2
- package/dist/apps/shared/components/calendar/TimeGridView.js +3 -2
- package/dist/apps/shared/components/calendar/eventDialogFields.d.ts +28 -0
- package/dist/apps/shared/components/calendar/eventDialogFields.js +59 -0
- package/dist/apps/shared/components/calendar/eventForm.d.ts +98 -0
- package/dist/apps/shared/components/calendar/eventForm.js +1 -0
- package/dist/apps/shared/components/calendar/eventFormat.d.ts +67 -0
- package/dist/apps/shared/components/calendar/eventFormat.js +163 -0
- package/dist/apps/shared/components/calendar/findTimeGrid.d.ts +30 -0
- package/dist/apps/shared/components/calendar/findTimeGrid.js +83 -0
- package/dist/apps/shared/components/calendar/swipeNavigation.d.ts +9 -0
- package/dist/apps/shared/components/calendar/swipeNavigation.js +8 -0
- package/dist/apps/shared/components/layout/UserMenu.d.ts +10 -8
- package/dist/apps/shared/components/layout/UserMenu.js +70 -23
- package/dist/apps/shared/components/mail/ConversationList.d.ts +12 -1
- package/dist/apps/shared/components/mail/ConversationList.js +21 -4
- package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +4 -1
- package/dist/apps/shared/components/mail/InviteCard.d.ts +20 -0
- package/dist/apps/shared/components/mail/InviteCard.js +150 -0
- package/dist/apps/shared/components/mail/MessageDetailPane.js +13 -2
- package/dist/apps/shared/components/mail/SwipeRow.d.ts +22 -0
- package/dist/apps/shared/components/mail/SwipeRow.js +71 -0
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +8 -3
- package/dist/apps/shared/components/mail/invite/InviteRowChip.d.ts +23 -0
- package/dist/apps/shared/components/mail/invite/InviteRowChip.js +46 -0
- package/dist/apps/shared/components/mail/invite/InviteRsvpPopover.d.ts +20 -0
- package/dist/apps/shared/components/mail/invite/InviteRsvpPopover.js +141 -0
- package/dist/apps/shared/components/mail/invite/InviteTimeline.d.ts +27 -0
- package/dist/apps/shared/components/mail/invite/InviteTimeline.js +120 -0
- package/dist/apps/shared/components/mail/invite/ProposeTimeForm.d.ts +17 -0
- package/dist/apps/shared/components/mail/invite/ProposeTimeForm.js +45 -0
- package/dist/apps/shared/components/mail/invite/inviteFormat.d.ts +28 -0
- package/dist/apps/shared/components/mail/invite/inviteFormat.js +94 -0
- package/dist/apps/shared/components/mail/invite/inviteStore.d.ts +28 -0
- package/dist/apps/shared/components/mail/invite/inviteStore.js +95 -0
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +5 -0
- package/dist/apps/shared/components/mail/layout/MailShell.js +14 -3
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +1 -0
- package/dist/apps/shared/gestures/useEnterSlide.d.ts +14 -0
- package/dist/apps/shared/gestures/useEnterSlide.js +47 -0
- package/dist/apps/shared/gestures/useSwipe.d.ts +45 -0
- package/dist/apps/shared/gestures/useSwipe.js +90 -0
- package/dist/apps/shared/gestures/useSwipeSlide.d.ts +40 -0
- package/dist/apps/shared/gestures/useSwipeSlide.js +95 -0
- package/dist/apps/shared/gestures/useWheelPaging.d.ts +32 -0
- package/dist/apps/shared/gestures/useWheelPaging.js +85 -0
- package/dist/apps/shared/mail/newMailNotifications.d.ts +3 -8
- package/dist/apps/shared/mail/newMailNotifications.js +3 -12
- package/dist/apps/shared/mail/useNewMailNotifications.js +3 -2
- package/dist/apps/shared/notifications/preferences.d.ts +13 -0
- package/dist/apps/shared/notifications/preferences.js +36 -0
- package/dist/apps/shared/notifications/store.d.ts +1 -0
- package/dist/apps/shared/notifications/store.js +7 -23
- package/dist/apps/www/_routes.js +1 -0
- package/dist/apps/www/calendar/index.js +76 -6
- package/dist/apps/www/index.js +140 -39
- package/dist/apps/www/messages/[uid].js +13 -5
- package/dist/apps/www/settings/profile/index.d.ts +4 -0
- package/dist/apps/www/settings/profile/index.js +124 -0
- package/package.json +3 -3
|
@@ -2,70 +2,19 @@
|
|
|
2
2
|
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
3
|
// SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
import React, {
|
|
6
|
-
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
-
import {
|
|
8
|
-
Attendee,
|
|
9
|
-
AttendeeResponseInput,
|
|
10
|
-
AttendeeResponseStatus,
|
|
11
|
-
AttendeeRole,
|
|
12
|
-
BusyStatus,
|
|
13
|
-
CalendarEvent,
|
|
14
|
-
CalendarEventInput,
|
|
15
|
-
RecurrenceRule,
|
|
16
|
-
createCalendarEvent,
|
|
17
|
-
getCalendarEvent,
|
|
18
|
-
respondToEvent,
|
|
19
|
-
updateCalendarEvent,
|
|
20
|
-
} from "@rapidmx/react-shared/calendar/calendarApi.js";
|
|
21
|
-
import {
|
|
22
|
-
VideoMeetingInvitee,
|
|
23
|
-
createVideoMeeting,
|
|
24
|
-
getVideoMeeting,
|
|
25
|
-
updateVideoMeeting,
|
|
26
|
-
} from "@rapidmx/react-shared/videoconf/videoMeetingsApi.js";
|
|
27
|
-
import { deleteEventOccurrence, deleteEventSeries, detachOccurrence, saveEventSeries } from "@rapidmx/react-shared/calendar/calendarMutations.js";
|
|
28
|
-
import { toDatetimeLocal } from "@rapidmx/react-shared/util/dateInput.js";
|
|
5
|
+
import React, { useRef, useState } from "react";
|
|
29
6
|
import { Mailbox } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
30
|
-
import { CalendarOccurrence
|
|
7
|
+
import { CalendarOccurrence } from "@rapidmx/react-shared/calendar/recurrence.js";
|
|
31
8
|
import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
|
|
32
|
-
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
33
9
|
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import {
|
|
10
|
+
import useIsMobile from "@rapidmx/react-shared/util/useIsMobile.js";
|
|
11
|
+
import EventDetails from "./EventDetails.js";
|
|
12
|
+
import EventEditor from "./EventEditor.js";
|
|
13
|
+
import EventShell, { EventAnchor, EventShellVariant } from "./EventShell.js";
|
|
14
|
+
import { QuickTab } from "./QuickCreateTabs.js";
|
|
39
15
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const SELECT_CLASS =
|
|
43
|
-
"text-sm py-2 px-2 border border-border rounded-sm bg-surface text-text focus:outline-none focus:border-primary";
|
|
44
|
-
|
|
45
|
-
const ATTENDEE_ROLES: AttendeeRole[] = ["required", "optional", "resource"];
|
|
46
|
-
const BUSY_STATUSES: BusyStatus[] = ["busy", "free", "tentative", "oof"];
|
|
47
|
-
const BUSY_STATUS_LABEL: Record<BusyStatus, string> = { busy: "Busy", free: "Free", tentative: "Tentative", oof: "Out of office" };
|
|
48
|
-
const RESPONSE_STATUS_LABEL: Record<AttendeeResponseStatus, string> = {
|
|
49
|
-
needsAction: "Awaiting response",
|
|
50
|
-
accepted: "Accepted",
|
|
51
|
-
declined: "Declined",
|
|
52
|
-
tentative: "Tentative",
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* The Location text this modal writes when it mints a video meeting for an event, and the one value it will
|
|
57
|
-
* clear again when video conferencing is turned back off (see `applyVideoConferencing()`).
|
|
58
|
-
*
|
|
59
|
-
* Deliberately generic and identical for everyone: each attendee's own personal join link is substituted into
|
|
60
|
-
* their own copy of the invitation server-side (`@rapidmx/restapi`'s `MeetingSchedulingJob`), so no link -
|
|
61
|
-
* personal or otherwise - may be stored on the shared event itself, where every attendee would read the same
|
|
62
|
-
* one.
|
|
63
|
-
*/
|
|
64
|
-
export const VIDEO_LOCATION_PLACEHOLDER = "Video call — link in this invitation";
|
|
65
|
-
|
|
66
|
-
/** The plugin's own title bound (`BaseVideoMeetingRoute`'s `MAX_TITLE_LENGTH`) - a longer title is a 400, so
|
|
67
|
-
* an over-long event title is trimmed to fit rather than failing the whole meeting. */
|
|
68
|
-
const MAX_MEETING_TITLE_LENGTH = 200;
|
|
16
|
+
export { VIDEO_LOCATION_PLACEHOLDER } from "./EventEditor.js";
|
|
17
|
+
export type { EventAnchor } from "./EventShell.js";
|
|
69
18
|
|
|
70
19
|
export interface EventModalProps {
|
|
71
20
|
open: boolean;
|
|
@@ -83,6 +32,8 @@ export interface EventModalProps {
|
|
|
83
32
|
* "Mailbox" selector (create mode only) chooses the mailbox, which in turn drives the Calendar selector
|
|
84
33
|
* and the organizer address; `mailboxUid`/`folderUid` are the initial selection. */
|
|
85
34
|
mailboxOptions?: { mailbox: Mailbox; calendars: { uid: string; name: string }[] }[];
|
|
35
|
+
/** Each calendar's colour, keyed by folder uid: the dot next to the calendar's name. */
|
|
36
|
+
folderColors?: Record<string, string>;
|
|
86
37
|
organizerAddress: string;
|
|
87
38
|
/** The viewing mailbox's alias addresses - an event it organizes (or an invitation to it) may name any of
|
|
88
39
|
* them instead of `organizerAddress`. Defaults to that mailbox's `aliasAddresses` from `mailboxOptions`. */
|
|
@@ -92,79 +43,37 @@ export interface EventModalProps {
|
|
|
92
43
|
/** Prefilled start/end for create mode (e.g. the day/slot the user clicked). */
|
|
93
44
|
initialStart?: Date;
|
|
94
45
|
initialEnd?: Date;
|
|
46
|
+
/** Create mode: start as an all-day event on `initialStart`'s day (a day of the month view was clicked). */
|
|
47
|
+
initialAllDay?: boolean;
|
|
48
|
+
/** Create mode: what was clicked (a slot, a day, the New event button), which the quick-create popover opens beside. Without one it
|
|
49
|
+
* opens centered near the top of the window. */
|
|
50
|
+
anchor?: EventAnchor;
|
|
51
|
+
/** Where the booking plugin's Settings pages are (`/settings/booking-types`) when it is running: a new event then has an Appointment
|
|
52
|
+
* schedule tab, and its More options opens the plugin's own new-link page. Without it there are only the Event and Task tabs. */
|
|
53
|
+
bookingHref?: string;
|
|
95
54
|
onSaved: () => void;
|
|
96
55
|
onDeleted: () => void;
|
|
97
56
|
}
|
|
98
57
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const MS_PER_MINUTE = 60_000;
|
|
106
|
-
const MS_PER_DAY = 86_400_000;
|
|
107
|
-
|
|
108
|
-
/** Whether two ISO instants fall in the same minute - a stored `...T15:00:00Z` and the form's re-serialized
|
|
109
|
-
* `...T15:00:00.000Z` name the same time without being equal strings. */
|
|
110
|
-
function sameMinute(a: string, b: string): boolean {
|
|
111
|
-
return Math.round(new Date(a).getTime() / MS_PER_MINUTE) === Math.round(new Date(b).getTime() / MS_PER_MINUTE);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** Milliseconds since midnight of an instant's wall clock in `timezone` (a timed event's own zone). */
|
|
115
|
-
function wallTimeOfDayMs(instantMs: number, timezone: string | undefined): number {
|
|
116
|
-
const wall = toEventWallClock(instantMs, timezone, false);
|
|
117
|
-
return ((wall % MS_PER_DAY) + MS_PER_DAY) % MS_PER_DAY;
|
|
118
|
-
}
|
|
58
|
+
/** How wide each face of the dialog gets, in px. */
|
|
59
|
+
const QUICK_WIDTH = 450;
|
|
60
|
+
const DETAILS_WIDTH = 480;
|
|
61
|
+
const FORM_WIDTH = 880;
|
|
62
|
+
const TASK_FORM_WIDTH = 560;
|
|
119
63
|
|
|
120
64
|
/**
|
|
121
|
-
*
|
|
122
|
-
* ever shows (and edits) *this occurrence's* dates, but the series is stored as its master record starting
|
|
123
|
-
* at the first occurrence - sending the occurrence's dates as-is would move the whole series' start to
|
|
124
|
-
* this occurrence. So only the change in time-of-day (and the new duration) is applied to the master's own
|
|
125
|
-
* start; the series keeps its original first date. Unchanged times aren't sent at all.
|
|
65
|
+
* The calendar's event dialog, in three faces drawn through one frame (`EventShell`):
|
|
126
66
|
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const master = await getCalendarEvent(occurrence.uid);
|
|
138
|
-
const timezone = fields.timezone as string;
|
|
139
|
-
const newStart = new Date(startDate as string).getTime();
|
|
140
|
-
const durationMs = new Date(endDate as string).getTime() - newStart;
|
|
141
|
-
let masterStart: number;
|
|
142
|
-
if (fields.allDay) {
|
|
143
|
-
// Timed -> all-day keeps the master's own date on its wall clock.
|
|
144
|
-
const masterDateKey = master.allDay
|
|
145
|
-
? allDayDateKey(master.startDate)
|
|
146
|
-
: new Date(toEventWallClock(new Date(master.startDate).getTime(), timezone, false)).toISOString().slice(0, 10);
|
|
147
|
-
masterStart = new Date(allDayInstant(masterDateKey)).getTime();
|
|
148
|
-
} else if (master.allDay) {
|
|
149
|
-
// All-day -> timed: the master's own date at the newly chosen wall-clock time.
|
|
150
|
-
const masterDateWall = new Date(allDayInstant(allDayDateKey(master.startDate))).getTime();
|
|
151
|
-
masterStart = fromEventWallClock(masterDateWall + wallTimeOfDayMs(newStart, timezone), timezone, false);
|
|
152
|
-
} else {
|
|
153
|
-
const rawDelta = wallTimeOfDayMs(newStart, timezone) - wallTimeOfDayMs(new Date(occurrence.startDate).getTime(), timezone);
|
|
154
|
-
const delta = ((((rawDelta + MS_PER_DAY / 2) % MS_PER_DAY) + MS_PER_DAY) % MS_PER_DAY) - MS_PER_DAY / 2;
|
|
155
|
-
const masterWall = toEventWallClock(new Date(master.startDate).getTime(), timezone, false);
|
|
156
|
-
masterStart = fromEventWallClock(masterWall + delta, timezone, false);
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
...rest,
|
|
160
|
-
startDate: new Date(masterStart).toISOString(),
|
|
161
|
-
endDate: new Date(masterStart + durationMs).toISOString(),
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Create/view/edit/delete for a single calendar event. Editing or deleting a recurring event's
|
|
167
|
-
* occurrence offers a choice between "this event" and "the entire series" (see
|
|
67
|
+
* - **A new event** opens as a quick-create popover (`EventQuickForm`, beside what was clicked; a bottom sheet on a phone). "More options"
|
|
68
|
+
* grows it into the full card (`EventExpandedForm`) with everything typed so far still in it.
|
|
69
|
+
* The popover has tabs (`QuickCreateTabs`): Event, Task, and - when the booking plugin is running (`bookingHref`) - Appointment schedule.
|
|
70
|
+
* The Task and Appointment faces are drawn by `QuickCreateFaces`, share the Event tab's title, mailbox and calendar, and only ever
|
|
71
|
+
* create a task or a booking type; the Event tab is the form it always was.
|
|
72
|
+
* - **An existing event** opens read-only (`EventDetails`): what the event says, the invited reader's Accept / Tentative / Decline,
|
|
73
|
+
* and Delete. The reader who organized it also gets Modify, which turns the same card into the full form; closing that form returns
|
|
74
|
+
* to the details, discarding the edits (a save closes everything, as it always did).
|
|
75
|
+
*
|
|
76
|
+
* Editing or deleting a recurring event's occurrence offers a choice between "this event" and "the entire series" (see
|
|
168
77
|
* `calendarMutations.ts`) — Outlook's own convention for the same ambiguity.
|
|
169
78
|
*/
|
|
170
79
|
export default function EventModal({
|
|
@@ -174,377 +83,30 @@ export default function EventModal({
|
|
|
174
83
|
folderUid,
|
|
175
84
|
calendars,
|
|
176
85
|
mailboxOptions,
|
|
86
|
+
folderColors,
|
|
177
87
|
organizerAddress,
|
|
178
88
|
organizerAliases,
|
|
179
89
|
occurrence,
|
|
180
90
|
initialStart,
|
|
181
91
|
initialEnd,
|
|
92
|
+
initialAllDay,
|
|
93
|
+
anchor,
|
|
94
|
+
bookingHref,
|
|
182
95
|
onSaved,
|
|
183
96
|
onDeleted,
|
|
184
97
|
}: EventModalProps) {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
// Every address the viewing mailbox receives at - its primary address and its aliases, case-insensitively.
|
|
192
|
-
const ownAddresses = new Set(
|
|
193
|
-
[organizerAddress, ...(organizerAliases ?? mailboxOptions?.find((option) => option.mailbox.uid === mailboxUid)?.mailbox.aliasAddresses ?? [])].map(
|
|
194
|
-
(address) => address.toLowerCase(),
|
|
195
|
-
),
|
|
196
|
-
);
|
|
197
|
-
const isOwnAddress = (address: string) => ownAddresses.has(address.toLowerCase());
|
|
198
|
-
// An existing event organized by someone else is the viewing mailbox's copy of an invitation: only the
|
|
199
|
-
// organizer can change it (their next update would overwrite local edits anyway), so it's read-only
|
|
200
|
-
// apart from the RSVP controls.
|
|
201
|
-
const isInvited =
|
|
202
|
-
!!occurrence && !isOwnAddress(occurrence.organizer.address) && !occurrence.attendees.some((a) => a.isOrganizer && isOwnAddress(a.address));
|
|
203
|
-
|
|
204
|
-
function handleMailboxChange(nextMailboxUid: string) {
|
|
205
|
-
setTargetMailboxUid(nextMailboxUid);
|
|
206
|
-
const firstCalendar = mailboxOptions?.find((option) => option.mailbox.uid === nextMailboxUid)?.calendars[0];
|
|
207
|
-
if (firstCalendar) {
|
|
208
|
-
setTargetFolderUid(firstCalendar.uid);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
const [title, setTitle] = useState(occurrence?.title ?? "");
|
|
212
|
-
const [location, setLocation] = useState(occurrence?.location ?? "");
|
|
213
|
-
// An all-day event is stored date-only with an exclusive end (see `allDay.ts`); the form shows its
|
|
214
|
-
// inclusive last day instead.
|
|
215
|
-
const [start, setStart] = useState(() =>
|
|
216
|
-
occurrence?.allDay
|
|
217
|
-
? `${allDayDateKey(occurrence.startDate)}T00:00`
|
|
218
|
-
: toDatetimeLocal(occurrence?.startDate ?? initialStart?.toISOString() ?? new Date().toISOString()),
|
|
219
|
-
);
|
|
220
|
-
const [end, setEnd] = useState(() => {
|
|
221
|
-
if (occurrence?.allDay) {
|
|
222
|
-
const startKey = allDayDateKey(occurrence.startDate);
|
|
223
|
-
const lastDayKey = addDaysToKey(allDayDateKey(occurrence.endDate), -1);
|
|
224
|
-
return `${lastDayKey < startKey ? startKey : lastDayKey}T00:00`;
|
|
225
|
-
}
|
|
226
|
-
return toDatetimeLocal(occurrence?.endDate ?? initialEnd?.toISOString() ?? new Date(Date.now() + 30 * 60_000).toISOString());
|
|
227
|
-
});
|
|
228
|
-
const [allDay, setAllDay] = useState(occurrence?.allDay ?? false);
|
|
229
|
-
const [timezone] = useState(occurrence?.timezone ?? Intl.DateTimeFormat().resolvedOptions().timeZone);
|
|
230
|
-
const [attendees, setAttendees] = useState<Attendee[]>(occurrence?.attendees ?? []);
|
|
231
|
-
const [recurrenceRule, setRecurrenceRule] = useState<RecurrenceRule | null>(occurrence?.recurrenceRule ?? null);
|
|
232
|
-
const [reminderMinutes, setReminderMinutes] = useState(occurrence?.reminderMinutesBeforeStart?.toString() ?? "");
|
|
233
|
-
const [busyStatus, setBusyStatus] = useState<BusyStatus>(occurrence?.busyStatus ?? "busy");
|
|
234
|
-
const [autoReplyEnabled, setAutoReplyEnabled] = useState(occurrence?.autoReplyEnabled ?? false);
|
|
235
|
-
const [autoReplyMessage, setAutoReplyMessage] = useState(occurrence?.autoReplyMessage ?? "");
|
|
236
|
-
const [editScope, setEditScope] = useState<EditScope>("occurrence");
|
|
237
|
-
// Video conferencing: the toggle, the meeting this event is linked to (if any), the organizer's own join
|
|
238
|
-
// link for it, and whatever went wrong with the last attempt to mint/cancel one.
|
|
239
|
-
const [videoEnabled, setVideoEnabled] = useState(!!occurrence?.videoMeetingUid);
|
|
240
|
-
const [videoMeetingUid, setVideoMeetingUid] = useState<string | undefined>(occurrence?.videoMeetingUid);
|
|
241
|
-
// `undefined` while the link is still being fetched, `null` once it is known there is none to open.
|
|
242
|
-
const [organizerJoinUrl, setOrganizerJoinUrl] = useState<string | null | undefined>(undefined);
|
|
243
|
-
const [videoError, setVideoError] = useState<string | null>(null);
|
|
244
|
-
// The event as this modal last persisted it. Set only when a save got the event stored but could not
|
|
245
|
-
// finish the video-conferencing step after it: the modal then stays open on that error, and the retry
|
|
246
|
-
// must update *that* record (its uid and its new version), not re-create it or reuse the stale prop.
|
|
247
|
-
const [savedEvent, setSavedEvent] = useState<CalendarEvent | null>(null);
|
|
248
|
-
const [confirmingDelete, setConfirmingDelete] = useState(false);
|
|
249
|
-
const [error, setError] = useState<string | null>(null);
|
|
250
|
-
const [saving, setSaving] = useState(false);
|
|
251
|
-
// A series save that moved the series but couldn't move every separately edited occurrence with it.
|
|
98
|
+
const isMobile = useIsMobile();
|
|
99
|
+
// An existing event: Modify was pressed. A new event: More options was.
|
|
100
|
+
const [editing, setEditing] = useState(false);
|
|
101
|
+
const [expanded, setExpanded] = useState(false);
|
|
102
|
+
// A new event: what the popover creates (an event, a task or an appointment schedule). More options only ever grows the tab it was pressed on.
|
|
103
|
+
const [tab, setTab] = useState<QuickTab>("event");
|
|
252
104
|
const [syncWarning, setSyncWarning] = useState(false);
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
const addResourceButtonRef = useRef<HTMLButtonElement>(null);
|
|
256
|
-
|
|
257
|
-
// An event that already carried a meeting when it was opened (e.g. after a page reload) knows only that
|
|
258
|
-
// meeting's uid - the organizer's own join link lives on the meeting, so it is fetched once here. A
|
|
259
|
-
// meeting minted in this session already has its link from the create call (see
|
|
260
|
-
// `applyVideoConferencing()`), which is why this deliberately reads the *prop*, not the state: it must
|
|
261
|
-
// not re-fetch what was just handed to us. A failure and a meeting with no link at all are the same
|
|
262
|
-
// thing to this UI - there is nothing to open either way - so both settle on `null`.
|
|
263
|
-
useEffect(() => {
|
|
264
|
-
const uid = occurrence?.videoMeetingUid;
|
|
265
|
-
if (!uid) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
let cancelled = false;
|
|
269
|
-
void getVideoMeeting(uid)
|
|
270
|
-
.then((meeting) => meeting.organizerJoinUrl ?? null)
|
|
271
|
-
.catch(() => null)
|
|
272
|
-
.then((url) => {
|
|
273
|
-
if (!cancelled) {
|
|
274
|
-
setOrganizerJoinUrl(url);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
return () => {
|
|
278
|
-
cancelled = true;
|
|
279
|
-
};
|
|
280
|
-
}, [occurrence?.videoMeetingUid]);
|
|
281
|
-
|
|
282
|
-
// The viewing mailbox can respond to an *existing* event it's invited to but doesn't organize —
|
|
283
|
-
// `organizerAddress` (plus the aliases) are this mailbox's own addresses (see `EventModalProps`), so
|
|
284
|
-
// finding one among `attendees` (and not as that attendee's own organizer flag) identifies exactly
|
|
285
|
-
// that case. `@rapidmx/restapi`'s `respond()` route has no occurrence-vs-series scope of its own
|
|
286
|
-
// (see `calendarApi.ts`'s `respondToEvent` doc comment) — it always acts on `occurrence.uid` as a
|
|
287
|
-
// single event document, so this deliberately does not consult `editScope`.
|
|
288
|
-
const myAttendeeIndex = occurrence ? attendees.findIndex((a) => isOwnAddress(a.address)) : -1;
|
|
289
|
-
const canRespond = myAttendeeIndex !== -1 && !attendees[myAttendeeIndex].isOrganizer;
|
|
290
|
-
// "This event only" detaches a standalone, non-repeating copy - the series' rule doesn't apply to it.
|
|
291
|
-
const editingSingleOccurrence = !!occurrence?.isRecurringOccurrence && editScope === "occurrence";
|
|
292
|
-
|
|
293
|
-
function updateAttendee(index: number, patch: Partial<Attendee>) {
|
|
294
|
-
setAttendees((prev) => prev.map((a, i) => (i === index ? { ...a, ...patch } : a)));
|
|
295
|
-
}
|
|
296
|
-
function removeAttendee(index: number) {
|
|
297
|
-
setAttendees((prev) => prev.filter((_, i) => i !== index));
|
|
298
|
-
}
|
|
299
|
-
function addResource(mailbox: Mailbox) {
|
|
300
|
-
setAttendees((prev) => [
|
|
301
|
-
...prev,
|
|
302
|
-
{ address: mailbox.primarySmtpAddress, displayName: mailbox.displayName, role: "resource", responseStatus: "needsAction", isOrganizer: false },
|
|
303
|
-
]);
|
|
304
|
-
setResourcePickerOpen(false);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Brings the event's video meeting in line with the toggle, once the event itself is saved (so the
|
|
309
|
-
* attendee list a new meeting's invitees are built from is the one that was just stored).
|
|
310
|
-
*
|
|
311
|
-
* Turning it **on** mints a meeting for the saved event's attendees - every one of them except the
|
|
312
|
-
* organizer, who reaches their own meeting through ownership (`organizerJoinUrl`), not as a guest - and
|
|
313
|
-
* then patches the event with the meeting's uid and the generic `VIDEO_LOCATION_PLACEHOLDER` location.
|
|
314
|
-
* No join link is written onto the event: each attendee's own link is substituted into their own copy of
|
|
315
|
-
* the invitation server-side.
|
|
316
|
-
*
|
|
317
|
-
* Turning it **off** cancels the meeting and clears the link, restoring Location to `""` only when it
|
|
318
|
-
* still holds exactly the placeholder this modal wrote - anything the user has typed there since is
|
|
319
|
-
* theirs and is preserved.
|
|
320
|
-
*
|
|
321
|
-
* **Known, deliberate limitation:** an event that already has a meeting is left completely alone, even
|
|
322
|
-
* when its attendee list has just changed. `@rapidmx/meet-plugin`'s `PUT /mail/video-meetings/:id`
|
|
323
|
-
* is deliberately minimal (title and cancellation only) and cannot add or remove invitees, and a private
|
|
324
|
-
* meeting's personal join links are minted once at creation - so there is no way to reconcile an invitee
|
|
325
|
-
* list, and silently pretending otherwise would leave a new attendee with no link and a removed one with
|
|
326
|
-
* a working one. The helper text under the checkbox says so, and turning the toggle off and on again
|
|
327
|
-
* reissues links for the current attendee list.
|
|
328
|
-
*
|
|
329
|
-
* Never throws: the event is already stored by the time this runs, so a failure here is reported inline
|
|
330
|
-
* next to the checkbox and left retryable, with `videoMeetingUid` still whatever it was before.
|
|
331
|
-
*/
|
|
332
|
-
async function applyVideoConferencing(saved: CalendarEvent): Promise<{ event: CalendarEvent; failed: boolean }> {
|
|
333
|
-
// Off and never on, or on and already linked (see the limitation above) - nothing to do either way.
|
|
334
|
-
if (videoEnabled === !!videoMeetingUid) {
|
|
335
|
-
return { event: saved, failed: false };
|
|
336
|
-
}
|
|
337
|
-
// Detaching a single occurrence (`detachOccurrence()`, react-shared's `calendarMutations.ts`)
|
|
338
|
-
// deliberately never copies the series' `videoMeetingUid` onto the new standalone event - that
|
|
339
|
-
// shared meeting belongs to the series, not to the one occurrence being split off, and every other
|
|
340
|
-
// occurrence still needs it live. But this component's own `videoMeetingUid` *state* was seeded
|
|
341
|
-
// from the series' occurrence at mount and is untouched by the detach, so unchecking the toggle
|
|
342
|
-
// while detaching would otherwise still look like "off, but state says linked" above and fall into
|
|
343
|
-
// the cancel branch below - cancelling the series' shared meeting for every remaining occurrence,
|
|
344
|
-
// not just this one. `saved.videoMeetingUid` is the actual just-persisted record, so when the
|
|
345
|
-
// toggle is off and that record already has no meeting reference (true for every detach, checked or
|
|
346
|
-
// not - see this function's own doc comment on the still-checked case being a separate, documented
|
|
347
|
-
// gap), there is nothing of *this* record's to cancel.
|
|
348
|
-
if (!videoEnabled && !saved.videoMeetingUid) {
|
|
349
|
-
return { event: saved, failed: false };
|
|
350
|
-
}
|
|
351
|
-
try {
|
|
352
|
-
if (videoEnabled) {
|
|
353
|
-
const organizerAddressLower = saved.organizer.address.toLowerCase();
|
|
354
|
-
const invitees: VideoMeetingInvitee[] = attendees
|
|
355
|
-
.filter((a) => !a.isOrganizer && !!a.address.trim() && a.address.trim().toLowerCase() !== organizerAddressLower)
|
|
356
|
-
.map((a) => ({ email: a.address.trim(), displayName: a.displayName }));
|
|
357
|
-
if (invitees.length === 0) {
|
|
358
|
-
setVideoError("Add at least one attendee other than yourself to add video conferencing.");
|
|
359
|
-
return { event: saved, failed: true };
|
|
360
|
-
}
|
|
361
|
-
const result = await createVideoMeeting({
|
|
362
|
-
mailboxUid: saved.mailboxUid,
|
|
363
|
-
title: saved.title.slice(0, MAX_MEETING_TITLE_LENGTH),
|
|
364
|
-
visibility: "private",
|
|
365
|
-
calendarEventUid: saved.uid,
|
|
366
|
-
startTime: saved.startDate,
|
|
367
|
-
endTime: saved.endDate,
|
|
368
|
-
invitees,
|
|
369
|
-
});
|
|
370
|
-
const patched = await updateCalendarEvent({
|
|
371
|
-
uid: saved.uid,
|
|
372
|
-
version: saved.version,
|
|
373
|
-
location: VIDEO_LOCATION_PLACEHOLDER,
|
|
374
|
-
videoMeetingUid: result.meeting.uid,
|
|
375
|
-
});
|
|
376
|
-
setVideoMeetingUid(result.meeting.uid);
|
|
377
|
-
setOrganizerJoinUrl(result.organizerJoinUrl ?? null);
|
|
378
|
-
setLocation(VIDEO_LOCATION_PLACEHOLDER);
|
|
379
|
-
return { event: patched, failed: false };
|
|
380
|
-
}
|
|
381
|
-
await updateVideoMeeting(videoMeetingUid!, { status: "cancelled" });
|
|
382
|
-
const restoredLocation = location.trim() === VIDEO_LOCATION_PLACEHOLDER ? "" : location.trim();
|
|
383
|
-
// A stored event clears a field with an explicit `null` (see `EventFields`) - an omitted one would
|
|
384
|
-
// leave the placeholder (and the link to the now-cancelled meeting) in place.
|
|
385
|
-
const patch: EventFields = { location: restoredLocation || null, videoMeetingUid: null };
|
|
386
|
-
const patched = await updateCalendarEvent({ uid: saved.uid, version: saved.version, ...(patch as Partial<CalendarEventInput>) });
|
|
387
|
-
setVideoMeetingUid(undefined);
|
|
388
|
-
setOrganizerJoinUrl(undefined);
|
|
389
|
-
setLocation(restoredLocation);
|
|
390
|
-
return { event: patched, failed: false };
|
|
391
|
-
} catch (err) {
|
|
392
|
-
// `videoMeetingsApi.ts`'s own doc comment: when the plugin isn't installed at all, its routes
|
|
393
|
-
// simply aren't mounted and every call here fails with a plain 404 - a caller offering video
|
|
394
|
-
// conferencing optionally must treat that as "not available here," not alarm the reader with
|
|
395
|
-
// the raw (often server-generated, unhelpful) 404 body text.
|
|
396
|
-
setVideoError(
|
|
397
|
-
err instanceof ApiRequestError
|
|
398
|
-
? err.status === 404
|
|
399
|
-
? "Video conferencing is not available on this server."
|
|
400
|
-
: err.message
|
|
401
|
-
: "Could not update this event's video conferencing.",
|
|
402
|
-
);
|
|
403
|
-
return { event: saved, failed: true };
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
async function handleSubmit(e: FormEvent) {
|
|
408
|
-
e.preventDefault();
|
|
409
|
-
setError(null);
|
|
410
|
-
setVideoError(null);
|
|
411
|
-
|
|
412
|
-
if (!title.trim()) {
|
|
413
|
-
setError("A title is required.");
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
let startDate: string;
|
|
417
|
-
let endDate: string;
|
|
418
|
-
if (allDay) {
|
|
419
|
-
const startKey = start.slice(0, 10);
|
|
420
|
-
const lastDayKey = end.slice(0, 10);
|
|
421
|
-
if (lastDayKey < startKey) {
|
|
422
|
-
setError("The end date can't be before the start date.");
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
startDate = allDayInstant(startKey);
|
|
426
|
-
endDate = allDayInstant(addDaysToKey(lastDayKey, 1));
|
|
427
|
-
} else {
|
|
428
|
-
if (new Date(end) <= new Date(start)) {
|
|
429
|
-
setError("The end time must be after the start time.");
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
startDate = new Date(start).toISOString();
|
|
433
|
-
endDate = new Date(end).toISOString();
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// Only a stored event is updated in place, where a cleared field must be sent as `null`; creating
|
|
437
|
-
// (a new event, or the detached copy of one occurrence) just omits it.
|
|
438
|
-
const updatingInPlace = !!occurrence && !editingSingleOccurrence;
|
|
439
|
-
const cleared = updatingInPlace ? null : undefined;
|
|
440
|
-
const fields: EventFields = {
|
|
441
|
-
title: title.trim(),
|
|
442
|
-
location: location.trim() || cleared,
|
|
443
|
-
startDate,
|
|
444
|
-
endDate,
|
|
445
|
-
allDay,
|
|
446
|
-
timezone,
|
|
447
|
-
attendees,
|
|
448
|
-
recurrenceRule: editingSingleOccurrence ? undefined : (recurrenceRule ?? cleared),
|
|
449
|
-
reminderMinutesBeforeStart: reminderMinutes.trim() ? Number(reminderMinutes) : cleared,
|
|
450
|
-
busyStatus,
|
|
451
|
-
autoReplyEnabled,
|
|
452
|
-
autoReplyMessage: autoReplyEnabled ? autoReplyMessage : cleared,
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
setSaving(true);
|
|
456
|
-
try {
|
|
457
|
-
let saved: CalendarEvent;
|
|
458
|
-
let detachedSyncFailed = false;
|
|
459
|
-
if (savedEvent) {
|
|
460
|
-
// A retry after the event was stored but its video meeting couldn't be (see `savedEvent`):
|
|
461
|
-
// update exactly the record the first attempt left behind, whichever branch below created it.
|
|
462
|
-
// A series' own exception/detached-occurrence re-pointing already ran on that attempt and has
|
|
463
|
-
// nothing left to shift - the dates being sent again are the ones it moved everything to.
|
|
464
|
-
saved = await updateCalendarEvent({ uid: savedEvent.uid, version: savedEvent.version, ...(fields as Partial<CalendarEventInput>) });
|
|
465
|
-
} else if (!occurrence) {
|
|
466
|
-
// The organizer is only ever set on create - an edit keeps the event's own organizer.
|
|
467
|
-
saved = await createCalendarEvent({
|
|
468
|
-
mailboxUid: targetMailboxUid,
|
|
469
|
-
folderUid: targetFolderUid,
|
|
470
|
-
...fields,
|
|
471
|
-
organizer: { address: effectiveOrganizerAddress, type: "to" },
|
|
472
|
-
} as CalendarEventInput);
|
|
473
|
-
} else if (editingSingleOccurrence) {
|
|
474
|
-
saved = await detachOccurrence(occurrence, fields as Partial<CalendarEventInput>);
|
|
475
|
-
} else if (occurrence.isRecurringOccurrence) {
|
|
476
|
-
const series = await saveEventSeries(occurrence, (await toSeriesFields(occurrence, fields)) as Partial<CalendarEventInput>);
|
|
477
|
-
saved = series;
|
|
478
|
-
detachedSyncFailed = !!series.detachedOccurrenceSyncFailed;
|
|
479
|
-
} else {
|
|
480
|
-
saved = await updateCalendarEvent({ uid: occurrence.uid, version: occurrence.version, ...(fields as Partial<CalendarEventInput>) });
|
|
481
|
-
}
|
|
482
|
-
const video = await applyVideoConferencing(saved);
|
|
483
|
-
if (video.failed) {
|
|
484
|
-
// The event itself is saved - keep the modal open on the inline error so the video meeting
|
|
485
|
-
// can be retried (or the toggle put back) rather than closing over it.
|
|
486
|
-
setSavedEvent(video.event);
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
if (detachedSyncFailed) {
|
|
490
|
-
// The series itself was saved - say so, and leave closing to the user once they've read it.
|
|
491
|
-
setSyncWarning(true);
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
onSaved();
|
|
495
|
-
} catch (err) {
|
|
496
|
-
setError(err instanceof ApiRequestError ? err.message : "Could not save this event.");
|
|
497
|
-
} finally {
|
|
498
|
-
setSaving(false);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
// Only ever invoked from the Delete button(s) rendered inside the `{occurrence && (...)}` block
|
|
503
|
-
// below, so `occurrence` is always non-null here — no defensive null check needed.
|
|
504
|
-
async function handleDelete(scope: EditScope) {
|
|
505
|
-
setError(null);
|
|
506
|
-
setSaving(true);
|
|
507
|
-
try {
|
|
508
|
-
if (occurrence!.isRecurringOccurrence && scope === "occurrence") {
|
|
509
|
-
await deleteEventOccurrence(occurrence!);
|
|
510
|
-
} else {
|
|
511
|
-
await deleteEventSeries(occurrence!);
|
|
512
|
-
}
|
|
513
|
-
onDeleted();
|
|
514
|
-
} catch (err) {
|
|
515
|
-
setError(err instanceof ApiRequestError ? err.message : "Could not delete this event.");
|
|
516
|
-
setSaving(false);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// Only rendered inside the `{canRespond && (...)}` block below, which already requires `occurrence`
|
|
521
|
-
// to be non-null (see `canRespond`'s own definition above) — same established pattern as
|
|
522
|
-
// `handleDelete`'s non-null assertion.
|
|
523
|
-
async function handleRespond(responseStatus: AttendeeResponseInput) {
|
|
524
|
-
setError(null);
|
|
525
|
-
setResponding(true);
|
|
526
|
-
try {
|
|
527
|
-
await respondToEvent(occurrence!.uid, responseStatus);
|
|
528
|
-
// A decline soft-deletes the mailbox's own copy server-side — treat it the same as a
|
|
529
|
-
// delete rather than a save so the calendar view drops it immediately.
|
|
530
|
-
if (responseStatus === "declined") {
|
|
531
|
-
onDeleted();
|
|
532
|
-
} else {
|
|
533
|
-
onSaved();
|
|
534
|
-
}
|
|
535
|
-
} catch (err) {
|
|
536
|
-
setError(err instanceof ApiRequestError ? err.message : "Could not send your response.");
|
|
537
|
-
setResponding(false);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
105
|
+
// Whether the form holds anything a click on the backdrop would throw away (kept up to date by the editor).
|
|
106
|
+
const dirtyRef = useRef(false);
|
|
540
107
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
function handleAllDayChange(nextAllDay: boolean) {
|
|
544
|
-
setAllDay(nextAllDay);
|
|
545
|
-
setRecurrenceRule((rule) =>
|
|
546
|
-
rule?.until ? { ...rule, until: recurrenceUntilInstant(recurrenceUntilDateKey(rule.until, allDay), nextAllDay) } : rule,
|
|
547
|
-
);
|
|
108
|
+
if (!open) {
|
|
109
|
+
return null;
|
|
548
110
|
}
|
|
549
111
|
|
|
550
112
|
if (syncWarning) {
|
|
@@ -561,382 +123,84 @@ export default function EventModal({
|
|
|
561
123
|
);
|
|
562
124
|
}
|
|
563
125
|
|
|
564
|
-
//
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const
|
|
126
|
+
// Every address the viewing mailbox receives at - its primary address and its aliases, case-insensitively.
|
|
127
|
+
const ownAddresses = new Set(
|
|
128
|
+
[organizerAddress, ...(organizerAliases ?? mailboxOptions?.find((option) => option.mailbox.uid === mailboxUid)?.mailbox.aliasAddresses ?? [])].map(
|
|
129
|
+
(address) => address.toLowerCase(),
|
|
130
|
+
),
|
|
131
|
+
);
|
|
132
|
+
const isOwnAddress = (address: string) => ownAddresses.has(address.toLowerCase());
|
|
133
|
+
// An existing event organized by someone else is the viewing mailbox's copy of an invitation: only the
|
|
134
|
+
// organizer can change it (their next update would overwrite local edits anyway), so it can't be modified.
|
|
135
|
+
const isInvited =
|
|
136
|
+
!!occurrence && !isOwnAddress(occurrence.organizer.address) && !occurrence.attendees.some((a) => a.isOrganizer && isOwnAddress(a.address));
|
|
137
|
+
// The viewing mailbox can respond to an *existing* event it's invited to but doesn't organize - finding one of its own
|
|
138
|
+
// addresses among the attendees (and not as that attendee's own organizer flag) identifies exactly that case.
|
|
139
|
+
const myAttendee = occurrence?.attendees.find((a) => isOwnAddress(a.address));
|
|
140
|
+
const canRespond = !!myAttendee && !myAttendee.isOrganizer;
|
|
141
|
+
|
|
142
|
+
const isForm = !occurrence || editing;
|
|
143
|
+
const layout = occurrence || expanded ? "expanded" : "quick";
|
|
144
|
+
const variant: EventShellVariant = !isForm || layout === "expanded" ? "card" : isMobile ? "sheet" : "popover";
|
|
145
|
+
const width = !isForm ? DETAILS_WIDTH : layout === "expanded" ? (tab === "event" || occurrence ? FORM_WIDTH : TASK_FORM_WIDTH) : QUICK_WIDTH;
|
|
146
|
+
// Leaving the form: an existing event goes back to its details, a new one is done.
|
|
147
|
+
const leaveForm = occurrence ? () => setEditing(false) : onClose;
|
|
571
148
|
|
|
572
149
|
return (
|
|
573
|
-
<
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
variant="secondary"
|
|
629
|
-
className="!w-auto"
|
|
630
|
-
disabled={!validatedJoinUrl}
|
|
631
|
-
onClick={() => window.open(validatedJoinUrl!, "_blank", "noopener,noreferrer")}
|
|
632
|
-
>
|
|
633
|
-
Join video call
|
|
634
|
-
</Button>
|
|
635
|
-
{!validatedJoinUrl && (
|
|
636
|
-
<span className="text-xs text-text-muted">
|
|
637
|
-
{organizerJoinUrl === undefined ? "Loading the join link…" : "This meeting’s join link isn’t available."}
|
|
638
|
-
</span>
|
|
639
|
-
)}
|
|
640
|
-
</div>
|
|
641
|
-
)}
|
|
642
|
-
|
|
643
|
-
<fieldset disabled={isInvited} className="flex flex-col gap-1 min-w-0">
|
|
644
|
-
|
|
645
|
-
{!occurrence && mailboxOptions && mailboxOptions.length > 1 && (
|
|
646
|
-
<FormField label="Mailbox" htmlFor="event-mailbox">
|
|
647
|
-
<select
|
|
648
|
-
id="event-mailbox"
|
|
649
|
-
className={INPUT_CLASS}
|
|
650
|
-
value={targetMailboxUid}
|
|
651
|
-
onChange={(e) => handleMailboxChange(e.target.value)}
|
|
652
|
-
>
|
|
653
|
-
{mailboxOptions.map(({ mailbox }) => (
|
|
654
|
-
<option key={mailbox.uid} value={mailbox.uid}>
|
|
655
|
-
{mailbox.displayName}
|
|
656
|
-
{mailbox.ownerUserUid ? "" : " (shared)"}
|
|
657
|
-
</option>
|
|
658
|
-
))}
|
|
659
|
-
</select>
|
|
660
|
-
</FormField>
|
|
661
|
-
)}
|
|
662
|
-
|
|
663
|
-
{!occurrence && calendarChoices && calendarChoices.length > 1 && (
|
|
664
|
-
<FormField label="Calendar" htmlFor="event-calendar">
|
|
665
|
-
<select
|
|
666
|
-
id="event-calendar"
|
|
667
|
-
className={INPUT_CLASS}
|
|
668
|
-
value={targetFolderUid}
|
|
669
|
-
onChange={(e) => setTargetFolderUid(e.target.value)}
|
|
670
|
-
>
|
|
671
|
-
{calendarChoices.map((cal) => (
|
|
672
|
-
<option key={cal.uid} value={cal.uid}>
|
|
673
|
-
{cal.name}
|
|
674
|
-
</option>
|
|
675
|
-
))}
|
|
676
|
-
</select>
|
|
677
|
-
</FormField>
|
|
678
|
-
)}
|
|
679
|
-
|
|
680
|
-
<FormField label="Title" htmlFor="event-title">
|
|
681
|
-
<input id="event-title" type="text" className={INPUT_CLASS} value={title} onChange={(e) => setTitle(e.target.value)} />
|
|
682
|
-
</FormField>
|
|
683
|
-
|
|
684
|
-
<FormField label="Location" htmlFor="event-location">
|
|
685
|
-
<input id="event-location" type="text" className={INPUT_CLASS} value={location} onChange={(e) => setLocation(e.target.value)} />
|
|
686
|
-
</FormField>
|
|
687
|
-
|
|
688
|
-
<div className="mb-3">
|
|
689
|
-
<label className="flex items-center gap-2 text-sm font-medium">
|
|
690
|
-
<input type="checkbox" checked={videoEnabled} onChange={(e) => setVideoEnabled(e.target.checked)} />
|
|
691
|
-
Add video conferencing
|
|
692
|
-
</label>
|
|
693
|
-
{videoEnabled && (
|
|
694
|
-
<p className="text-xs text-text-muted mt-1">
|
|
695
|
-
Changing attendees after enabling video conferencing won’t update meeting invitees —
|
|
696
|
-
turn this off and back on to reissue links to the current attendee list.
|
|
697
|
-
</p>
|
|
698
|
-
)}
|
|
699
|
-
{videoError && (
|
|
700
|
-
<p role="alert" className="text-xs text-danger mt-1">
|
|
701
|
-
{videoError}
|
|
702
|
-
</p>
|
|
703
|
-
)}
|
|
704
|
-
</div>
|
|
705
|
-
|
|
706
|
-
<label className="flex items-center gap-2 text-sm font-medium mb-3">
|
|
707
|
-
<input type="checkbox" checked={allDay} onChange={(e) => handleAllDayChange(e.target.checked)} />
|
|
708
|
-
All day
|
|
709
|
-
</label>
|
|
710
|
-
|
|
711
|
-
<div className="grid grid-cols-2 gap-3">
|
|
712
|
-
<FormField label="Start" htmlFor="event-start">
|
|
713
|
-
<input
|
|
714
|
-
id="event-start"
|
|
715
|
-
type={allDay ? "date" : "datetime-local"}
|
|
716
|
-
className={INPUT_CLASS}
|
|
717
|
-
value={allDay ? start.slice(0, 10) : start}
|
|
718
|
-
onChange={(e) => setStart(allDay ? `${e.target.value}T00:00` : e.target.value)}
|
|
719
|
-
/>
|
|
720
|
-
</FormField>
|
|
721
|
-
<FormField label="End" htmlFor="event-end">
|
|
722
|
-
<input
|
|
723
|
-
id="event-end"
|
|
724
|
-
type={allDay ? "date" : "datetime-local"}
|
|
725
|
-
className={INPUT_CLASS}
|
|
726
|
-
value={allDay ? end.slice(0, 10) : end}
|
|
727
|
-
onChange={(e) => setEnd(allDay ? `${e.target.value}T00:00` : e.target.value)}
|
|
728
|
-
/>
|
|
729
|
-
</FormField>
|
|
730
|
-
</div>
|
|
731
|
-
|
|
732
|
-
<FormField label="Attendees" htmlFor="event-attendees">
|
|
733
|
-
<div id="event-attendees" className="flex flex-col gap-2">
|
|
734
|
-
{attendees.map((attendee, i) => (
|
|
735
|
-
<div key={i} className="flex gap-2">
|
|
736
|
-
<input
|
|
737
|
-
type="email"
|
|
738
|
-
className={`${INPUT_CLASS} flex-1`}
|
|
739
|
-
value={attendee.address}
|
|
740
|
-
onChange={(e) => updateAttendee(i, { address: e.target.value })}
|
|
741
|
-
aria-label={`Attendee email ${i + 1}`}
|
|
742
|
-
/>
|
|
743
|
-
<select
|
|
744
|
-
className={SELECT_CLASS}
|
|
745
|
-
value={attendee.role}
|
|
746
|
-
onChange={(e) => updateAttendee(i, { role: e.target.value as AttendeeRole })}
|
|
747
|
-
aria-label={`Attendee role ${i + 1}`}
|
|
748
|
-
>
|
|
749
|
-
{ATTENDEE_ROLES.map((role) => (
|
|
750
|
-
<option key={role} value={role}>
|
|
751
|
-
{role}
|
|
752
|
-
</option>
|
|
753
|
-
))}
|
|
754
|
-
</select>
|
|
755
|
-
<span className="text-xs font-medium text-text-muted shrink-0 py-1 px-2.5 rounded-pill bg-surface-alt self-center">
|
|
756
|
-
{RESPONSE_STATUS_LABEL[attendee.responseStatus]}
|
|
757
|
-
</span>
|
|
758
|
-
<button
|
|
759
|
-
type="button"
|
|
760
|
-
onClick={() => removeAttendee(i)}
|
|
761
|
-
className="text-sm text-danger px-2"
|
|
762
|
-
aria-label={`Remove attendee ${i + 1}`}
|
|
763
|
-
>
|
|
764
|
-
×
|
|
765
|
-
</button>
|
|
766
|
-
</div>
|
|
767
|
-
))}
|
|
768
|
-
<div className="flex gap-3 items-center">
|
|
769
|
-
<button
|
|
770
|
-
type="button"
|
|
771
|
-
onClick={() => setAttendees((prev) => [...prev, { address: "", role: "required", responseStatus: "needsAction", isOrganizer: false }])}
|
|
772
|
-
className="self-start text-xs font-medium text-primary-dark hover:underline"
|
|
773
|
-
>
|
|
774
|
-
+ Add attendee
|
|
775
|
-
</button>
|
|
776
|
-
<button
|
|
777
|
-
ref={addResourceButtonRef}
|
|
778
|
-
type="button"
|
|
779
|
-
onClick={() => setResourcePickerOpen(true)}
|
|
780
|
-
className="self-start text-xs font-medium text-primary-dark hover:underline"
|
|
781
|
-
>
|
|
782
|
-
+ Add room/equipment
|
|
783
|
-
</button>
|
|
784
|
-
</div>
|
|
785
|
-
{resourcePickerOpen && (
|
|
786
|
-
<ResourcePicker
|
|
787
|
-
anchorRef={addResourceButtonRef}
|
|
788
|
-
onClose={() => setResourcePickerOpen(false)}
|
|
789
|
-
onSelect={addResource}
|
|
790
|
-
excludeAddresses={attendees.map((a) => a.address.toLowerCase())}
|
|
791
|
-
/>
|
|
792
|
-
)}
|
|
793
|
-
</div>
|
|
794
|
-
</FormField>
|
|
795
|
-
|
|
796
|
-
<div className="grid grid-cols-2 gap-3">
|
|
797
|
-
<FormField label="Busy status" htmlFor="event-busyStatus">
|
|
798
|
-
<select
|
|
799
|
-
id="event-busyStatus"
|
|
800
|
-
className={INPUT_CLASS}
|
|
801
|
-
value={busyStatus}
|
|
802
|
-
onChange={(e) => setBusyStatus(e.target.value as BusyStatus)}
|
|
803
|
-
>
|
|
804
|
-
{BUSY_STATUSES.map((status) => (
|
|
805
|
-
<option key={status} value={status}>
|
|
806
|
-
{BUSY_STATUS_LABEL[status]}
|
|
807
|
-
</option>
|
|
808
|
-
))}
|
|
809
|
-
</select>
|
|
810
|
-
</FormField>
|
|
811
|
-
<FormField label="Reminder (minutes before)" htmlFor="event-reminder">
|
|
812
|
-
<input
|
|
813
|
-
id="event-reminder"
|
|
814
|
-
type="number"
|
|
815
|
-
min={0}
|
|
816
|
-
className={INPUT_CLASS}
|
|
817
|
-
value={reminderMinutes}
|
|
818
|
-
onChange={(e) => setReminderMinutes(e.target.value)}
|
|
819
|
-
placeholder="None"
|
|
820
|
-
/>
|
|
821
|
-
</FormField>
|
|
822
|
-
</div>
|
|
823
|
-
|
|
824
|
-
<div className="mb-3">
|
|
825
|
-
<label className="flex items-center gap-2 text-sm font-medium">
|
|
826
|
-
<input
|
|
827
|
-
type="checkbox"
|
|
828
|
-
checked={autoReplyEnabled}
|
|
829
|
-
onChange={(e) => setAutoReplyEnabled(e.target.checked)}
|
|
830
|
-
/>
|
|
831
|
-
Send an automatic reply while this event is happening
|
|
832
|
-
</label>
|
|
833
|
-
<p className="text-xs text-text-muted mt-1">
|
|
834
|
-
Applies in addition to your mailbox’s own Automatic Replies setting (see Settings) —
|
|
835
|
-
this event’s message takes over for its own start/end window.
|
|
836
|
-
</p>
|
|
837
|
-
{autoReplyEnabled && (
|
|
838
|
-
<textarea
|
|
839
|
-
aria-label="Automatic reply message"
|
|
840
|
-
className={`${INPUT_CLASS} mt-2`}
|
|
841
|
-
rows={3}
|
|
842
|
-
value={autoReplyMessage}
|
|
843
|
-
onChange={(e) => setAutoReplyMessage(e.target.value)}
|
|
844
|
-
placeholder="I'm out of office and back on..."
|
|
845
|
-
/>
|
|
846
|
-
)}
|
|
847
|
-
</div>
|
|
848
|
-
|
|
849
|
-
{!editingSingleOccurrence && (
|
|
850
|
-
<FormField label="Recurrence" htmlFor="event-recurrence">
|
|
851
|
-
<RecurrenceEditor
|
|
852
|
-
value={recurrenceRule}
|
|
853
|
-
onChange={setRecurrenceRule}
|
|
854
|
-
allDay={allDay}
|
|
855
|
-
startWeekday={startWeekdayCode(start, allDay, timezone)}
|
|
856
|
-
/>
|
|
857
|
-
</FormField>
|
|
858
|
-
)}
|
|
859
|
-
|
|
860
|
-
{occurrence?.isRecurringOccurrence && !isInvited && (
|
|
861
|
-
<fieldset className="flex flex-col gap-1.5 text-sm mb-3">
|
|
862
|
-
<legend className="text-xs font-bold uppercase tracking-wide text-text-muted mb-1">Apply changes to</legend>
|
|
863
|
-
<label className="flex items-center gap-2">
|
|
864
|
-
<input
|
|
865
|
-
type="radio"
|
|
866
|
-
name="event-edit-scope"
|
|
867
|
-
checked={editScope === "occurrence"}
|
|
868
|
-
onChange={() => setEditScope("occurrence")}
|
|
869
|
-
/>
|
|
870
|
-
This event only
|
|
871
|
-
</label>
|
|
872
|
-
<label className="flex items-center gap-2">
|
|
873
|
-
<input
|
|
874
|
-
type="radio"
|
|
875
|
-
name="event-edit-scope"
|
|
876
|
-
checked={editScope === "series"}
|
|
877
|
-
onChange={() => setEditScope("series")}
|
|
878
|
-
/>
|
|
879
|
-
The entire series
|
|
880
|
-
</label>
|
|
881
|
-
</fieldset>
|
|
882
|
-
)}
|
|
883
|
-
|
|
884
|
-
</fieldset>
|
|
885
|
-
|
|
886
|
-
<div className="flex gap-3 mt-2">
|
|
887
|
-
{!isInvited && (
|
|
888
|
-
<Button type="submit" loading={saving} disabled={saving} className="!w-auto">
|
|
889
|
-
Save
|
|
890
|
-
</Button>
|
|
891
|
-
)}
|
|
892
|
-
<Button type="button" variant="secondary" className="!w-auto" onClick={onClose}>
|
|
893
|
-
Cancel
|
|
894
|
-
</Button>
|
|
895
|
-
{occurrence &&
|
|
896
|
-
(!occurrence.isRecurringOccurrence ? (
|
|
897
|
-
<Button
|
|
898
|
-
type="button"
|
|
899
|
-
variant="secondary"
|
|
900
|
-
className="!w-auto ml-auto text-danger"
|
|
901
|
-
disabled={saving}
|
|
902
|
-
onClick={() => handleDelete("series")}
|
|
903
|
-
>
|
|
904
|
-
Delete
|
|
905
|
-
</Button>
|
|
906
|
-
) : !confirmingDelete ? (
|
|
907
|
-
<Button
|
|
908
|
-
type="button"
|
|
909
|
-
variant="secondary"
|
|
910
|
-
className="!w-auto ml-auto text-danger"
|
|
911
|
-
disabled={saving}
|
|
912
|
-
onClick={() => setConfirmingDelete(true)}
|
|
913
|
-
>
|
|
914
|
-
Delete
|
|
915
|
-
</Button>
|
|
916
|
-
) : (
|
|
917
|
-
<div className="flex gap-2 ml-auto">
|
|
918
|
-
<Button
|
|
919
|
-
type="button"
|
|
920
|
-
variant="secondary"
|
|
921
|
-
className="!w-auto text-danger"
|
|
922
|
-
disabled={saving}
|
|
923
|
-
onClick={() => handleDelete("occurrence")}
|
|
924
|
-
>
|
|
925
|
-
Delete this event
|
|
926
|
-
</Button>
|
|
927
|
-
<Button
|
|
928
|
-
type="button"
|
|
929
|
-
variant="secondary"
|
|
930
|
-
className="!w-auto text-danger"
|
|
931
|
-
disabled={saving}
|
|
932
|
-
onClick={() => handleDelete("series")}
|
|
933
|
-
>
|
|
934
|
-
Delete series
|
|
935
|
-
</Button>
|
|
936
|
-
</div>
|
|
937
|
-
))}
|
|
938
|
-
</div>
|
|
939
|
-
</form>
|
|
940
|
-
</Modal>
|
|
150
|
+
<EventShell
|
|
151
|
+
variant={variant}
|
|
152
|
+
label={!occurrence ? "New event" : editing ? "Edit event" : "Event details"}
|
|
153
|
+
focusKey={isForm ? layout : "details"}
|
|
154
|
+
anchor={anchor}
|
|
155
|
+
width={width}
|
|
156
|
+
onClose={isForm ? leaveForm : onClose}
|
|
157
|
+
onBackdropPress={isForm ? () => !dirtyRef.current && leaveForm() : undefined}
|
|
158
|
+
>
|
|
159
|
+
{isForm ? (
|
|
160
|
+
<EventEditor
|
|
161
|
+
layout={layout}
|
|
162
|
+
onExpand={() => setExpanded(true)}
|
|
163
|
+
onCancel={leaveForm}
|
|
164
|
+
onSaved={onSaved}
|
|
165
|
+
onSyncWarning={() => setSyncWarning(true)}
|
|
166
|
+
dirtyRef={dirtyRef}
|
|
167
|
+
mailboxUid={mailboxUid}
|
|
168
|
+
folderUid={folderUid}
|
|
169
|
+
calendars={calendars}
|
|
170
|
+
mailboxOptions={mailboxOptions}
|
|
171
|
+
folderColors={folderColors}
|
|
172
|
+
organizerAddress={organizerAddress}
|
|
173
|
+
occurrence={occurrence}
|
|
174
|
+
initialStart={initialStart}
|
|
175
|
+
initialEnd={initialEnd}
|
|
176
|
+
initialAllDay={initialAllDay}
|
|
177
|
+
quickCreate={
|
|
178
|
+
occurrence
|
|
179
|
+
? undefined
|
|
180
|
+
: {
|
|
181
|
+
tab,
|
|
182
|
+
onTabChange: (next) => {
|
|
183
|
+
setTab(next);
|
|
184
|
+
setExpanded(false);
|
|
185
|
+
},
|
|
186
|
+
bookingHref,
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/>
|
|
190
|
+
) : (
|
|
191
|
+
<EventDetails
|
|
192
|
+
occurrence={occurrence}
|
|
193
|
+
isInvited={isInvited}
|
|
194
|
+
myResponse={canRespond ? myAttendee.responseStatus : undefined}
|
|
195
|
+
isOwnAddress={isOwnAddress}
|
|
196
|
+
calendarName={calendars?.find((cal) => cal.uid === occurrence.folderUid)?.name}
|
|
197
|
+
calendarColor={folderColors?.[occurrence.folderUid]}
|
|
198
|
+
onClose={onClose}
|
|
199
|
+
onModify={() => setEditing(true)}
|
|
200
|
+
onSaved={onSaved}
|
|
201
|
+
onDeleted={onDeleted}
|
|
202
|
+
/>
|
|
203
|
+
)}
|
|
204
|
+
</EventShell>
|
|
941
205
|
);
|
|
942
206
|
}
|