@remit/web-client 0.0.328 → 0.0.329
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 +321 -0
- package/dist/src/components/calendar/CalendarEventPopup.d.ts +10 -0
- package/dist/src/components/calendar/CalendarEventPopup.js +133 -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 +131 -0
- package/dist/src/components/calendar/CalendarScreen.d.ts +11 -0
- package/dist/src/components/calendar/CalendarScreen.js +145 -0
- package/dist/src/components/calendar/CalendarSession.d.ts +21 -0
- package/dist/src/components/calendar/CalendarSession.js +12 -0
- 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/layout/AppFrame.d.ts +11 -0
- package/dist/src/components/layout/AppFrame.js +16 -0
- package/dist/src/components/mail/MailSidebarAdapter.js +1 -1
- package/dist/src/components/ui/SignedOutOverlay.d.ts +6 -0
- package/dist/src/components/ui/SignedOutOverlay.js +29 -0
- package/dist/src/hooks/calendar/draft-session.d.ts +77 -0
- package/dist/src/hooks/calendar/draft-session.js +109 -0
- package/dist/src/hooks/calendar/index.d.ts +2 -1
- package/dist/src/hooks/calendar/index.js +1 -0
- package/dist/src/hooks/calendar/useCalendarJump.d.ts +0 -2
- package/dist/src/hooks/calendar/useCalendarJump.js +3 -5
- package/dist/src/hooks/calendar/useCalendarWrites.d.ts +11 -1
- package/dist/src/hooks/calendar/useCalendarWrites.js +7 -2
- package/dist/src/hooks/calendar/useCalendars.d.ts +1 -0
- package/dist/src/hooks/calendar/useCalendars.js +5 -2
- 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 +61 -0
- package/dist/src/hooks/use-system-update.js +3 -5
- package/dist/src/hooks/useCalendarData.d.ts +2 -0
- package/dist/src/hooks/useCalendarData.js +6 -1
- package/dist/src/hooks/useCalendarSidePane.d.ts +14 -0
- package/dist/src/hooks/useCalendarSidePane.js +30 -0
- package/dist/src/hooks/useRefreshControl.js +4 -8
- package/dist/src/hooks/useStaleAccountSync.js +4 -4
- 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 +81 -19
- package/dist/src/routeTree.gen.js +25 -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.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/routing/app-switch.d.ts +11 -0
- package/dist/src/routing/app-switch.js +35 -0
- package/dist/src/routing/calendar.d.ts +41 -4
- package/dist/src/routing/calendar.js +121 -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
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { CalendarDescriptor, CalendarEventData } from "@remit/ui";
|
|
2
|
-
import type { ReactNode } from "react";
|
|
3
|
-
export type CalendarEventAbsence = {
|
|
4
|
-
kind: "NotInView";
|
|
5
|
-
} | {
|
|
6
|
-
kind: "Finding";
|
|
7
|
-
} | {
|
|
8
|
-
kind: "Deleted";
|
|
9
|
-
} | {
|
|
10
|
-
kind: "NoOccurrenceFound";
|
|
11
|
-
} | {
|
|
12
|
-
kind: "SignedOut";
|
|
13
|
-
signIn: ReactNode;
|
|
14
|
-
} | {
|
|
15
|
-
kind: "Failed";
|
|
16
|
-
reason: string;
|
|
17
|
-
reportHref: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* The event the address has open.
|
|
21
|
-
*
|
|
22
|
-
* Presentational, like the workspace beside it: the route resolves the event
|
|
23
|
-
* and turns closing, editing and deleting into things it does, so this renders
|
|
24
|
-
* what it is handed and nothing else. Each control appears only when the route
|
|
25
|
-
* gave it somewhere to go — a control that leads nowhere is worse than none.
|
|
26
|
-
*/
|
|
27
|
-
export interface CalendarEventPaneProps {
|
|
28
|
-
/** Absent when the address names an event the calendar does not have. */
|
|
29
|
-
event: CalendarEventData | undefined;
|
|
30
|
-
calendar: CalendarDescriptor | undefined;
|
|
31
|
-
/** Whether the address names one occurrence rather than the series. */
|
|
32
|
-
isOccurrence: boolean;
|
|
33
|
-
absence?: CalendarEventAbsence;
|
|
34
|
-
/**
|
|
35
|
-
* A write that did not happen, stated where the reader is looking. Empty
|
|
36
|
-
* when the last one did.
|
|
37
|
-
*/
|
|
38
|
-
problem?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Why this event cannot be changed here, stated where Edit and Delete would
|
|
41
|
-
* be. Empty for an event the reader can change.
|
|
42
|
-
*/
|
|
43
|
-
readOnlyNote?: string;
|
|
44
|
-
onEdit?: () => void;
|
|
45
|
-
onDelete?: () => void;
|
|
46
|
-
onClose: () => void;
|
|
47
|
-
}
|
|
48
|
-
export declare function CalendarEventPane({ event, calendar, isOccurrence, absence, problem, readOnlyNote, onEdit, onDelete, onClose, }: CalendarEventPaneProps): import("react").JSX.Element;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { EventDetail } from "@remit/ui";
|
|
3
|
-
import { AlertCircle, CalendarDays, Lock } from "lucide-react";
|
|
4
|
-
import { formatEventWhen } from "../../lib/calendar-format";
|
|
5
|
-
const NOT_IN_VIEW = { kind: "NotInView" };
|
|
6
|
-
const LINK = "rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring";
|
|
7
|
-
function absenceText(absence) {
|
|
8
|
-
switch (absence.kind) {
|
|
9
|
-
case "Finding":
|
|
10
|
-
return {
|
|
11
|
-
title: "Finding the event",
|
|
12
|
-
detail: "Looking for the day it falls on.",
|
|
13
|
-
};
|
|
14
|
-
case "Deleted":
|
|
15
|
-
return {
|
|
16
|
-
title: "This event was deleted",
|
|
17
|
-
detail: "None of your calendars holds it any more.",
|
|
18
|
-
};
|
|
19
|
-
case "NoOccurrenceFound":
|
|
20
|
-
return {
|
|
21
|
-
title: "No occurrence in its first year or the coming year",
|
|
22
|
-
detail: "Its repeat rule, or the days taken out of it, leave it no day in either.",
|
|
23
|
-
};
|
|
24
|
-
case "SignedOut":
|
|
25
|
-
return {
|
|
26
|
-
title: "Your session has ended",
|
|
27
|
-
detail: "Sign in again to open this event.",
|
|
28
|
-
};
|
|
29
|
-
case "Failed":
|
|
30
|
-
return {
|
|
31
|
-
title: "The event couldn't be looked up",
|
|
32
|
-
detail: absence.reason,
|
|
33
|
-
};
|
|
34
|
-
case "NotInView":
|
|
35
|
-
return {
|
|
36
|
-
title: "That event isn't on this week",
|
|
37
|
-
detail: "The address names an event the calendar doesn't have here.",
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export function CalendarEventPane({ event, calendar, isOccurrence, absence = NOT_IN_VIEW, problem = "", readOnlyNote = "", onEdit, onDelete, onClose, }) {
|
|
42
|
-
if (!event || !calendar) {
|
|
43
|
-
const { title, detail } = absenceText(absence);
|
|
44
|
-
const loud = absence.kind === "Failed" || absence.kind === "SignedOut";
|
|
45
|
-
return (_jsxs("div", { role: loud ? "alert" : undefined, className: "flex h-full flex-col items-center justify-center gap-2 bg-surface p-8 text-center", children: [_jsx(CalendarDays, { className: "size-8 text-fg-subtle", "aria-hidden": "true" }), _jsx("p", { className: "text-sm font-medium text-fg", children: title }), _jsx("p", { className: "max-w-xs break-words text-sm text-fg-muted", children: detail }), _jsxs("div", { className: "flex flex-wrap items-center justify-center gap-2", children: [absence.kind === "SignedOut" && absence.signIn, absence.kind === "Failed" && (_jsx("a", { href: absence.reportHref, target: "_blank", rel: "noreferrer", className: LINK, children: "Report an issue" })), _jsx("button", { type: "button", onClick: onClose, className: LINK, children: "Back to the calendar" })] })] }));
|
|
46
|
-
}
|
|
47
|
-
return (_jsxs("div", { className: "flex h-full min-h-0 flex-col bg-surface", children: [isOccurrence && (_jsx("p", { className: "shrink-0 border-b border-line bg-surface-sunken px-row-inset py-1.5 text-2xs uppercase tracking-wider text-fg-subtle", children: "One occurrence of a repeating event" })), readOnlyNote !== "" && (_jsxs("p", { className: "flex shrink-0 items-start gap-2 border-b border-line bg-surface-sunken px-row-inset py-2 text-sm text-fg-muted", children: [_jsx(Lock, { className: "mt-0.5 size-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { className: "min-w-0 flex-1 break-words", children: readOnlyNote })] })), problem !== "" && (_jsxs("div", { role: "alert", className: "flex shrink-0 items-start gap-2 border-b border-danger/40 bg-danger-soft px-row-inset py-2 text-sm", children: [_jsx(AlertCircle, { className: "mt-0.5 size-4 shrink-0 text-danger", "aria-hidden": "true" }), _jsx("p", { className: "min-w-0 flex-1 break-words text-fg", children: problem })] })), _jsx(EventDetail, { event: event, calendar: calendar, whenText: formatEventWhen(event), onEdit: onEdit, onDelete: onDelete, onClose: onClose, className: "min-h-0 flex-1" })] }));
|
|
48
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* The chrome the calendar shares with mail, published by the `/calendar` layout
|
|
4
|
-
* and consumed by the view route that mounts the shell.
|
|
5
|
-
*
|
|
6
|
-
* It lives outside the route files for the same reason
|
|
7
|
-
* `lib/mail-context.ts` does: the generated route tree imports route files
|
|
8
|
-
* relatively, so a context declared inside one would resolve to a second module
|
|
9
|
-
* instance and hand the consumer an empty default.
|
|
10
|
-
*/
|
|
11
|
-
export interface CalendarShellChrome {
|
|
12
|
-
/** Below the reading boundary the shell shows one pane, as mail's does. */
|
|
13
|
-
isSinglePane: boolean;
|
|
14
|
-
isLoading: boolean;
|
|
15
|
-
nav: ReactNode;
|
|
16
|
-
navOpen: boolean;
|
|
17
|
-
onOpenNav: () => void;
|
|
18
|
-
onCloseNav: () => void;
|
|
19
|
-
}
|
|
20
|
-
export declare const CalendarShellProvider: ({ chrome, children, }: {
|
|
21
|
-
chrome: CalendarShellChrome;
|
|
22
|
-
children: ReactNode;
|
|
23
|
-
}) => import("react").JSX.Element;
|
|
24
|
-
export interface CalendarShellProps {
|
|
25
|
-
/** The grid, or whatever the current zoom draws. */
|
|
26
|
-
workspace: ReactNode;
|
|
27
|
-
/** The open event, from the route below this one. */
|
|
28
|
-
reading: ReactNode;
|
|
29
|
-
/** Whether the address has an event or the composer open. */
|
|
30
|
-
hasOpenEvent: boolean;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The shell the calendar mounts around its own panes.
|
|
34
|
-
*
|
|
35
|
-
* `listBias="list"` because the grid is the work rather than an index into it:
|
|
36
|
-
* a week of columns costs width it cannot give back when a detail opens, which
|
|
37
|
-
* is the opposite of the split a message list wants.
|
|
38
|
-
*
|
|
39
|
-
* Below the reading boundary there is one pane, so the open event replaces the
|
|
40
|
-
* grid in it — the same swap mail makes, read off the address rather than
|
|
41
|
-
* decided here.
|
|
42
|
-
*/
|
|
43
|
-
export declare function CalendarShell({ workspace, reading, hasOpenEvent, }: CalendarShellProps): import("react").JSX.Element;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { AppShellSlotted } from "@remit/ui";
|
|
3
|
-
import { createContext, useContext } from "react";
|
|
4
|
-
import { AppShellSkeleton } from "../layout/AppShellSkeleton";
|
|
5
|
-
const CalendarShellCtx = createContext(null);
|
|
6
|
-
export const CalendarShellProvider = ({ chrome, children, }) => (_jsx(CalendarShellCtx.Provider, { value: chrome, children: children }));
|
|
7
|
-
/**
|
|
8
|
-
* The shell the calendar mounts around its own panes.
|
|
9
|
-
*
|
|
10
|
-
* `listBias="list"` because the grid is the work rather than an index into it:
|
|
11
|
-
* a week of columns costs width it cannot give back when a detail opens, which
|
|
12
|
-
* is the opposite of the split a message list wants.
|
|
13
|
-
*
|
|
14
|
-
* Below the reading boundary there is one pane, so the open event replaces the
|
|
15
|
-
* grid in it — the same swap mail makes, read off the address rather than
|
|
16
|
-
* decided here.
|
|
17
|
-
*/
|
|
18
|
-
export function CalendarShell({ workspace, reading, hasOpenEvent, }) {
|
|
19
|
-
const chrome = useContext(CalendarShellCtx);
|
|
20
|
-
if (!chrome)
|
|
21
|
-
return _jsx(AppShellSkeleton, {});
|
|
22
|
-
const shared = {
|
|
23
|
-
nav: chrome.nav,
|
|
24
|
-
skeleton: _jsx(AppShellSkeleton, {}),
|
|
25
|
-
isLoading: chrome.isLoading,
|
|
26
|
-
navOpen: chrome.navOpen,
|
|
27
|
-
onOpenNav: chrome.onOpenNav,
|
|
28
|
-
onCloseNav: chrome.onCloseNav,
|
|
29
|
-
listBias: "list",
|
|
30
|
-
};
|
|
31
|
-
if (chrome.isSinglePane) {
|
|
32
|
-
return (_jsx(AppShellSlotted, { ...shared, list: hasOpenEvent ? reading : workspace }));
|
|
33
|
-
}
|
|
34
|
-
return _jsx(AppShellSlotted, { ...shared, list: workspace, reading: reading });
|
|
35
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function CalendarViewPlaceholder(): import("react").JSX.Element;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { CalendarRange } from "lucide-react";
|
|
3
|
-
export function CalendarViewPlaceholder() {
|
|
4
|
-
return (_jsxs("div", { className: "flex h-full flex-col items-center justify-center gap-2 bg-surface p-8 text-center", "data-testid": "calendar-placeholder-year", children: [_jsx(CalendarRange, { className: "size-8 text-fg-subtle", "aria-hidden": "true" }), _jsx("p", { className: "text-sm font-medium text-fg", children: "Not built yet" }), _jsx("p", { className: "max-w-xs text-sm text-fg-muted", children: "The year grid arrives with the rest of the zoom ladder. Month, Week, Day and Agenda work now." })] }));
|
|
5
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type CalendarColorId, type CalendarEventData, type CalendarSlotPick, type CalendarViewId, type Density } from "@remit/ui";
|
|
2
|
-
import { type ReactNode } from "react";
|
|
3
|
-
export interface CalendarWorkspaceProps {
|
|
4
|
-
view: CalendarViewId;
|
|
5
|
-
/** The day the view is centred on, `YYYY-MM-DD`. */
|
|
6
|
-
date: string;
|
|
7
|
-
events: CalendarEventData[];
|
|
8
|
-
colorByCalendarId: Record<string, CalendarColorId>;
|
|
9
|
-
/**
|
|
10
|
-
* The strip, at the one zoom that draws it. A slot rather than something
|
|
11
|
-
* built here because it loads its own days over a rolling range, and this
|
|
12
|
-
* pane holds no events and knows no router.
|
|
13
|
-
*/
|
|
14
|
-
agenda: ReactNode;
|
|
15
|
-
/**
|
|
16
|
-
* What the mail is still asking about time, beside whichever zoom is drawn.
|
|
17
|
-
* A slot for the reason the strip is one: it reads its own data.
|
|
18
|
-
*/
|
|
19
|
-
waiting?: ReactNode;
|
|
20
|
-
/** The first read of this window is still out; the grid has nothing yet. */
|
|
21
|
-
isLoading?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* A refusal the calendar states in place of the grid. A week drawn empty
|
|
24
|
-
* because the read failed is indistinguishable from a week with nothing in
|
|
25
|
-
* it, which is the one thing this must never look like.
|
|
26
|
-
*/
|
|
27
|
-
error?: unknown;
|
|
28
|
-
onRetry?: () => void;
|
|
29
|
-
density: Density;
|
|
30
|
-
/** The event the reading pane has open, empty for none. */
|
|
31
|
-
selectedEventId: string;
|
|
32
|
-
timeZone: string;
|
|
33
|
-
/** The instant the grid calls now. */
|
|
34
|
-
now: string;
|
|
35
|
-
onChangeView: (view: CalendarViewId) => void;
|
|
36
|
-
onToday: () => void;
|
|
37
|
-
onChangeDensity: (density: Density) => void;
|
|
38
|
-
onSelectEvent: (eventId: string) => void;
|
|
39
|
-
onPickSlot: (pick: CalendarSlotPick) => void;
|
|
40
|
-
onStep: (direction: -1 | 1) => void;
|
|
41
|
-
dayHref: (date: string) => string;
|
|
42
|
-
onZoomDay: (date: string) => void;
|
|
43
|
-
/**
|
|
44
|
-
* A phone: the toolbar splits into two rows of thumb-sized controls, because
|
|
45
|
-
* one row of them is wider than the screen and pushes the grid off it.
|
|
46
|
-
*/
|
|
47
|
-
touch?: boolean;
|
|
48
|
-
}
|
|
49
|
-
export declare function CalendarWorkspace({ view, date, events, colorByCalendarId, agenda, waiting, isLoading, error, onRetry, density, selectedEventId, timeZone, now, onChangeView, onToday, onChangeDensity, onSelectEvent, onPickSlot, onStep, dayHref, onZoomDay, touch, }: CalendarWorkspaceProps): import("react").JSX.Element;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { CalendarDateNav, CalendarGrid, CalendarViewSwitch, ErrorState, Segmented, } from "@remit/ui";
|
|
3
|
-
import { Loader2 } from "lucide-react";
|
|
4
|
-
import { useState } from "react";
|
|
5
|
-
import { calendarViewMountsAgenda, calendarViewMountsGrid, } from "../../lib/calendar-route";
|
|
6
|
-
import { NavMenuButton } from "../mail/NavMenuButton";
|
|
7
|
-
import { CalendarViewPlaceholder } from "./CalendarViewPlaceholder";
|
|
8
|
-
/**
|
|
9
|
-
* The calendar's own pane: the toolbar that moves it and whatever the current
|
|
10
|
-
* zoom draws.
|
|
11
|
-
*
|
|
12
|
-
* Presentational, like everything in `@remit/ui` it is built from. It holds no
|
|
13
|
-
* events, reads no clock and knows no router: prev, next, today and the zoom
|
|
14
|
-
* switch all leave through callbacks, and the route turns each one into an
|
|
15
|
-
* address. That is what keeps "which view" and "which day" facts of the URL
|
|
16
|
-
* rather than of this component's state.
|
|
17
|
-
*/
|
|
18
|
-
const PHONE_VIEWS = ["month", "week", "day", "agenda"];
|
|
19
|
-
const DENSITY_OPTIONS = [
|
|
20
|
-
{ value: "comfortable", label: "Detail", shortLabel: "Detail" },
|
|
21
|
-
{ value: "compact", label: "Glance", shortLabel: "Glance" },
|
|
22
|
-
];
|
|
23
|
-
/**
|
|
24
|
-
* The range the toolbar names before the grid has measured one, and the whole
|
|
25
|
-
* answer for a week and at a zoom that draws no grid.
|
|
26
|
-
*/
|
|
27
|
-
function fallbackRangeTitle(view, date) {
|
|
28
|
-
const instant = new Date(`${date}T00:00:00`);
|
|
29
|
-
if (view === "year")
|
|
30
|
-
return new Intl.DateTimeFormat(undefined, { year: "numeric" }).format(instant);
|
|
31
|
-
if (view === "week") {
|
|
32
|
-
const monday = new Date(instant);
|
|
33
|
-
monday.setDate(instant.getDate() - ((instant.getDay() + 6) % 7));
|
|
34
|
-
const sunday = new Date(monday);
|
|
35
|
-
sunday.setDate(monday.getDate() + 6);
|
|
36
|
-
return new Intl.DateTimeFormat(undefined, {
|
|
37
|
-
day: "numeric",
|
|
38
|
-
month: "short",
|
|
39
|
-
year: "numeric",
|
|
40
|
-
}).formatRange(monday, sunday);
|
|
41
|
-
}
|
|
42
|
-
if (view === "day")
|
|
43
|
-
return new Intl.DateTimeFormat(undefined, {
|
|
44
|
-
weekday: "short",
|
|
45
|
-
day: "numeric",
|
|
46
|
-
month: "long",
|
|
47
|
-
year: "numeric",
|
|
48
|
-
}).format(instant);
|
|
49
|
-
return new Intl.DateTimeFormat(undefined, {
|
|
50
|
-
month: "long",
|
|
51
|
-
year: "numeric",
|
|
52
|
-
}).format(instant);
|
|
53
|
-
}
|
|
54
|
-
export function CalendarWorkspace({ view, date, events, colorByCalendarId, agenda, waiting, isLoading = false, error, onRetry, density, selectedEventId, timeZone, now, onChangeView, onToday, onChangeDensity, onSelectEvent, onPickSlot, onStep, dayHref, onZoomDay, touch = false, }) {
|
|
55
|
-
// Held against the address it was measured for, so leaving a view does not
|
|
56
|
-
// carry its title into the next one.
|
|
57
|
-
const [measured, setMeasured] = useState({ key: "", title: "" });
|
|
58
|
-
const addressKey = `${view}/${date}`;
|
|
59
|
-
const title = view !== "week" && measured.key === addressKey
|
|
60
|
-
? measured.title
|
|
61
|
-
: fallbackRangeTitle(view, date);
|
|
62
|
-
const dateNav = (_jsx(CalendarDateNav, { title: title, onPrev: () => onStep(-1), onNext: () => onStep(1), onToday: onToday, touch: touch }));
|
|
63
|
-
const densitySwitch = (_jsx(Segmented, { ariaLabel: "Calendar density", options: DENSITY_OPTIONS, value: density, onChange: onChangeDensity, touch: touch, className: "shrink-0" }));
|
|
64
|
-
return (_jsxs("div", { className: "flex h-full min-h-0 flex-col bg-surface", children: [touch ? (_jsxs("div", { className: "flex shrink-0 flex-col gap-1 border-b border-line px-2 pb-1", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [_jsx(NavMenuButton, {}), _jsx("div", { className: "min-w-0 flex-1", children: dateNav })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CalendarViewSwitch, { value: view, onChange: onChangeView, views: PHONE_VIEWS, touch: true, className: "flex-1" }), densitySwitch] })] })) : (_jsxs("div", { className: "flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-2", children: [_jsx(NavMenuButton, {}), _jsx("div", { className: "min-w-0 flex-1", children: dateNav }), densitySwitch, _jsx(CalendarViewSwitch, { value: view, onChange: onChangeView })] })), _jsxs("div", { className: "flex min-h-0 flex-1", children: [waiting, calendarViewMountsAgenda(view) ? (_jsx("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: agenda })) : (_jsx("div", { className: "min-h-0 min-w-0 flex-1", children: error !== undefined && error !== null ? (_jsx("div", { className: "flex h-full items-center justify-center", children: _jsx(ErrorState, { title: "Couldn't load this week", error: error, onRetry: onRetry }) })) : isLoading ? (_jsx("div", { role: "status", "aria-label": "Loading the calendar", className: "flex h-full items-center justify-center bg-surface", children: _jsx(Loader2, { className: "size-6 animate-spin text-fg-subtle" }) })) : calendarViewMountsGrid(view) ? (_jsx(CalendarGrid, { view: view, date: date, events: events, colorByCalendarId: colorByCalendarId, density: density, selectedEventId: selectedEventId, timeZone: timeZone, now: now, onSelectEvent: onSelectEvent, onPickSlot: onPickSlot, dayHref: dayHref, onZoomDay: onZoomDay, onRangeChange: (measuredTitle) => setMeasured({ key: addressKey, title: measuredTitle }) })) : (_jsx(CalendarViewPlaceholder, {})) }))] })] }));
|
|
65
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The event the address names, resolved — and everything a reader can do to it.
|
|
3
|
-
*
|
|
4
|
-
* The two event routes differ only in what the address says, so the lookup, the
|
|
5
|
-
* scope question and the way back live here once rather than in each of them.
|
|
6
|
-
*
|
|
7
|
-
* An edit or a delete on a repeating event asks which occurrences it means
|
|
8
|
-
* before the form opens, not on the way out: which instances it reaches changes
|
|
9
|
-
* what the change is, so it is settled while it can still be answered.
|
|
10
|
-
*
|
|
11
|
-
* Every write carries the etag of the version on screen. A 412 means somebody
|
|
12
|
-
* replaced the event in between, and it is said out loud rather than resolved
|
|
13
|
-
* by overwriting them.
|
|
14
|
-
*/
|
|
15
|
-
export interface OpenCalendarEventProps {
|
|
16
|
-
calendarObjectId: string;
|
|
17
|
-
/** One occurrence of a series, absent on the series itself. */
|
|
18
|
-
recurrenceId?: string;
|
|
19
|
-
}
|
|
20
|
-
export declare function OpenCalendarEvent({ calendarObjectId, recurrenceId, }: OpenCalendarEventProps): import("react").JSX.Element;
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { RecurrenceScopePrompt, } from "@remit/ui";
|
|
3
|
-
import { Navigate } from "@tanstack/react-router";
|
|
4
|
-
import { useState } from "react";
|
|
5
|
-
import { SignInAgain } from "../../auth/SignInAgain";
|
|
6
|
-
import { calendarInstanceId, deviceTimeZone, draftFromEvent, emptyDraft, isoOnClock, moveRule, patchFromDrafts, rruleFromIcalData, seriesOccurrenceOf, storedAnchorZone, textFromIcalData, textFromRrule, UNZONED_CALENDAR, useCalendarEvent, useCalendarJump, useCalendars, useCalendarWrites, useDraftClashes, } from "../../hooks/calendar";
|
|
7
|
-
import { useCalendarData } from "../../hooks/useCalendarData";
|
|
8
|
-
import { formatEventWhen } from "../../lib/calendar-format";
|
|
9
|
-
import { calendarEventReportHref } from "../../lib/calendar-report";
|
|
10
|
-
import { subscriptionReadOnlyNote } from "../../lib/calendar-subscription";
|
|
11
|
-
import { useCalendarAddress, useCalendarNavigation } from "../../routing";
|
|
12
|
-
import { CalendarComposePane } from "./CalendarComposePane";
|
|
13
|
-
import { CalendarEventPane, } from "./CalendarEventPane";
|
|
14
|
-
const CONFLICT = "This event changed somewhere else — over CalDAV, or in another tab. Nothing was saved. Close it and open it again to see the version that's stored now.";
|
|
15
|
-
const absenceOf = (search, loading) => {
|
|
16
|
-
switch (search.kind) {
|
|
17
|
-
case "Deleted":
|
|
18
|
-
case "NoOccurrenceFound":
|
|
19
|
-
return { kind: search.kind };
|
|
20
|
-
case "SignedOut":
|
|
21
|
-
return { kind: "SignedOut", signIn: _jsx(SignInAgain, {}) };
|
|
22
|
-
case "Failed":
|
|
23
|
-
return {
|
|
24
|
-
kind: "Failed",
|
|
25
|
-
reason: search.reason,
|
|
26
|
-
reportHref: calendarEventReportHref(`opening an event failed: ${search.reason}`),
|
|
27
|
-
};
|
|
28
|
-
case "Searching":
|
|
29
|
-
return { kind: "Finding" };
|
|
30
|
-
default:
|
|
31
|
-
return { kind: loading ? "Finding" : "NotInView" };
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
export function OpenCalendarEvent({ calendarObjectId, recurrenceId, }) {
|
|
35
|
-
const { view, date, calendarIds } = useCalendarAddress();
|
|
36
|
-
const { events, isLoading } = useCalendarData({ view, date, calendarIds });
|
|
37
|
-
const { calendars, collections, timeZoneByCalendarId } = useCalendars();
|
|
38
|
-
const { closeEvent } = useCalendarNavigation();
|
|
39
|
-
const { updateEvent, deleteEvent, isWriting } = useCalendarWrites();
|
|
40
|
-
const event = events.find((candidate) => candidate.id === calendarInstanceId(calendarObjectId, recurrenceId ?? ""));
|
|
41
|
-
const seriesOnly = recurrenceId === undefined && event === undefined;
|
|
42
|
-
const occurrence = seriesOnly
|
|
43
|
-
? seriesOccurrenceOf(events, calendarObjectId, new Date().toISOString())
|
|
44
|
-
: undefined;
|
|
45
|
-
const search = useCalendarJump(calendarObjectId, seriesOnly && !isLoading && occurrence === undefined);
|
|
46
|
-
const calendar = calendars.find((candidate) => candidate.id === event?.calendarId);
|
|
47
|
-
const { resource } = useCalendarEvent(calendarObjectId, event?.calendarId ?? "");
|
|
48
|
-
const [asking, setAsking] = useState(undefined);
|
|
49
|
-
const [editing, setEditing] = useState(undefined);
|
|
50
|
-
const [draft, setDraft] = useState(undefined);
|
|
51
|
-
const [problem, setProblem] = useState("");
|
|
52
|
-
const clashes = useDraftClashes(draft ?? emptyDraft("", ""), calendarObjectId);
|
|
53
|
-
const stored = resource ? textFromIcalData(resource.icalData) : undefined;
|
|
54
|
-
const rrule = resource ? rruleFromIcalData(resource.icalData) : "";
|
|
55
|
-
const startTime = event && !event.allDay ? event.start.slice(11, 16) : "";
|
|
56
|
-
const anchor = resource
|
|
57
|
-
? storedAnchorZone(resource.icalData, timeZoneByCalendarId[event?.calendarId ?? ""] ?? UNZONED_CALENDAR)
|
|
58
|
-
: UNZONED_CALENDAR;
|
|
59
|
-
const shownRule = event && !event.allDay
|
|
60
|
-
? moveRule(rrule, isoOnClock(event.start, anchor === "" ? "UTC" : anchor).slice(0, 10), event.start.slice(0, 10))
|
|
61
|
-
: rrule;
|
|
62
|
-
const repeat = rrule === "" ? "" : (textFromRrule(shownRule, startTime) ?? "Repeats");
|
|
63
|
-
// Scoping needs the occurrence to anchor at, so it is offered only where the
|
|
64
|
-
// address names one. A series opened by itself has one honest answer, which
|
|
65
|
-
// is the whole of it.
|
|
66
|
-
const canScope = event !== undefined &&
|
|
67
|
-
event.seriesId !== "" &&
|
|
68
|
-
recurrenceId !== undefined &&
|
|
69
|
-
recurrenceId !== "";
|
|
70
|
-
// Until the resource is read there is no etag, and a write with no etag is a
|
|
71
|
-
// write that can silently overwrite somebody.
|
|
72
|
-
const writable = event !== undefined && resource !== undefined && !calendar?.readOnly;
|
|
73
|
-
const settle = (outcome, done) => {
|
|
74
|
-
if (outcome.kind === "written") {
|
|
75
|
-
setProblem("");
|
|
76
|
-
done();
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
setProblem(outcome.kind === "conflict" ? CONFLICT : outcome.message);
|
|
80
|
-
};
|
|
81
|
-
const write = (scope) => ({
|
|
82
|
-
calendarObjectId,
|
|
83
|
-
calendarId: event?.calendarId ?? "",
|
|
84
|
-
recurrenceId: recurrenceId ?? "",
|
|
85
|
-
scope,
|
|
86
|
-
etag: resource?.etag ?? "",
|
|
87
|
-
});
|
|
88
|
-
const startEdit = (scope) => {
|
|
89
|
-
if (!event)
|
|
90
|
-
return;
|
|
91
|
-
const before = draftFromEvent(event, {
|
|
92
|
-
repeat,
|
|
93
|
-
location: stored?.location ?? "",
|
|
94
|
-
notes: stored?.description ?? "",
|
|
95
|
-
});
|
|
96
|
-
setAsking(undefined);
|
|
97
|
-
setEditing({ before, scope });
|
|
98
|
-
setDraft(before);
|
|
99
|
-
setProblem("");
|
|
100
|
-
};
|
|
101
|
-
const removeEvent = (scope) => {
|
|
102
|
-
setAsking(undefined);
|
|
103
|
-
void deleteEvent(write(scope)).then((outcome) => settle(outcome, closeEvent));
|
|
104
|
-
};
|
|
105
|
-
const saveEdit = () => {
|
|
106
|
-
if (!editing || !draft)
|
|
107
|
-
return;
|
|
108
|
-
const patch = patchFromDrafts(editing.before, draft, {
|
|
109
|
-
clock: deviceTimeZone(),
|
|
110
|
-
anchor,
|
|
111
|
-
});
|
|
112
|
-
if (!patch.ok) {
|
|
113
|
-
setProblem(patch.problem);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
void updateEvent(write(editing.scope), patch.patch).then((outcome) => settle(outcome, () => {
|
|
117
|
-
setEditing(undefined);
|
|
118
|
-
setDraft(undefined);
|
|
119
|
-
}));
|
|
120
|
-
};
|
|
121
|
-
if (occurrence) {
|
|
122
|
-
return (_jsx(Navigate, { to: "/calendar/$view/$date/$calendarObjectId/$recurrenceId", params: {
|
|
123
|
-
view,
|
|
124
|
-
date,
|
|
125
|
-
calendarObjectId,
|
|
126
|
-
recurrenceId: occurrence.recurrenceId,
|
|
127
|
-
}, search: true, hash: true, replace: true }));
|
|
128
|
-
}
|
|
129
|
-
const jump = search.kind === "Found" ? search.jump : undefined;
|
|
130
|
-
const hidden = jump !== undefined &&
|
|
131
|
-
calendarIds.length > 0 &&
|
|
132
|
-
!calendarIds.includes(jump.calendarId);
|
|
133
|
-
if (jump && (jump.date !== date || hidden)) {
|
|
134
|
-
const shown = hidden
|
|
135
|
-
? (previous) => ({
|
|
136
|
-
...previous,
|
|
137
|
-
calendarId: [...calendarIds, jump.calendarId],
|
|
138
|
-
})
|
|
139
|
-
: true;
|
|
140
|
-
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: {
|
|
141
|
-
view,
|
|
142
|
-
date: jump.date,
|
|
143
|
-
calendarObjectId,
|
|
144
|
-
recurrenceId: jump.recurrenceId,
|
|
145
|
-
}, search: shown, hash: true, replace: true }));
|
|
146
|
-
}
|
|
147
|
-
if (asking !== undefined && event) {
|
|
148
|
-
return (_jsx("div", { className: "flex h-full flex-col justify-center bg-surface px-row-inset", children: _jsx(RecurrenceScopePrompt, { className: "mx-auto w-full max-w-md", title: event.title, ruleText: repeat === "" ? "It repeats" : repeat, instanceText: formatEventWhen(event), onChoose: asking === "edit" ? startEdit : removeEvent, onCancel: () => setAsking(undefined) }) }));
|
|
149
|
-
}
|
|
150
|
-
if (editing && draft) {
|
|
151
|
-
return (_jsx(CalendarComposePane, { title: "Edit event", subtitle: editing.scope === "this" ? "This occurrence only" : draft.date, calendars: calendars, draft: draft, onChange: setDraft, problem: problem, saveLabel: "Save", isSaving: isWriting, repeatEditable: editing.scope === undefined || editing.scope === "all", calendarEditable: false, clashes: clashes, onSave: saveEdit, onCancel: () => {
|
|
152
|
-
setEditing(undefined);
|
|
153
|
-
setDraft(undefined);
|
|
154
|
-
setProblem("");
|
|
155
|
-
} }));
|
|
156
|
-
}
|
|
157
|
-
return (_jsx(CalendarEventPane, { event: event && {
|
|
158
|
-
...event,
|
|
159
|
-
location: stored?.location ?? "",
|
|
160
|
-
notes: stored?.description ?? "",
|
|
161
|
-
recurrenceRule: repeat,
|
|
162
|
-
}, calendar: calendar, readOnlyNote: calendar?.readOnly
|
|
163
|
-
? subscriptionReadOnlyNote(collections.find((collection) => collection.calendarId === calendar.id)?.subscriptionUrl ?? "")
|
|
164
|
-
: "", isOccurrence: recurrenceId !== undefined, absence: absenceOf(search, seriesOnly && isLoading), problem: problem, onEdit: writable
|
|
165
|
-
? () => (canScope ? setAsking("edit") : startEdit(undefined))
|
|
166
|
-
: undefined, onDelete: writable
|
|
167
|
-
? () => (canScope ? setAsking("delete") : removeEvent(undefined))
|
|
168
|
-
: undefined, onClose: closeEvent }));
|
|
169
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Writing a new event.
|
|
3
|
-
*
|
|
4
|
-
* The draft starts on the slot the reader dragged out of the grid, or on the
|
|
5
|
-
* day the calendar is showing when they opened the composer some other way. The
|
|
6
|
-
* write goes through the same service function every other path uses, so an
|
|
7
|
-
* event typed here, one accepted from an invitation and one written over CalDAV
|
|
8
|
-
* are the same bytes stored the same way.
|
|
9
|
-
*/
|
|
10
|
-
export interface WriteCalendarEventProps {
|
|
11
|
-
onClose: () => void;
|
|
12
|
-
}
|
|
13
|
-
export declare function WriteCalendarEvent({ onClose }: WriteCalendarEventProps): import("react").JSX.Element;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { anchorZoneFor, createInputFromDraft, deviceTimeZone, emptyDraft, UNZONED_CALENDAR, useCalendars, useCalendarWrites, useDraftClashes, } from "../../hooks/calendar";
|
|
4
|
-
import { useCalendarAddress } from "../../routing";
|
|
5
|
-
import { CalendarComposePane } from "./CalendarComposePane";
|
|
6
|
-
import { useCalendarComposeSeed } from "./CalendarComposeSeed";
|
|
7
|
-
export function WriteCalendarEvent({ onClose }) {
|
|
8
|
-
const { date } = useCalendarAddress();
|
|
9
|
-
const seed = useCalendarComposeSeed();
|
|
10
|
-
const { calendars: held, timeZoneByCalendarId } = useCalendars();
|
|
11
|
-
const calendars = held.filter((calendar) => !calendar.readOnly);
|
|
12
|
-
const { createEvent, isWriting } = useCalendarWrites();
|
|
13
|
-
const [problem, setProblem] = useState("");
|
|
14
|
-
const [draft, setDraft] = useState(() => {
|
|
15
|
-
const blank = emptyDraft(seed?.date ?? date, "");
|
|
16
|
-
if (!seed)
|
|
17
|
-
return blank;
|
|
18
|
-
return {
|
|
19
|
-
...blank,
|
|
20
|
-
allDay: seed.allDay,
|
|
21
|
-
startTime: seed.allDay ? "" : seed.startTime,
|
|
22
|
-
endDate: seed.endDate,
|
|
23
|
-
endTime: seed.allDay ? "" : seed.endTime,
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
const clashes = useDraftClashes(draft);
|
|
27
|
-
// The default calendar is provisioned by the listing itself, so the picker
|
|
28
|
-
// has one the moment the calendars arrive rather than making the reader
|
|
29
|
-
// choose before they can type anything.
|
|
30
|
-
const firstCalendarId = calendars[0]?.id ?? "";
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (firstCalendarId === "")
|
|
33
|
-
return;
|
|
34
|
-
setDraft((current) => current.calendarId === ""
|
|
35
|
-
? { ...current, calendarId: firstCalendarId }
|
|
36
|
-
: current);
|
|
37
|
-
}, [firstCalendarId]);
|
|
38
|
-
const save = () => {
|
|
39
|
-
const built = createInputFromDraft(draft, {
|
|
40
|
-
clock: deviceTimeZone(),
|
|
41
|
-
anchor: anchorZoneFor(timeZoneByCalendarId[draft.calendarId] ?? UNZONED_CALENDAR),
|
|
42
|
-
});
|
|
43
|
-
if (!built.ok) {
|
|
44
|
-
setProblem(built.problem);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
void createEvent(built.input).then((outcome) => {
|
|
48
|
-
if (outcome.kind === "written") {
|
|
49
|
-
setProblem("");
|
|
50
|
-
onClose();
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
setProblem(outcome.kind === "conflict"
|
|
54
|
-
? "This calendar changed while you were writing. Close the form and try again."
|
|
55
|
-
: outcome.message);
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
return (_jsx(CalendarComposePane, { title: "New event", subtitle: draft.date, calendars: calendars, draft: draft, onChange: setDraft, problem: problem, saveLabel: "Add", isSaving: isWriting, clashes: clashes, onSave: save, onCancel: onClose }));
|
|
59
|
-
}
|