@remit/web-client 0.0.328 → 0.0.330
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/dist/src/components/calendar/CalendarEventEditor.d.ts +6 -0
- package/dist/src/components/calendar/CalendarEventEditor.js +371 -0
- package/dist/src/components/calendar/CalendarEventPopup.d.ts +10 -0
- package/dist/src/components/calendar/CalendarEventPopup.js +198 -0
- package/dist/src/components/calendar/CalendarLoadFailed.d.ts +8 -0
- package/dist/src/components/calendar/CalendarLoadFailed.js +11 -0
- package/dist/src/components/calendar/CalendarNavPane.d.ts +11 -0
- package/dist/src/components/calendar/CalendarNavPane.js +50 -0
- package/dist/src/components/calendar/CalendarQuickCreate.d.ts +22 -0
- package/dist/src/components/calendar/CalendarQuickCreate.js +204 -0
- package/dist/src/components/calendar/CalendarScreen.d.ts +11 -0
- package/dist/src/components/calendar/CalendarScreen.js +184 -0
- package/dist/src/components/calendar/CalendarSession.d.ts +24 -0
- package/dist/src/components/calendar/CalendarSession.js +12 -0
- package/dist/src/components/calendar/CalendarTaskPopup.d.ts +4 -0
- package/dist/src/components/calendar/CalendarTaskPopup.js +95 -0
- package/dist/src/components/calendar/CalendarWaiting.d.ts +3 -3
- package/dist/src/components/calendar/CalendarWaiting.js +5 -10
- package/dist/src/components/calendar/ChangeCalendarSuggestion.js +39 -5
- package/dist/src/components/calendar/EventMoves.d.ts +17 -0
- package/dist/src/components/calendar/EventMoves.js +103 -0
- package/dist/src/components/calendar/calendar-story-fixtures.js +8 -2
- package/dist/src/components/calendar/calendar-story-server.d.ts +2 -5
- package/dist/src/components/calendar/calendar-story-server.js +5 -6
- package/dist/src/components/compose/ComposeForm.js +1 -1
- package/dist/src/components/layout/AppFrame.d.ts +11 -0
- package/dist/src/components/layout/AppFrame.js +16 -0
- package/dist/src/components/mail/BulkRunProvider.js +1 -1
- package/dist/src/components/mail/MailSidebarAdapter.js +1 -1
- package/dist/src/components/mail/MessageActionMenu.js +1 -1
- package/dist/src/components/mail/MessageList.js +1 -1
- package/dist/src/components/mail/OutboxPane.js +1 -1
- package/dist/src/components/mail/ThreadListInteraction.js +1 -1
- package/dist/src/components/settings/CalendarDefaultSenderCard.d.ts +2 -0
- package/dist/src/components/settings/CalendarDefaultSenderCard.js +16 -0
- package/dist/src/components/ui/ErrorBannerProvider.d.ts +0 -23
- package/dist/src/components/ui/ErrorBannerProvider.js +3 -39
- package/dist/src/components/ui/SignedOutOverlay.d.ts +6 -0
- package/dist/src/components/ui/SignedOutOverlay.js +29 -0
- package/dist/src/components/ui/error-banner-context.d.ts +23 -0
- package/dist/src/components/ui/error-banner-context.js +38 -0
- package/dist/src/hooks/calendar/draft-session.d.ts +78 -0
- package/dist/src/hooks/calendar/draft-session.js +110 -0
- package/dist/src/hooks/calendar/draft.d.ts +8 -2
- package/dist/src/hooks/calendar/draft.js +17 -4
- package/dist/src/hooks/calendar/index.d.ts +6 -3
- package/dist/src/hooks/calendar/index.js +5 -2
- package/dist/src/hooks/calendar/instance.d.ts +2 -1
- package/dist/src/hooks/calendar/instance.js +14 -1
- package/dist/src/hooks/calendar/useCalendarJump.d.ts +0 -2
- package/dist/src/hooks/calendar/useCalendarJump.js +3 -5
- package/dist/src/hooks/calendar/useCalendarScheduling.d.ts +33 -0
- package/dist/src/hooks/calendar/useCalendarScheduling.js +118 -0
- package/dist/src/hooks/calendar/useCalendarTasks.d.ts +53 -0
- package/dist/src/hooks/calendar/useCalendarTasks.js +105 -0
- package/dist/src/hooks/calendar/useCalendarWrites.d.ts +18 -2
- package/dist/src/hooks/calendar/useCalendarWrites.js +19 -6
- package/dist/src/hooks/calendar/useCalendars.d.ts +3 -0
- package/dist/src/hooks/calendar/useCalendars.js +13 -5
- package/dist/src/hooks/calendar/useDraftSession.d.ts +32 -0
- package/dist/src/hooks/calendar/useDraftSession.js +106 -0
- package/dist/src/hooks/calendar/useMoveEvent.d.ts +4 -0
- package/dist/src/hooks/calendar/useMoveEvent.js +62 -0
- package/dist/src/hooks/use-system-update.js +3 -5
- package/dist/src/hooks/useApplyLabel.js +1 -1
- package/dist/src/hooks/useCalendarData.d.ts +9 -2
- package/dist/src/hooks/useCalendarData.js +22 -5
- package/dist/src/hooks/useCalendarSidePane.d.ts +14 -0
- package/dist/src/hooks/useCalendarSidePane.js +30 -0
- package/dist/src/hooks/useComposeLanguages.js +1 -1
- package/dist/src/hooks/useDeleteMessages.js +1 -1
- package/dist/src/hooks/useEmptyTrash.js +1 -1
- package/dist/src/hooks/useEscalatedActions.js +1 -1
- package/dist/src/hooks/useFilters.d.ts +1 -1
- package/dist/src/hooks/useLabels.d.ts +1 -1
- package/dist/src/hooks/useMarkAsRead.js +1 -1
- package/dist/src/hooks/useMoveMessages.js +1 -1
- package/dist/src/hooks/useRefreshControl.js +4 -8
- package/dist/src/hooks/useReportSpam.js +1 -1
- package/dist/src/hooks/useSignature.js +1 -1
- package/dist/src/hooks/useStaleAccountSync.js +4 -4
- package/dist/src/hooks/useStarredThreads.d.ts +1 -1
- package/dist/src/hooks/useToggleStar.js +1 -1
- package/dist/src/hooks/useToggleTrusted.js +1 -1
- package/dist/src/hooks/useTriggerSync.d.ts +1 -1
- package/dist/src/hooks/useUpdateAddressFlags.js +1 -1
- package/dist/src/hooks/useWarningsAttention.js +1 -3
- package/dist/src/lib/calendar-route.d.ts +6 -0
- package/dist/src/lib/calendar-route.js +14 -0
- package/dist/src/lib/calendar-side-pane-pref.d.ts +14 -0
- package/dist/src/lib/calendar-side-pane-pref.js +27 -0
- package/dist/src/lib/error-classifier.d.ts +5 -30
- package/dist/src/lib/error-classifier.js +7 -10
- package/dist/src/lib/escalate.d.ts +6 -0
- package/dist/src/lib/escalate.js +16 -0
- package/dist/src/lib/intelligence-pref.js +3 -2
- package/dist/src/lib/new-event-range.d.ts +26 -0
- package/dist/src/lib/new-event-range.js +69 -0
- package/dist/src/lib/query-error-handler.d.ts +2 -6
- package/dist/src/lib/query-error-handler.js +5 -14
- package/dist/src/lib/signed-out.d.ts +13 -0
- package/dist/src/lib/signed-out.js +28 -0
- package/dist/src/routeTree.gen.d.ts +98 -19
- package/dist/src/routeTree.gen.js +32 -1
- package/dist/src/routes/__root.js +8 -2
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.js +11 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.js +12 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.js +4 -13
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.js +14 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.js +4 -4
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/index.d.ts +1 -6
- package/dist/src/routes/calendar/$view.$date/index.js +3 -10
- package/dist/src/routes/calendar/$view.$date/new.d.ts +6 -2
- package/dist/src/routes/calendar/$view.$date/new.js +8 -13
- package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.js +2 -2
- package/dist/src/routes/calendar/$view.$date/task.$calendarTaskId.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/task.$calendarTaskId.js +16 -0
- package/dist/src/routes/calendar/$view.$date.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date.js +14 -50
- package/dist/src/routes/calendar/index.d.ts +1 -1
- package/dist/src/routes/calendar/index.js +2 -1
- package/dist/src/routes/calendar.d.ts +4 -9
- package/dist/src/routes/calendar.js +10 -35
- package/dist/src/routes/mail/index.d.ts +1 -1
- package/dist/src/routes/mail/index.js +7 -2
- package/dist/src/routes/mail.js +6 -5
- package/dist/src/routes/settings/calendars.js +2 -1
- package/dist/src/routing/app-switch.d.ts +11 -0
- package/dist/src/routing/app-switch.js +35 -0
- package/dist/src/routing/calendar.d.ts +45 -4
- package/dist/src/routing/calendar.js +135 -13
- package/dist/src/routing/fragment.d.ts +1 -1
- package/dist/src/routing/fragment.js +6 -1
- package/dist/src/routing/index.d.ts +2 -1
- package/dist/src/routing/index.js +2 -1
- package/package.json +2 -2
- package/dist/src/components/calendar/CalendarComposePane.d.ts +0 -49
- package/dist/src/components/calendar/CalendarComposePane.js +0 -8
- package/dist/src/components/calendar/CalendarComposeSeed.d.ts +0 -7
- package/dist/src/components/calendar/CalendarComposeSeed.js +0 -19
- package/dist/src/components/calendar/CalendarEventPane.d.ts +0 -48
- package/dist/src/components/calendar/CalendarEventPane.js +0 -48
- package/dist/src/components/calendar/CalendarShell.d.ts +0 -43
- package/dist/src/components/calendar/CalendarShell.js +0 -35
- package/dist/src/components/calendar/CalendarViewPlaceholder.d.ts +0 -1
- package/dist/src/components/calendar/CalendarViewPlaceholder.js +0 -5
- package/dist/src/components/calendar/CalendarWorkspace.d.ts +0 -49
- package/dist/src/components/calendar/CalendarWorkspace.js +0 -65
- package/dist/src/components/calendar/OpenCalendarEvent.d.ts +0 -20
- package/dist/src/components/calendar/OpenCalendarEvent.js +0 -169
- package/dist/src/components/calendar/WriteCalendarEvent.d.ts +0 -13
- package/dist/src/components/calendar/WriteCalendarEvent.js +0 -59
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function CalendarNewEventSidebar(): import("react").JSX.Element | null;
|
|
2
|
+
export interface CalendarEditEventSidebarProps {
|
|
3
|
+
calendarObjectId: string;
|
|
4
|
+
recurrenceId?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function CalendarEditEventSidebar({ calendarObjectId, recurrenceId, }: CalendarEditEventSidebarProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CalendarEventGone, CalendarEventSidebar, ConfirmDialog, RecurrenceScopePrompt, storedGuest, } from "@remit/ui";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { anchorZoneFor, calendarInstanceId, createInputFromDraft, deviceTimeZone, draftFromEvent, isoOnClock, moveRule, patchFromDrafts, rruleFromIcalData, storedAnchorZone, textFromIcalData, textFromRrule, UNZONED_CALENDAR, useCalendarEvent, useCalendarSenders, useCalendars, useCalendarWrites, useGuestSuggestions, } from "../../hooks/calendar";
|
|
5
|
+
import { useCalendarData } from "../../hooks/useCalendarData";
|
|
6
|
+
import { formatEventWhen } from "../../lib/calendar-format";
|
|
7
|
+
import { calendarEventReportHref } from "../../lib/calendar-report";
|
|
8
|
+
import { rangeFromSearch, searchFromRange } from "../../lib/new-event-range";
|
|
9
|
+
import { useBackCloses, useCalendarAddress, useCalendarNavigation, useNewEventBounds, } from "../../routing";
|
|
10
|
+
import { eventDraftOf } from "./CalendarQuickCreate";
|
|
11
|
+
import { useCalendarSession } from "./CalendarSession";
|
|
12
|
+
const CONFLICT = "This calendar changed while you were writing. Close the form and try again.";
|
|
13
|
+
const TIME_ZONES = Intl.supportedValuesOf("timeZone");
|
|
14
|
+
const sameRange = (a, b) => a.date === b.date &&
|
|
15
|
+
a.endDate === b.endDate &&
|
|
16
|
+
a.startTime === b.startTime &&
|
|
17
|
+
a.endTime === b.endTime &&
|
|
18
|
+
a.allDay === b.allDay;
|
|
19
|
+
const rangeOfDraft = (draft) => ({
|
|
20
|
+
date: draft.date,
|
|
21
|
+
endDate: draft.endDate,
|
|
22
|
+
startTime: draft.allDay ? "" : draft.startTime,
|
|
23
|
+
endTime: draft.allDay ? "" : draft.endTime,
|
|
24
|
+
allDay: draft.allDay,
|
|
25
|
+
});
|
|
26
|
+
const transparencyOf = (busy) => busy ? "Opaque" : "Transparent";
|
|
27
|
+
/** Focus carried from quick-create, or the title. */
|
|
28
|
+
function useFirstFocus(titleRef, ready) {
|
|
29
|
+
const { carriedFocus } = useCalendarSession();
|
|
30
|
+
const focused = useRef(false);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!ready || focused.current)
|
|
33
|
+
return;
|
|
34
|
+
focused.current = true;
|
|
35
|
+
const label = carriedFocus.current;
|
|
36
|
+
carriedFocus.current = "";
|
|
37
|
+
const carried = label === ""
|
|
38
|
+
? null
|
|
39
|
+
: document.querySelector(`[data-event-sidebar] [aria-label="${CSS.escape(label)}"]`);
|
|
40
|
+
(carried ?? titleRef.current)?.focus();
|
|
41
|
+
}, [carriedFocus, titleRef, ready]);
|
|
42
|
+
}
|
|
43
|
+
/** Cancel, Close and Esc: a touched draft asks before it is thrown away. */
|
|
44
|
+
function useSidebarClose(touched) {
|
|
45
|
+
const { requestClose } = useCalendarSession();
|
|
46
|
+
const { closeToView } = useCalendarNavigation();
|
|
47
|
+
const [confirming, setConfirming] = useState(false);
|
|
48
|
+
const discarding = useRef(false);
|
|
49
|
+
useBackCloses(touched && !confirming, () => {
|
|
50
|
+
if (discarding.current)
|
|
51
|
+
return false;
|
|
52
|
+
setConfirming(true);
|
|
53
|
+
return true;
|
|
54
|
+
});
|
|
55
|
+
const close = () => {
|
|
56
|
+
if (touched) {
|
|
57
|
+
setConfirming(true);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
closeToView();
|
|
61
|
+
};
|
|
62
|
+
const closeRef = useRef(close);
|
|
63
|
+
closeRef.current = close;
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
requestClose.current = () => closeRef.current();
|
|
66
|
+
return () => {
|
|
67
|
+
requestClose.current = null;
|
|
68
|
+
};
|
|
69
|
+
}, [requestClose]);
|
|
70
|
+
const confirm = (_jsx(ConfirmDialog, { isOpen: confirming, title: "Discard draft?", description: "Your event has unsaved changes. Are you sure you want to discard them?", confirmLabel: "Discard", cancelLabel: "Keep editing", destructive: true, onConfirm: () => {
|
|
71
|
+
discarding.current = true;
|
|
72
|
+
setConfirming(false);
|
|
73
|
+
closeToView();
|
|
74
|
+
}, onCancel: () => setConfirming(false) }));
|
|
75
|
+
const leave = () => {
|
|
76
|
+
discarding.current = true;
|
|
77
|
+
closeToView();
|
|
78
|
+
};
|
|
79
|
+
return { close, confirm, leave };
|
|
80
|
+
}
|
|
81
|
+
export function CalendarNewEventSidebar() {
|
|
82
|
+
const { session, dispatch, focusSaved } = useCalendarSession();
|
|
83
|
+
const { date } = useCalendarAddress();
|
|
84
|
+
const bounds = useNewEventBounds();
|
|
85
|
+
const { setNewEventBounds } = useCalendarNavigation();
|
|
86
|
+
const { calendars: all, defaultCalendarId, timeZoneByCalendarId, } = useCalendars();
|
|
87
|
+
const calendars = all.filter((calendar) => !calendar.readOnly);
|
|
88
|
+
const { createEvent, isWriting } = useCalendarWrites();
|
|
89
|
+
const { senders, defaultSenderId } = useCalendarSenders();
|
|
90
|
+
const [pickedSender, setPickedSender] = useState();
|
|
91
|
+
const [guestQuery, setGuestQuery] = useState("");
|
|
92
|
+
const guestSuggestions = useGuestSuggestions(guestQuery);
|
|
93
|
+
const { trackSends } = useCalendarSession();
|
|
94
|
+
const titleRef = useRef(null);
|
|
95
|
+
const failureRef = useRef(null);
|
|
96
|
+
const clock = deviceTimeZone();
|
|
97
|
+
const [extras, setExtras] = useState({
|
|
98
|
+
notes: "",
|
|
99
|
+
repeat: "",
|
|
100
|
+
timeZone: clock,
|
|
101
|
+
busy: true,
|
|
102
|
+
});
|
|
103
|
+
const [problem, setProblem] = useState("");
|
|
104
|
+
const [failure, setFailure] = useState();
|
|
105
|
+
const [initial] = useState(() => session.mode === "sidebar" ? session.draft : undefined);
|
|
106
|
+
const urlRange = rangeFromSearch(bounds?.start, bounds?.end, date, clock);
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (session.mode === "sidebar")
|
|
109
|
+
return;
|
|
110
|
+
dispatch({ type: "sidebar-range", range: urlRange });
|
|
111
|
+
}, [session.mode, dispatch, urlRange]);
|
|
112
|
+
const draft = session.mode === "sidebar" ? session.draft : undefined;
|
|
113
|
+
const range = draft?.range;
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!range)
|
|
116
|
+
return;
|
|
117
|
+
const written = searchFromRange(range, clock);
|
|
118
|
+
if (written.start === bounds?.start && written.end === bounds?.end)
|
|
119
|
+
return;
|
|
120
|
+
setNewEventBounds(written);
|
|
121
|
+
}, [range, bounds, clock, setNewEventBounds]);
|
|
122
|
+
useFirstFocus(titleRef, session.mode === "sidebar");
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (failure)
|
|
125
|
+
failureRef.current?.focus();
|
|
126
|
+
}, [failure]);
|
|
127
|
+
const fallbackCalendar = calendars.find((calendar) => calendar.id === defaultCalendarId)?.id ??
|
|
128
|
+
calendars[0]?.id ??
|
|
129
|
+
"";
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (draft?.calendarId !== "" || fallbackCalendar === "")
|
|
132
|
+
return;
|
|
133
|
+
dispatch({
|
|
134
|
+
type: "change",
|
|
135
|
+
draft: { ...draft, calendarId: fallbackCalendar },
|
|
136
|
+
});
|
|
137
|
+
}, [draft, fallbackCalendar, dispatch]);
|
|
138
|
+
const touched = draft !== undefined &&
|
|
139
|
+
(extras.notes !== "" ||
|
|
140
|
+
extras.repeat !== "" ||
|
|
141
|
+
!extras.busy ||
|
|
142
|
+
draft.title !== (initial?.title ?? "") ||
|
|
143
|
+
draft.location !== (initial?.location ?? "") ||
|
|
144
|
+
draft.guests.length !== (initial?.guests.length ?? 0));
|
|
145
|
+
const { close, confirm, leave } = useSidebarClose(touched);
|
|
146
|
+
if (!draft)
|
|
147
|
+
return null;
|
|
148
|
+
const senderId = pickedSender ??
|
|
149
|
+
defaultSenderId ??
|
|
150
|
+
calendars.find((calendar) => calendar.id === draft.calendarId)?.accountId ??
|
|
151
|
+
"";
|
|
152
|
+
const eventDraft = {
|
|
153
|
+
...eventDraftOf(draft),
|
|
154
|
+
notes: extras.notes,
|
|
155
|
+
repeat: extras.repeat,
|
|
156
|
+
};
|
|
157
|
+
const save = () => {
|
|
158
|
+
const zone = extras.timeZone;
|
|
159
|
+
const built = createInputFromDraft(eventDraft, {
|
|
160
|
+
clock: zone,
|
|
161
|
+
anchor: zone !== clock
|
|
162
|
+
? zone
|
|
163
|
+
: anchorZoneFor(timeZoneByCalendarId[draft.calendarId] ?? UNZONED_CALENDAR),
|
|
164
|
+
}, senderId);
|
|
165
|
+
if (!built.ok) {
|
|
166
|
+
setProblem(built.problem);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
setProblem("");
|
|
170
|
+
setFailure(undefined);
|
|
171
|
+
void createEvent({
|
|
172
|
+
...built.input,
|
|
173
|
+
transparency: transparencyOf(extras.busy),
|
|
174
|
+
}).then((outcome) => {
|
|
175
|
+
if (outcome.kind === "created") {
|
|
176
|
+
dispatch({ type: "saved" });
|
|
177
|
+
trackSends(outcome.sends);
|
|
178
|
+
focusSaved(outcome.calendarObjectId);
|
|
179
|
+
leave();
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const text = outcome.kind === "conflict"
|
|
183
|
+
? CONFLICT
|
|
184
|
+
: `Couldn't save this event: ${outcome.message}`;
|
|
185
|
+
setFailure({
|
|
186
|
+
text,
|
|
187
|
+
reportHref: calendarEventReportHref(text),
|
|
188
|
+
onRetry: save,
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
return (_jsxs(_Fragment, { children: [_jsx(CalendarEventSidebar, { heading: "New event", draft: eventDraft, onChange: (next) => {
|
|
193
|
+
dispatch({
|
|
194
|
+
type: "change",
|
|
195
|
+
draft: {
|
|
196
|
+
range: rangeOfDraft(next),
|
|
197
|
+
title: next.title,
|
|
198
|
+
location: next.location,
|
|
199
|
+
calendarId: next.calendarId,
|
|
200
|
+
guests: next.guests,
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
setExtras((current) => ({
|
|
204
|
+
...current,
|
|
205
|
+
notes: next.notes,
|
|
206
|
+
repeat: next.repeat,
|
|
207
|
+
}));
|
|
208
|
+
}, calendars: calendars, calendarEditable: true, repeatEditable: true, timeZone: extras.timeZone, timeZones: TIME_ZONES, onTimeZone: (timeZone) => setExtras((current) => ({ ...current, timeZone })), busy: extras.busy, onBusy: (busy) => setExtras((current) => ({ ...current, busy })), guests: {
|
|
209
|
+
suggestions: guestSuggestions,
|
|
210
|
+
onQuery: setGuestQuery,
|
|
211
|
+
senders,
|
|
212
|
+
sender: senderId,
|
|
213
|
+
onSender: setPickedSender,
|
|
214
|
+
senderEditable: true,
|
|
215
|
+
}, onSave: save, onCancel: close, saving: isWriting, problem: problem, failure: failure, failureRef: failureRef, titleRef: titleRef }), confirm] }));
|
|
216
|
+
}
|
|
217
|
+
export function CalendarEditEventSidebar({ calendarObjectId, recurrenceId, }) {
|
|
218
|
+
const { session, dispatch, focusSaved } = useCalendarSession();
|
|
219
|
+
const { view, date, calendarIds } = useCalendarAddress();
|
|
220
|
+
const { events, isLoading, freeIds } = useCalendarData({
|
|
221
|
+
view,
|
|
222
|
+
date,
|
|
223
|
+
calendarIds,
|
|
224
|
+
});
|
|
225
|
+
const { calendars, timeZoneByCalendarId } = useCalendars();
|
|
226
|
+
const { closeToView } = useCalendarNavigation();
|
|
227
|
+
const { updateEvent, isWriting } = useCalendarWrites();
|
|
228
|
+
const { senders, defaultSenderId } = useCalendarSenders();
|
|
229
|
+
const [pickedSender, setPickedSender] = useState();
|
|
230
|
+
const [guestQuery, setGuestQuery] = useState("");
|
|
231
|
+
const guestSuggestions = useGuestSuggestions(guestQuery);
|
|
232
|
+
const { trackSends } = useCalendarSession();
|
|
233
|
+
const titleRef = useRef(null);
|
|
234
|
+
const failureRef = useRef(null);
|
|
235
|
+
const goneId = useId();
|
|
236
|
+
const instanceId = calendarInstanceId(calendarObjectId, recurrenceId ?? "");
|
|
237
|
+
const event = events.find((candidate) => candidate.id === instanceId);
|
|
238
|
+
const { resource } = useCalendarEvent(calendarObjectId, event?.calendarId ?? "");
|
|
239
|
+
const [before, setBefore] = useState();
|
|
240
|
+
const [after, setAfter] = useState();
|
|
241
|
+
const [busy, setBusy] = useState(true);
|
|
242
|
+
const [timeZone, setTimeZone] = useState(deviceTimeZone());
|
|
243
|
+
const [asking, setAsking] = useState(false);
|
|
244
|
+
const [problem, setProblem] = useState("");
|
|
245
|
+
const [failure, setFailure] = useState();
|
|
246
|
+
useEffect(() => {
|
|
247
|
+
if (before || !event || !resource)
|
|
248
|
+
return;
|
|
249
|
+
const rrule = rruleFromIcalData(resource.icalData);
|
|
250
|
+
const anchor = storedAnchorZone(resource.icalData, timeZoneByCalendarId[event.calendarId] ?? UNZONED_CALENDAR);
|
|
251
|
+
const startTime = event.allDay ? "" : event.start.slice(11, 16);
|
|
252
|
+
const shownRule = event.allDay
|
|
253
|
+
? rrule
|
|
254
|
+
: moveRule(rrule, isoOnClock(event.start, anchor === "" ? "UTC" : anchor).slice(0, 10), event.start.slice(0, 10));
|
|
255
|
+
const stored = textFromIcalData(resource.icalData);
|
|
256
|
+
const draft = draftFromEvent(event, {
|
|
257
|
+
repeat: rrule === "" ? "" : (textFromRrule(shownRule, startTime) ?? "Repeats"),
|
|
258
|
+
location: stored.location,
|
|
259
|
+
notes: stored.description,
|
|
260
|
+
guests: resource.attendees
|
|
261
|
+
.filter((attendee) => attendee.role === "Guest")
|
|
262
|
+
.map((attendee) => storedGuest(attendee.email, attendee.displayName)),
|
|
263
|
+
});
|
|
264
|
+
const isBusy = !freeIds.has(event.id);
|
|
265
|
+
setBefore({ draft, busy: isBusy, anchor });
|
|
266
|
+
setAfter(draft);
|
|
267
|
+
setBusy(isBusy);
|
|
268
|
+
dispatch({ type: "sidebar-range", range: rangeOfDraft(draft) });
|
|
269
|
+
}, [before, event, resource, freeIds, timeZoneByCalendarId, dispatch]);
|
|
270
|
+
const sessionRange = session.mode === "sidebar" ? session.draft.range : undefined;
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
if (!sessionRange || !after)
|
|
273
|
+
return;
|
|
274
|
+
if (sameRange(sessionRange, rangeOfDraft(after)))
|
|
275
|
+
return;
|
|
276
|
+
setAfter({
|
|
277
|
+
...after,
|
|
278
|
+
date: sessionRange.date,
|
|
279
|
+
endDate: sessionRange.endDate,
|
|
280
|
+
startTime: sessionRange.startTime,
|
|
281
|
+
endTime: sessionRange.endTime,
|
|
282
|
+
allDay: sessionRange.allDay,
|
|
283
|
+
});
|
|
284
|
+
}, [sessionRange, after]);
|
|
285
|
+
const loaded = after !== undefined;
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
if (loaded)
|
|
288
|
+
titleRef.current?.focus();
|
|
289
|
+
}, [loaded]);
|
|
290
|
+
useEffect(() => {
|
|
291
|
+
if (failure)
|
|
292
|
+
failureRef.current?.focus();
|
|
293
|
+
}, [failure]);
|
|
294
|
+
const touched = before !== undefined &&
|
|
295
|
+
after !== undefined &&
|
|
296
|
+
(JSON.stringify(before.draft) !== JSON.stringify(after) ||
|
|
297
|
+
busy !== before.busy);
|
|
298
|
+
const { close, confirm, leave } = useSidebarClose(touched);
|
|
299
|
+
const gone = !isLoading && event === undefined;
|
|
300
|
+
if (gone)
|
|
301
|
+
return (_jsx("section", { className: "flex h-full flex-col bg-surface", "aria-labelledby": goneId, children: _jsx(CalendarEventGone, { headingId: goneId, onClose: closeToView }) }));
|
|
302
|
+
if (!event || !before || !after)
|
|
303
|
+
return null;
|
|
304
|
+
const calendar = calendars.find((candidate) => candidate.id === event.calendarId);
|
|
305
|
+
const repeats = event.seriesId !== "" && recurrenceId !== undefined;
|
|
306
|
+
const organizer = resource?.organizer ?? "";
|
|
307
|
+
const guestsEditable = resource !== undefined &&
|
|
308
|
+
(resource.participation === "Organizer" ||
|
|
309
|
+
(resource.participation === "Unscheduled" && organizer === ""));
|
|
310
|
+
const organizerSender = senders.find((sender) => sender.email === organizer)?.accountId;
|
|
311
|
+
const senderId = organizerSender ??
|
|
312
|
+
pickedSender ??
|
|
313
|
+
defaultSenderId ??
|
|
314
|
+
calendar?.accountId ??
|
|
315
|
+
"";
|
|
316
|
+
const save = (scope) => {
|
|
317
|
+
setAsking(false);
|
|
318
|
+
const patch = patchFromDrafts(before.draft, after, {
|
|
319
|
+
clock: timeZone,
|
|
320
|
+
anchor: timeZone !== deviceTimeZone() ? timeZone : before.anchor,
|
|
321
|
+
});
|
|
322
|
+
if (!patch.ok) {
|
|
323
|
+
setProblem(patch.problem);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
setProblem("");
|
|
327
|
+
setFailure(undefined);
|
|
328
|
+
const withBusy = busy !== before.busy
|
|
329
|
+
? { ...patch.patch, transparency: transparencyOf(busy) }
|
|
330
|
+
: patch.patch;
|
|
331
|
+
const body = withBusy.attendees !== undefined && organizer === "" && senderId !== ""
|
|
332
|
+
? { ...withBusy, organizerAccountId: senderId }
|
|
333
|
+
: withBusy;
|
|
334
|
+
void updateEvent({
|
|
335
|
+
calendarObjectId,
|
|
336
|
+
calendarId: event.calendarId,
|
|
337
|
+
recurrenceId: recurrenceId ?? "",
|
|
338
|
+
scope,
|
|
339
|
+
etag: resource?.etag ?? "",
|
|
340
|
+
}, body).then((outcome) => {
|
|
341
|
+
if (outcome.kind === "written") {
|
|
342
|
+
dispatch({ type: "saved" });
|
|
343
|
+
trackSends(outcome.sends);
|
|
344
|
+
focusSaved(calendarObjectId);
|
|
345
|
+
leave();
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const text = outcome.kind === "conflict"
|
|
349
|
+
? CONFLICT
|
|
350
|
+
: `Couldn't save this event: ${outcome.message}`;
|
|
351
|
+
setFailure({
|
|
352
|
+
text,
|
|
353
|
+
reportHref: calendarEventReportHref(text),
|
|
354
|
+
onRetry: () => save(scope),
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
return (_jsxs(_Fragment, { children: [_jsx(CalendarEventSidebar, { heading: "Edit event", draft: after, onChange: (next) => {
|
|
359
|
+
setAfter(next);
|
|
360
|
+
dispatch({ type: "sidebar-range", range: rangeOfDraft(next) });
|
|
361
|
+
}, calendars: calendar ? [calendar] : [], calendarEditable: false, repeatEditable: !repeats, timeZone: timeZone, timeZones: TIME_ZONES, onTimeZone: setTimeZone, busy: busy, onBusy: setBusy, guests: guestsEditable
|
|
362
|
+
? {
|
|
363
|
+
suggestions: guestSuggestions,
|
|
364
|
+
onQuery: setGuestQuery,
|
|
365
|
+
senders,
|
|
366
|
+
sender: senderId,
|
|
367
|
+
onSender: setPickedSender,
|
|
368
|
+
senderEditable: organizer === "",
|
|
369
|
+
}
|
|
370
|
+
: undefined, onSave: () => (repeats ? setAsking(true) : save(undefined)), onCancel: close, saving: isWriting, problem: problem, failure: failure, failureRef: failureRef, titleRef: titleRef, children: asking && (_jsx(RecurrenceScopePrompt, { title: event.title, ruleText: after.repeat === "" ? "It repeats" : after.repeat, instanceText: formatEventWhen(event), onChoose: save, onCancel: () => setAsking(false) })) }), confirm] }));
|
|
371
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface CalendarEventPopupProps {
|
|
2
|
+
calendarObjectId: string;
|
|
3
|
+
/** One occurrence of a series, absent on the series itself. */
|
|
4
|
+
recurrenceId?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The event the address names, in a popup beside its chip. It is a
|
|
8
|
+
* navigation, so Back closes it; Esc, Close and a click outside go back too.
|
|
9
|
+
*/
|
|
10
|
+
export declare function CalendarEventPopup({ calendarObjectId, recurrenceId, }: CalendarEventPopupProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { CalendarEventGone, CalendarEventGuests, CalendarEventPopupCard, CalendarPopover, CalendarReplyRow, ConfirmDialog, RecurrenceScopePrompt, } from "@remit/ui";
|
|
3
|
+
import { Navigate } from "@tanstack/react-router";
|
|
4
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
5
|
+
import { calendarInstanceId, rsvpOfParticipation, seriesOccurrenceOf, textFromIcalData, useCalendarEvent, useCalendarJump, useCalendars, useCalendarWrites, } from "../../hooks/calendar";
|
|
6
|
+
import { useCalendarData } from "../../hooks/useCalendarData";
|
|
7
|
+
import { formatEventWhen } from "../../lib/calendar-format";
|
|
8
|
+
import { calendarEventReportHref } from "../../lib/calendar-report";
|
|
9
|
+
import { useCalendarAddress, useCalendarNavigation } from "../../routing";
|
|
10
|
+
import { useCalendarSession } from "./CalendarSession";
|
|
11
|
+
const ATTENDEE_RSVP = {
|
|
12
|
+
Accepted: "accepted",
|
|
13
|
+
Declined: "declined",
|
|
14
|
+
Tentative: "tentative",
|
|
15
|
+
NeedsAction: "noReply",
|
|
16
|
+
};
|
|
17
|
+
const toAttendee = (attendee) => ({
|
|
18
|
+
name: attendee.displayName,
|
|
19
|
+
email: attendee.email,
|
|
20
|
+
rsvp: ATTENDEE_RSVP[attendee.status],
|
|
21
|
+
role: attendee.role === "Organizer" ? "organizer" : "attendee",
|
|
22
|
+
});
|
|
23
|
+
const ANSWER_OF = {
|
|
24
|
+
accepted: "Accepted",
|
|
25
|
+
declined: "Declined",
|
|
26
|
+
tentative: "Tentative",
|
|
27
|
+
};
|
|
28
|
+
const CONFLICT = "This calendar changed while you were writing.";
|
|
29
|
+
const failureText = (outcome) => outcome.kind === "conflict"
|
|
30
|
+
? `${CONFLICT} Close the popup and open the event again.`
|
|
31
|
+
: outcome.kind === "refused"
|
|
32
|
+
? `Couldn't delete this event: ${outcome.message}`
|
|
33
|
+
: "";
|
|
34
|
+
/**
|
|
35
|
+
* The event the address names, in a popup beside its chip. It is a
|
|
36
|
+
* navigation, so Back closes it; Esc, Close and a click outside go back too.
|
|
37
|
+
*/
|
|
38
|
+
export function CalendarEventPopup({ calendarObjectId, recurrenceId, }) {
|
|
39
|
+
const { view, date, calendarIds } = useCalendarAddress();
|
|
40
|
+
const { events, isLoading, freeIds } = useCalendarData({
|
|
41
|
+
view,
|
|
42
|
+
date,
|
|
43
|
+
calendarIds,
|
|
44
|
+
});
|
|
45
|
+
const { calendars } = useCalendars();
|
|
46
|
+
const { closeToView, openEditor } = useCalendarNavigation();
|
|
47
|
+
const { deleteEvent, updateEvent, isWriting } = useCalendarWrites();
|
|
48
|
+
const calendarSession = useCalendarSession();
|
|
49
|
+
const [answering, setAnswering] = useState();
|
|
50
|
+
const [replyFailure, setReplyFailure] = useState();
|
|
51
|
+
const headingId = useId();
|
|
52
|
+
const headingRef = useRef(null);
|
|
53
|
+
const closeRef = useRef(null);
|
|
54
|
+
const failureRef = useRef(null);
|
|
55
|
+
const [asking, setAsking] = useState(false);
|
|
56
|
+
const [confirmingDelete, setConfirmingDelete] = useState(false);
|
|
57
|
+
const [failure, setFailure] = useState(undefined);
|
|
58
|
+
const [anchor, setAnchor] = useState(null);
|
|
59
|
+
const instanceId = calendarInstanceId(calendarObjectId, recurrenceId ?? "");
|
|
60
|
+
const event = events.find((candidate) => candidate.id === instanceId);
|
|
61
|
+
const seriesOnly = recurrenceId === undefined && event === undefined;
|
|
62
|
+
const occurrence = seriesOnly
|
|
63
|
+
? seriesOccurrenceOf(events, calendarObjectId, new Date().toISOString())
|
|
64
|
+
: undefined;
|
|
65
|
+
const search = useCalendarJump(calendarObjectId, event === undefined && !isLoading && occurrence === undefined);
|
|
66
|
+
const calendar = calendars.find((candidate) => candidate.id === event?.calendarId);
|
|
67
|
+
const { resource } = useCalendarEvent(calendarObjectId, event?.calendarId ?? "");
|
|
68
|
+
const stored = resource ? textFromIcalData(resource.icalData) : undefined;
|
|
69
|
+
const writable = event !== undefined && resource !== undefined && !calendar?.readOnly;
|
|
70
|
+
const repeats = event !== undefined && event.seriesId !== "";
|
|
71
|
+
useLayoutEffect(() => {
|
|
72
|
+
setAnchor(event
|
|
73
|
+
? document.querySelector(`[data-event-id="${CSS.escape(event.id)}"]`)
|
|
74
|
+
: null);
|
|
75
|
+
}, [event]);
|
|
76
|
+
const gone = search.kind === "Deleted" || search.kind === "NoOccurrenceFound";
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (gone)
|
|
79
|
+
closeRef.current?.focus();
|
|
80
|
+
else if (event)
|
|
81
|
+
headingRef.current?.focus();
|
|
82
|
+
}, [gone, event]);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (failure)
|
|
85
|
+
failureRef.current?.focus();
|
|
86
|
+
}, [failure]);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const chipSelector = `[data-event-id="${CSS.escape(instanceId)}"]`;
|
|
89
|
+
return () => {
|
|
90
|
+
document.querySelector(chipSelector)?.focus();
|
|
91
|
+
};
|
|
92
|
+
}, [instanceId]);
|
|
93
|
+
const write = (scope) => ({
|
|
94
|
+
calendarObjectId,
|
|
95
|
+
calendarId: event?.calendarId ?? "",
|
|
96
|
+
recurrenceId: recurrenceId ?? "",
|
|
97
|
+
scope,
|
|
98
|
+
etag: resource?.etag ?? "",
|
|
99
|
+
});
|
|
100
|
+
const guestNames = (resource?.attendees ?? [])
|
|
101
|
+
.filter((attendee) => attendee.role === "Guest")
|
|
102
|
+
.map((attendee) => attendee.displayName === "" ? attendee.email : attendee.displayName);
|
|
103
|
+
const askDelete = () => {
|
|
104
|
+
if (guestNames.length > 0) {
|
|
105
|
+
setConfirmingDelete(true);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (repeats) {
|
|
109
|
+
setAsking(true);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
remove(undefined);
|
|
113
|
+
};
|
|
114
|
+
const confirmDelete = () => {
|
|
115
|
+
setConfirmingDelete(false);
|
|
116
|
+
if (repeats) {
|
|
117
|
+
setAsking(true);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
remove(undefined);
|
|
121
|
+
};
|
|
122
|
+
const remove = (scope) => {
|
|
123
|
+
setAsking(false);
|
|
124
|
+
void deleteEvent(write(scope)).then((outcome) => {
|
|
125
|
+
if (outcome.kind === "written") {
|
|
126
|
+
calendarSession.trackSends(outcome.sends);
|
|
127
|
+
closeToView();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const text = failureText(outcome);
|
|
131
|
+
setFailure({
|
|
132
|
+
text,
|
|
133
|
+
reportHref: calendarEventReportHref(text),
|
|
134
|
+
onRetry: () => remove(scope),
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const reply = (answer, scope) => {
|
|
139
|
+
setAnswering(undefined);
|
|
140
|
+
setReplyFailure(undefined);
|
|
141
|
+
void updateEvent(write(scope), { answer: ANSWER_OF[answer] }).then((outcome) => {
|
|
142
|
+
if (outcome.kind === "written") {
|
|
143
|
+
calendarSession.trackSends(outcome.sends);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const text = outcome.kind === "conflict"
|
|
147
|
+
? `${CONFLICT} Close the popup and open the event again.`
|
|
148
|
+
: `Couldn't send your reply: ${outcome.message}`;
|
|
149
|
+
setReplyFailure({
|
|
150
|
+
text,
|
|
151
|
+
reportHref: calendarEventReportHref(text),
|
|
152
|
+
onRetry: () => reply(answer, scope),
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
const participation = resource?.participation;
|
|
157
|
+
const isGuest = participation !== undefined &&
|
|
158
|
+
participation !== "Organizer" &&
|
|
159
|
+
participation !== "Unscheduled";
|
|
160
|
+
if (occurrence) {
|
|
161
|
+
return (_jsx(Navigate, { to: "/calendar/$view/$date/$calendarObjectId/$recurrenceId", params: {
|
|
162
|
+
view,
|
|
163
|
+
date,
|
|
164
|
+
calendarObjectId,
|
|
165
|
+
recurrenceId: occurrence.recurrenceId,
|
|
166
|
+
}, search: true, hash: true, replace: true }));
|
|
167
|
+
}
|
|
168
|
+
const jump = search.kind === "Found" ? search.jump : undefined;
|
|
169
|
+
const hidden = jump !== undefined &&
|
|
170
|
+
calendarIds.length > 0 &&
|
|
171
|
+
!calendarIds.includes(jump.calendarId);
|
|
172
|
+
if (jump && (jump.date !== date || hidden)) {
|
|
173
|
+
const shown = hidden
|
|
174
|
+
? (previous) => ({
|
|
175
|
+
...previous,
|
|
176
|
+
calendarId: [...calendarIds, jump.calendarId],
|
|
177
|
+
})
|
|
178
|
+
: true;
|
|
179
|
+
return jump.recurrenceId === "" ? (_jsx(Navigate, { to: "/calendar/$view/$date/$calendarObjectId", params: { view, date: jump.date, calendarObjectId }, search: shown, hash: true, replace: true })) : (_jsx(Navigate, { to: "/calendar/$view/$date/$calendarObjectId/$recurrenceId", params: {
|
|
180
|
+
view,
|
|
181
|
+
date: jump.date,
|
|
182
|
+
calendarObjectId,
|
|
183
|
+
recurrenceId: jump.recurrenceId,
|
|
184
|
+
}, search: shown, hash: true, replace: true }));
|
|
185
|
+
}
|
|
186
|
+
if (search.kind === "Failed" && !event) {
|
|
187
|
+
const text = `Couldn't open this event: ${search.reason}`;
|
|
188
|
+
return (_jsx(CalendarPopover, { anchor: null, anchorKey: "failed", labelledBy: headingId, children: _jsxs("div", { className: "flex flex-col gap-3 p-4", id: headingId, children: [_jsxs("p", { role: "alert", className: "text-sm text-danger", children: [text, " ", _jsx("a", { href: calendarEventReportHref(text), target: "_blank", rel: "noreferrer", className: "font-medium text-accent hover:underline", children: "Report an issue" })] }), _jsx("button", { type: "button", onClick: closeToView, className: "self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium", children: "Close" })] }) }));
|
|
189
|
+
}
|
|
190
|
+
if (gone) {
|
|
191
|
+
return (_jsx(CalendarPopover, { anchor: null, anchorKey: "gone", labelledBy: headingId, children: _jsx(CalendarEventGone, { headingId: headingId, onClose: closeToView, closeRef: closeRef }) }));
|
|
192
|
+
}
|
|
193
|
+
if (!event)
|
|
194
|
+
return null;
|
|
195
|
+
return (_jsxs(_Fragment, { children: [_jsx(CalendarPopover, { anchor: anchor, anchorKey: `${instanceId}:${anchor ? "chip" : "none"}`, labelledBy: headingId, children: _jsxs(CalendarEventPopupCard, { headingId: headingId, headingRef: headingRef, title: event.title, color: calendar?.color ?? "cal-1", when: formatEventWhen(event).replace(", ", " · "), location: stored?.location ?? "", calendarName: calendar?.name ?? "", availability: freeIds.has(event.id) ? "Free" : "Busy", onEdit: writable
|
|
196
|
+
? () => openEditor(calendarObjectId, recurrenceId)
|
|
197
|
+
: undefined, onDelete: writable ? askDelete : undefined, deleting: isWriting, onClose: closeToView, failure: failure, failureRef: failureRef, children: [resource && (_jsx(CalendarEventGuests, { attendees: resource.attendees.map(toAttendee), counts: resource.attendeeCounts })), isGuest && participation && (_jsx(CalendarReplyRow, { current: rsvpOfParticipation(participation), onAnswer: (answer) => repeats ? setAnswering(answer) : reply(answer, undefined), sending: isWriting, failure: replyFailure })), answering && (_jsx(RecurrenceScopePrompt, { title: event.title, ruleText: "It repeats", instanceText: formatEventWhen(event), scopes: ["this", "all"], onChoose: (scope) => reply(answering, scope), onCancel: () => setAnswering(undefined) })), asking && (_jsx(RecurrenceScopePrompt, { title: event.title, ruleText: "It repeats", instanceText: formatEventWhen(event), onChoose: remove, onCancel: () => setAsking(false) }))] }) }), _jsx(ConfirmDialog, { isOpen: confirmingDelete, title: "Delete and tell the guests?", description: `${guestNames.join(", ")} will get a cancellation.`, confirmLabel: "Delete and send", cancelLabel: "Keep event", destructive: true, onConfirm: confirmDelete, onCancel: () => setConfirmingDelete(false) })] }));
|
|
198
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface CalendarLoadFailedProps {
|
|
2
|
+
title: string;
|
|
3
|
+
error: unknown;
|
|
4
|
+
onRetry: () => void;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** A read that failed, said where it was asked for, with Retry and a prefilled report. */
|
|
8
|
+
export declare function CalendarLoadFailed({ title, error, onRetry, compact, }: CalendarLoadFailedProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatErrorMessage } from "@remit/ui";
|
|
3
|
+
import { AlertCircle } from "lucide-react";
|
|
4
|
+
import { calendarEventReportHref } from "../../lib/calendar-report";
|
|
5
|
+
/** A read that failed, said where it was asked for, with Retry and a prefilled report. */
|
|
6
|
+
export function CalendarLoadFailed({ title, error, onRetry, compact = false, }) {
|
|
7
|
+
const message = formatErrorMessage(error);
|
|
8
|
+
return (_jsxs("div", { role: "alert", className: compact
|
|
9
|
+
? "flex flex-col gap-2 rounded-md border border-danger/40 bg-danger-soft p-3 text-sm"
|
|
10
|
+
: "flex h-full flex-col items-center justify-center gap-3 p-8 text-center", children: [!compact && (_jsx(AlertCircle, { className: "size-8 text-danger", "aria-hidden": "true" })), _jsxs("div", { children: [_jsx("p", { className: "font-medium text-danger", children: title }), _jsx("p", { className: "mt-1 break-words text-sm text-fg-muted", children: message })] }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsx("button", { type: "button", onClick: onRetry, className: "inline-flex items-center rounded-md border border-line bg-canvas px-3 py-1.5 text-sm font-medium hover:bg-surface-raised", children: "Retry" }), _jsx("a", { href: calendarEventReportHref(`${title}: ${message}`), target: "_blank", rel: "noreferrer", className: "text-sm font-medium text-accent hover:underline", children: "Report an issue" })] })] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Ref } from "react";
|
|
2
|
+
export declare const CALENDAR_SIDE_PANE_ID = "calendar-side-pane";
|
|
3
|
+
export interface CalendarNavPaneProps {
|
|
4
|
+
onNewEvent: () => void;
|
|
5
|
+
newEventRef?: Ref<HTMLButtonElement>;
|
|
6
|
+
/** After a day is picked, as the phone slide-over closes on it. */
|
|
7
|
+
onPicked?: () => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/** New event, the mini month and My calendars, bound to the address. */
|
|
11
|
+
export declare function CalendarNavPane({ onNewEvent, newEventRef, onPicked, className, }: CalendarNavPaneProps): import("react").JSX.Element;
|