@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.
Files changed (159) hide show
  1. package/dist/src/components/calendar/CalendarEventEditor.d.ts +6 -0
  2. package/dist/src/components/calendar/CalendarEventEditor.js +371 -0
  3. package/dist/src/components/calendar/CalendarEventPopup.d.ts +10 -0
  4. package/dist/src/components/calendar/CalendarEventPopup.js +198 -0
  5. package/dist/src/components/calendar/CalendarLoadFailed.d.ts +8 -0
  6. package/dist/src/components/calendar/CalendarLoadFailed.js +11 -0
  7. package/dist/src/components/calendar/CalendarNavPane.d.ts +11 -0
  8. package/dist/src/components/calendar/CalendarNavPane.js +50 -0
  9. package/dist/src/components/calendar/CalendarQuickCreate.d.ts +22 -0
  10. package/dist/src/components/calendar/CalendarQuickCreate.js +204 -0
  11. package/dist/src/components/calendar/CalendarScreen.d.ts +11 -0
  12. package/dist/src/components/calendar/CalendarScreen.js +184 -0
  13. package/dist/src/components/calendar/CalendarSession.d.ts +24 -0
  14. package/dist/src/components/calendar/CalendarSession.js +12 -0
  15. package/dist/src/components/calendar/CalendarTaskPopup.d.ts +4 -0
  16. package/dist/src/components/calendar/CalendarTaskPopup.js +95 -0
  17. package/dist/src/components/calendar/CalendarWaiting.d.ts +3 -3
  18. package/dist/src/components/calendar/CalendarWaiting.js +5 -10
  19. package/dist/src/components/calendar/ChangeCalendarSuggestion.js +39 -5
  20. package/dist/src/components/calendar/EventMoves.d.ts +17 -0
  21. package/dist/src/components/calendar/EventMoves.js +103 -0
  22. package/dist/src/components/calendar/calendar-story-fixtures.js +8 -2
  23. package/dist/src/components/calendar/calendar-story-server.d.ts +2 -5
  24. package/dist/src/components/calendar/calendar-story-server.js +5 -6
  25. package/dist/src/components/compose/ComposeForm.js +1 -1
  26. package/dist/src/components/layout/AppFrame.d.ts +11 -0
  27. package/dist/src/components/layout/AppFrame.js +16 -0
  28. package/dist/src/components/mail/BulkRunProvider.js +1 -1
  29. package/dist/src/components/mail/MailSidebarAdapter.js +1 -1
  30. package/dist/src/components/mail/MessageActionMenu.js +1 -1
  31. package/dist/src/components/mail/MessageList.js +1 -1
  32. package/dist/src/components/mail/OutboxPane.js +1 -1
  33. package/dist/src/components/mail/ThreadListInteraction.js +1 -1
  34. package/dist/src/components/settings/CalendarDefaultSenderCard.d.ts +2 -0
  35. package/dist/src/components/settings/CalendarDefaultSenderCard.js +16 -0
  36. package/dist/src/components/ui/ErrorBannerProvider.d.ts +0 -23
  37. package/dist/src/components/ui/ErrorBannerProvider.js +3 -39
  38. package/dist/src/components/ui/SignedOutOverlay.d.ts +6 -0
  39. package/dist/src/components/ui/SignedOutOverlay.js +29 -0
  40. package/dist/src/components/ui/error-banner-context.d.ts +23 -0
  41. package/dist/src/components/ui/error-banner-context.js +38 -0
  42. package/dist/src/hooks/calendar/draft-session.d.ts +78 -0
  43. package/dist/src/hooks/calendar/draft-session.js +110 -0
  44. package/dist/src/hooks/calendar/draft.d.ts +8 -2
  45. package/dist/src/hooks/calendar/draft.js +17 -4
  46. package/dist/src/hooks/calendar/index.d.ts +6 -3
  47. package/dist/src/hooks/calendar/index.js +5 -2
  48. package/dist/src/hooks/calendar/instance.d.ts +2 -1
  49. package/dist/src/hooks/calendar/instance.js +14 -1
  50. package/dist/src/hooks/calendar/useCalendarJump.d.ts +0 -2
  51. package/dist/src/hooks/calendar/useCalendarJump.js +3 -5
  52. package/dist/src/hooks/calendar/useCalendarScheduling.d.ts +33 -0
  53. package/dist/src/hooks/calendar/useCalendarScheduling.js +118 -0
  54. package/dist/src/hooks/calendar/useCalendarTasks.d.ts +53 -0
  55. package/dist/src/hooks/calendar/useCalendarTasks.js +105 -0
  56. package/dist/src/hooks/calendar/useCalendarWrites.d.ts +18 -2
  57. package/dist/src/hooks/calendar/useCalendarWrites.js +19 -6
  58. package/dist/src/hooks/calendar/useCalendars.d.ts +3 -0
  59. package/dist/src/hooks/calendar/useCalendars.js +13 -5
  60. package/dist/src/hooks/calendar/useDraftSession.d.ts +32 -0
  61. package/dist/src/hooks/calendar/useDraftSession.js +106 -0
  62. package/dist/src/hooks/calendar/useMoveEvent.d.ts +4 -0
  63. package/dist/src/hooks/calendar/useMoveEvent.js +62 -0
  64. package/dist/src/hooks/use-system-update.js +3 -5
  65. package/dist/src/hooks/useApplyLabel.js +1 -1
  66. package/dist/src/hooks/useCalendarData.d.ts +9 -2
  67. package/dist/src/hooks/useCalendarData.js +22 -5
  68. package/dist/src/hooks/useCalendarSidePane.d.ts +14 -0
  69. package/dist/src/hooks/useCalendarSidePane.js +30 -0
  70. package/dist/src/hooks/useComposeLanguages.js +1 -1
  71. package/dist/src/hooks/useDeleteMessages.js +1 -1
  72. package/dist/src/hooks/useEmptyTrash.js +1 -1
  73. package/dist/src/hooks/useEscalatedActions.js +1 -1
  74. package/dist/src/hooks/useFilters.d.ts +1 -1
  75. package/dist/src/hooks/useLabels.d.ts +1 -1
  76. package/dist/src/hooks/useMarkAsRead.js +1 -1
  77. package/dist/src/hooks/useMoveMessages.js +1 -1
  78. package/dist/src/hooks/useRefreshControl.js +4 -8
  79. package/dist/src/hooks/useReportSpam.js +1 -1
  80. package/dist/src/hooks/useSignature.js +1 -1
  81. package/dist/src/hooks/useStaleAccountSync.js +4 -4
  82. package/dist/src/hooks/useStarredThreads.d.ts +1 -1
  83. package/dist/src/hooks/useToggleStar.js +1 -1
  84. package/dist/src/hooks/useToggleTrusted.js +1 -1
  85. package/dist/src/hooks/useTriggerSync.d.ts +1 -1
  86. package/dist/src/hooks/useUpdateAddressFlags.js +1 -1
  87. package/dist/src/hooks/useWarningsAttention.js +1 -3
  88. package/dist/src/lib/calendar-route.d.ts +6 -0
  89. package/dist/src/lib/calendar-route.js +14 -0
  90. package/dist/src/lib/calendar-side-pane-pref.d.ts +14 -0
  91. package/dist/src/lib/calendar-side-pane-pref.js +27 -0
  92. package/dist/src/lib/error-classifier.d.ts +5 -30
  93. package/dist/src/lib/error-classifier.js +7 -10
  94. package/dist/src/lib/escalate.d.ts +6 -0
  95. package/dist/src/lib/escalate.js +16 -0
  96. package/dist/src/lib/intelligence-pref.js +3 -2
  97. package/dist/src/lib/new-event-range.d.ts +26 -0
  98. package/dist/src/lib/new-event-range.js +69 -0
  99. package/dist/src/lib/query-error-handler.d.ts +2 -6
  100. package/dist/src/lib/query-error-handler.js +5 -14
  101. package/dist/src/lib/signed-out.d.ts +13 -0
  102. package/dist/src/lib/signed-out.js +28 -0
  103. package/dist/src/routeTree.gen.d.ts +98 -19
  104. package/dist/src/routeTree.gen.js +32 -1
  105. package/dist/src/routes/__root.js +8 -2
  106. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.d.ts +5 -0
  107. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.js +11 -0
  108. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.d.ts +5 -0
  109. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.js +12 -0
  110. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.d.ts +1 -1
  111. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.js +4 -13
  112. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.d.ts +5 -0
  113. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.js +14 -0
  114. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.d.ts +1 -1
  115. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.js +4 -4
  116. package/dist/src/routes/calendar/$view.$date/$calendarObjectId.d.ts +1 -1
  117. package/dist/src/routes/calendar/$view.$date/index.d.ts +1 -6
  118. package/dist/src/routes/calendar/$view.$date/index.js +3 -10
  119. package/dist/src/routes/calendar/$view.$date/new.d.ts +6 -2
  120. package/dist/src/routes/calendar/$view.$date/new.js +8 -13
  121. package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.d.ts +1 -1
  122. package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.js +2 -2
  123. package/dist/src/routes/calendar/$view.$date/task.$calendarTaskId.d.ts +5 -0
  124. package/dist/src/routes/calendar/$view.$date/task.$calendarTaskId.js +16 -0
  125. package/dist/src/routes/calendar/$view.$date.d.ts +1 -1
  126. package/dist/src/routes/calendar/$view.$date.js +14 -50
  127. package/dist/src/routes/calendar/index.d.ts +1 -1
  128. package/dist/src/routes/calendar/index.js +2 -1
  129. package/dist/src/routes/calendar.d.ts +4 -9
  130. package/dist/src/routes/calendar.js +10 -35
  131. package/dist/src/routes/mail/index.d.ts +1 -1
  132. package/dist/src/routes/mail/index.js +7 -2
  133. package/dist/src/routes/mail.js +6 -5
  134. package/dist/src/routes/settings/calendars.js +2 -1
  135. package/dist/src/routing/app-switch.d.ts +11 -0
  136. package/dist/src/routing/app-switch.js +35 -0
  137. package/dist/src/routing/calendar.d.ts +45 -4
  138. package/dist/src/routing/calendar.js +135 -13
  139. package/dist/src/routing/fragment.d.ts +1 -1
  140. package/dist/src/routing/fragment.js +6 -1
  141. package/dist/src/routing/index.d.ts +2 -1
  142. package/dist/src/routing/index.js +2 -1
  143. package/package.json +2 -2
  144. package/dist/src/components/calendar/CalendarComposePane.d.ts +0 -49
  145. package/dist/src/components/calendar/CalendarComposePane.js +0 -8
  146. package/dist/src/components/calendar/CalendarComposeSeed.d.ts +0 -7
  147. package/dist/src/components/calendar/CalendarComposeSeed.js +0 -19
  148. package/dist/src/components/calendar/CalendarEventPane.d.ts +0 -48
  149. package/dist/src/components/calendar/CalendarEventPane.js +0 -48
  150. package/dist/src/components/calendar/CalendarShell.d.ts +0 -43
  151. package/dist/src/components/calendar/CalendarShell.js +0 -35
  152. package/dist/src/components/calendar/CalendarViewPlaceholder.d.ts +0 -1
  153. package/dist/src/components/calendar/CalendarViewPlaceholder.js +0 -5
  154. package/dist/src/components/calendar/CalendarWorkspace.d.ts +0 -49
  155. package/dist/src/components/calendar/CalendarWorkspace.js +0 -65
  156. package/dist/src/components/calendar/OpenCalendarEvent.d.ts +0 -20
  157. package/dist/src/components/calendar/OpenCalendarEvent.js +0 -169
  158. package/dist/src/components/calendar/WriteCalendarEvent.d.ts +0 -13
  159. package/dist/src/components/calendar/WriteCalendarEvent.js +0 -59
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The one draft the calendar holds, and every way it moves.
3
+ *
4
+ * The quick-create popup, the advanced sidebar and the block on the grid all
5
+ * show this one draft. A new selection moves it rather than opening a second.
6
+ * A click outside the popup removes it, typed or not, with nothing kept (M1).
7
+ * Nothing here reaches the API or the address: the screen reads the state and
8
+ * runs the save and the navigations itself.
9
+ */
10
+ import type { CalendarSlotPick, GridGesture, GuestEntry } from "@remit/ui";
11
+ export interface SessionDraft {
12
+ range: CalendarSlotPick;
13
+ title: string;
14
+ location: string;
15
+ calendarId: string;
16
+ guests: GuestEntry[];
17
+ }
18
+ export type DraftStatus = "editing" | "saving" | "failed";
19
+ export type DraftSession = {
20
+ mode: "idle";
21
+ dragging: CalendarSlotPick | null;
22
+ } | {
23
+ mode: "quick";
24
+ dragging: CalendarSlotPick | null;
25
+ draft: SessionDraft;
26
+ status: DraftStatus;
27
+ problem: string;
28
+ } | {
29
+ mode: "sidebar";
30
+ dragging: CalendarSlotPick | null;
31
+ draft: SessionDraft;
32
+ };
33
+ /** What else is up on the screen, which the session does not own but answers to. */
34
+ export interface SessionLayers {
35
+ /** An event popup is open over the grid. */
36
+ eventPopup: boolean;
37
+ /** The advanced sidebar is open, on a new event or a stored one. */
38
+ sidebar: boolean;
39
+ /** The nav slide-over is open on a phone. */
40
+ nav: boolean;
41
+ }
42
+ export type SessionAction = {
43
+ type: "gesture";
44
+ gesture: GridGesture;
45
+ layers: SessionLayers;
46
+ } | {
47
+ type: "new-event";
48
+ range: CalendarSlotPick;
49
+ } | {
50
+ type: "outside";
51
+ } | {
52
+ type: "escape";
53
+ layers: SessionLayers;
54
+ } | {
55
+ type: "change";
56
+ draft: SessionDraft;
57
+ } | {
58
+ type: "save";
59
+ } | {
60
+ type: "saved";
61
+ } | {
62
+ type: "save-failed";
63
+ problem: string;
64
+ } | {
65
+ type: "expand";
66
+ } | {
67
+ type: "sidebar-range";
68
+ range: CalendarSlotPick;
69
+ } | {
70
+ type: "sidebar-closed";
71
+ };
72
+ export declare const IDLE: DraftSession;
73
+ /** Which layer Esc closes: only the top one, a drag first. */
74
+ export type EscapeTarget = "drag" | "popup" | "event-popup" | "sidebar" | "nav";
75
+ export declare function escapeTarget(session: DraftSession, layers: SessionLayers): EscapeTarget | null;
76
+ export declare function draftSessionReducer(session: DraftSession, action: SessionAction): DraftSession;
77
+ /** The range the grid draws: the one being dragged, else the draft's. */
78
+ export declare function drawnRange(session: DraftSession): CalendarSlotPick | null;
@@ -0,0 +1,110 @@
1
+ export const IDLE = { mode: "idle", dragging: null };
2
+ const quick = (draft) => ({
3
+ mode: "quick",
4
+ dragging: null,
5
+ draft,
6
+ status: "editing",
7
+ problem: "",
8
+ });
9
+ const blank = (range) => ({
10
+ range,
11
+ title: "",
12
+ location: "",
13
+ calendarId: "",
14
+ guests: [],
15
+ });
16
+ export function escapeTarget(session, layers) {
17
+ if (session.dragging)
18
+ return "drag";
19
+ if (session.mode === "quick")
20
+ return "popup";
21
+ if (layers.eventPopup)
22
+ return "event-popup";
23
+ if (layers.sidebar)
24
+ return "sidebar";
25
+ if (layers.nav)
26
+ return "nav";
27
+ return null;
28
+ }
29
+ /** A finished range: it opens the draft, or moves the one already open. */
30
+ function settleRange(session, range) {
31
+ if (session.mode === "quick")
32
+ return {
33
+ ...session,
34
+ dragging: null,
35
+ draft: { ...session.draft, range },
36
+ status: session.status === "saving" ? "saving" : "editing",
37
+ };
38
+ if (session.mode === "sidebar")
39
+ return { ...session, dragging: null, draft: { ...session.draft, range } };
40
+ return quick(blank(range));
41
+ }
42
+ function onGesture(session, gesture, layers) {
43
+ switch (gesture.type) {
44
+ case "drag":
45
+ return { ...session, dragging: gesture.range };
46
+ case "drag-cancel":
47
+ return { ...session, dragging: null };
48
+ case "drag-end":
49
+ case "keyboard":
50
+ if (layers.sidebar && session.mode !== "sidebar")
51
+ return { mode: "sidebar", dragging: null, draft: blank(gesture.range) };
52
+ return settleRange(session, gesture.range);
53
+ case "click":
54
+ if (session.mode === "quick")
55
+ return IDLE;
56
+ if (session.mode === "sidebar" || layers.sidebar)
57
+ return { ...session, dragging: null };
58
+ if (layers.eventPopup)
59
+ return { ...session, dragging: null };
60
+ return quick(blank(gesture.range));
61
+ }
62
+ }
63
+ export function draftSessionReducer(session, action) {
64
+ switch (action.type) {
65
+ case "gesture":
66
+ return onGesture(session, action.gesture, action.layers);
67
+ case "new-event":
68
+ return quick(blank(action.range));
69
+ case "outside":
70
+ return session.mode === "quick" ? IDLE : session;
71
+ case "escape": {
72
+ const target = escapeTarget(session, action.layers);
73
+ if (target === "drag")
74
+ return { ...session, dragging: null };
75
+ if (target === "popup")
76
+ return IDLE;
77
+ return session;
78
+ }
79
+ case "change":
80
+ if (session.mode === "idle")
81
+ return session;
82
+ return { ...session, draft: action.draft };
83
+ case "save":
84
+ if (session.mode !== "quick")
85
+ return session;
86
+ return { ...session, status: "saving", problem: "" };
87
+ case "saved":
88
+ return IDLE;
89
+ case "save-failed":
90
+ if (session.mode !== "quick")
91
+ return session;
92
+ return { ...session, status: "failed", problem: action.problem };
93
+ case "expand":
94
+ if (session.mode !== "quick")
95
+ return session;
96
+ return { mode: "sidebar", dragging: null, draft: session.draft };
97
+ case "sidebar-range":
98
+ if (session.mode === "sidebar")
99
+ return { ...session, draft: { ...session.draft, range: action.range } };
100
+ return { mode: "sidebar", dragging: null, draft: blank(action.range) };
101
+ case "sidebar-closed":
102
+ return session.mode === "sidebar" ? IDLE : session;
103
+ }
104
+ }
105
+ /** The range the grid draws: the one being dragged, else the draft's. */
106
+ export function drawnRange(session) {
107
+ if (session.dragging)
108
+ return session.dragging;
109
+ return session.mode === "idle" ? null : session.draft.range;
110
+ }
@@ -10,7 +10,7 @@
10
10
  * `location` and `description` a listing never carried and quietly erase them.
11
11
  */
12
12
  import type { RemitImapCreateCalendarEventInput, RemitImapUpdateCalendarEventInput } from "@remit/api-http-client/types.gen.ts";
13
- import { type CalendarEventData, type EventDraft } from "@remit/ui";
13
+ import { type CalendarEventData, type EventDraft, type GuestEntry } from "@remit/ui";
14
14
  export type DraftRefusal = {
15
15
  ok: false;
16
16
  problem: string;
@@ -45,6 +45,7 @@ export declare function draftFromEvent(event: CalendarEventData, stored: {
45
45
  repeat: string;
46
46
  location: string;
47
47
  notes: string;
48
+ guests: GuestEntry[];
48
49
  }): EventDraft;
49
50
  /**
50
51
  * The draft's wall clock, pinned to an instant on the clock it was read on.
@@ -55,5 +56,10 @@ export declare function timesFor(draft: EventDraft, clock: string): {
55
56
  start: string;
56
57
  end: string;
57
58
  };
58
- export declare function createInputFromDraft(draft: EventDraft, zones: DraftZones): CreateInput;
59
+ /** The guest list as the API takes it: every entry an address, named or not. */
60
+ export declare const attendeesOfDraft: (draft: Pick<EventDraft, "guests">) => {
61
+ email: string;
62
+ displayName: string;
63
+ }[];
64
+ export declare function createInputFromDraft(draft: EventDraft, zones: DraftZones, organizerAccountId: string): CreateInput;
59
65
  export declare function patchFromDrafts(before: EventDraft, after: EventDraft, zones: DraftZones): UpdatePatch;
@@ -1,4 +1,4 @@
1
- import { lastDayOf } from "@remit/ui";
1
+ import { invalidGuest, lastDayOf, } from "@remit/ui";
2
2
  import { moveRule, rruleFromText } from "./recurrence-rule";
3
3
  import { addDays, isoAtInZone, isoOnClock } from "./window";
4
4
  /** A blank event, an hour long, at the start of a working day. */
@@ -12,7 +12,7 @@ export function emptyDraft(date, calendarId) {
12
12
  allDay: false,
13
13
  calendarId,
14
14
  location: "",
15
- guests: "",
15
+ guests: [],
16
16
  notes: "",
17
17
  repeat: "",
18
18
  };
@@ -32,7 +32,7 @@ export function draftFromEvent(event, stored) {
32
32
  allDay: event.allDay,
33
33
  calendarId: event.calendarId,
34
34
  location: stored.location,
35
- guests: "",
35
+ guests: stored.guests,
36
36
  notes: stored.notes,
37
37
  repeat: stored.repeat,
38
38
  };
@@ -82,15 +82,24 @@ function refuse(draft, checkRepeat) {
82
82
  if (!draft.allDay &&
83
83
  `${draft.endDate}T${draft.endTime}` <= `${draft.date}T${draft.startTime}`)
84
84
  return "The end is not after the start. Move one of them.";
85
+ const badGuest = invalidGuest(draft.guests);
86
+ if (badGuest)
87
+ return `${badGuest.text} is not an email address. Fix or remove it to save.`;
85
88
  if (checkRepeat && rruleFromText(draft.repeat) === undefined)
86
89
  return "This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.";
87
90
  return "";
88
91
  }
89
- export function createInputFromDraft(draft, zones) {
92
+ /** The guest list as the API takes it: every entry an address, named or not. */
93
+ export const attendeesOfDraft = (draft) => draft.guests
94
+ .filter((guest) => guest.valid)
95
+ .map((guest) => ({ email: guest.email, displayName: guest.displayName }));
96
+ const guestKey = (draft) => JSON.stringify(attendeesOfDraft(draft));
97
+ export function createInputFromDraft(draft, zones, organizerAccountId) {
90
98
  const problem = refuse(draft, true);
91
99
  if (problem !== "")
92
100
  return { ok: false, problem };
93
101
  const { start, end } = timesFor(draft, zones.clock);
102
+ const attendees = attendeesOfDraft(draft);
94
103
  return {
95
104
  ok: true,
96
105
  input: {
@@ -103,6 +112,8 @@ export function createInputFromDraft(draft, zones) {
103
112
  allDay: draft.allDay,
104
113
  ...(zones.anchor === "" ? {} : { timeZone: zones.anchor }),
105
114
  recurrenceRule: storedRule(draft, start, zones),
115
+ attendees,
116
+ ...(attendees.length === 0 ? {} : { organizerAccountId }),
106
117
  },
107
118
  };
108
119
  }
@@ -138,5 +149,7 @@ export function patchFromDrafts(before, after, zones) {
138
149
  }
139
150
  if (repeatChanged)
140
151
  patch.recurrenceRule = storedRule(after, start, zones);
152
+ if (guestKey(after) !== guestKey(before))
153
+ patch.attendees = attendeesOfDraft(after);
141
154
  return { ok: true, patch };
142
155
  }
@@ -6,8 +6,8 @@
6
6
  * of them are on screen, and a write invalidates what all of them are showing.
7
7
  */
8
8
  export { type AgendaRange, busySpansByDate, CAP_WEEKS, datesInRange, extendRangeEnd, extendRangeStart, type FreeLookup, freeStretchesByDate, LEAD_IN, LEAD_OUT, liftRangeCeiling, liftRangeFloor, PAGE, rangeAround, rangeAtCeiling, rangeAtFloor, rangeCovering, weekKeyOf, weekWindowsOver, } from "./agenda-window";
9
- export { type CreateInput, createInputFromDraft, type DraftRefusal, type DraftZones, draftFromEvent, emptyDraft, patchFromDrafts, type UpdatePatch, } from "./draft";
10
- export { anchorZoneFor, type CalendarInstanceRef, type CalendarJump, calendarInstanceId, calendarJumpOf, deviceTimeZone, isDrawnInstance, readCalendarInstanceId, seriesOccurrenceOf, toCalendarDescriptor, toCalendarEventData, UNZONED_CALENDAR, } from "./instance";
9
+ export { attendeesOfDraft, type CreateInput, createInputFromDraft, type DraftRefusal, type DraftZones, draftFromEvent, emptyDraft, patchFromDrafts, type UpdatePatch, } from "./draft";
10
+ export { anchorZoneFor, type CalendarInstanceRef, type CalendarJump, calendarInstanceId, calendarJumpOf, deviceTimeZone, isDrawnInstance, readCalendarInstanceId, rsvpOfParticipation, seriesOccurrenceOf, toCalendarDescriptor, toCalendarEventData, UNZONED_CALENDAR, } from "./instance";
11
11
  export { moveRule, rruleFromText, textFromRrule } from "./recurrence-rule";
12
12
  export { type CalendarResourceText, rruleFromIcalData, storedAnchorZone, textFromIcalData, } from "./resource";
13
13
  export { type CalendarSelection, selectCalendarIds, useCalendarSelection, useDrawnEvents, } from "./selection";
@@ -17,8 +17,11 @@ export { type CalendarEventResource, useCalendarEvent, } from "./useCalendarEven
17
17
  export { CALENDAR_WINDOW_STALE_TIME, type CalendarEventWeeksResult, type CalendarEventWindowRequest, type CalendarEventWindowResult, useCalendarEventWeeks, useCalendarEventWindow, usePrefetchAdjacentWindows, } from "./useCalendarEvents";
18
18
  export { type CalendarFreeBusyResult, useCalendarFreeBusyWeeks, } from "./useCalendarFreeBusy";
19
19
  export { type CalendarJumpSearch, useCalendarJump } from "./useCalendarJump";
20
+ export { type CalendarSenders, type SendsFollowUp, useCalendarSenders, useGuestSuggestions, useSendsFollowUp, } from "./useCalendarScheduling";
20
21
  export { type CalendarSuggestionAnswers, type CalendarSuggestionsResult, type PendingCalendarSuggestionResult, type SuggestionAnswer, useCalendarSuggestionAnswers, useMessageCalendarSuggestions, usePendingCalendarSuggestion, usePendingCalendarSuggestions, } from "./useCalendarSuggestions";
21
22
  export { type CalendarsResult, useCalendars } from "./useCalendars";
22
- export { type CalendarWriteOutcome, type CalendarWrites, type ScopedWrite, useCalendarWrites, useInvalidateCalendarReads, } from "./useCalendarWrites";
23
+ export { type CalendarTaskRead, type TaskWriteOutcome, toTaskData, useCalendarTask, useCalendarTasks, useCalendarTaskWrites, } from "./useCalendarTasks";
24
+ export { type CalendarCreateOutcome, type CalendarWriteOutcome, type CalendarWrites, type ScopedWrite, useCalendarWrites, useInvalidateCalendarReads, } from "./useCalendarWrites";
23
25
  export { useDraftClashes } from "./useDraftClashes";
26
+ export { type MoveEvent, useMoveEvent } from "./useMoveEvent";
24
27
  export { addDays, type CalendarWindow, calendarWindow, calendarWindowOfDays, isoAt, isoAtInZone, isoOnClock, startOfDay, } from "./window";
@@ -6,8 +6,8 @@
6
6
  * of them are on screen, and a write invalidates what all of them are showing.
7
7
  */
8
8
  export { busySpansByDate, CAP_WEEKS, datesInRange, extendRangeEnd, extendRangeStart, freeStretchesByDate, LEAD_IN, LEAD_OUT, liftRangeCeiling, liftRangeFloor, PAGE, rangeAround, rangeAtCeiling, rangeAtFloor, rangeCovering, weekKeyOf, weekWindowsOver, } from "./agenda-window";
9
- export { createInputFromDraft, draftFromEvent, emptyDraft, patchFromDrafts, } from "./draft";
10
- export { anchorZoneFor, calendarInstanceId, calendarJumpOf, deviceTimeZone, isDrawnInstance, readCalendarInstanceId, seriesOccurrenceOf, toCalendarDescriptor, toCalendarEventData, UNZONED_CALENDAR, } from "./instance";
9
+ export { attendeesOfDraft, createInputFromDraft, draftFromEvent, emptyDraft, patchFromDrafts, } from "./draft";
10
+ export { anchorZoneFor, calendarInstanceId, calendarJumpOf, deviceTimeZone, isDrawnInstance, readCalendarInstanceId, rsvpOfParticipation, seriesOccurrenceOf, toCalendarDescriptor, toCalendarEventData, UNZONED_CALENDAR, } from "./instance";
11
11
  export { moveRule, rruleFromText, textFromRrule } from "./recurrence-rule";
12
12
  export { rruleFromIcalData, storedAnchorZone, textFromIcalData, } from "./resource";
13
13
  export { selectCalendarIds, useCalendarSelection, useDrawnEvents, } from "./selection";
@@ -17,8 +17,11 @@ export { useCalendarEvent, } from "./useCalendarEvent";
17
17
  export { CALENDAR_WINDOW_STALE_TIME, useCalendarEventWeeks, useCalendarEventWindow, usePrefetchAdjacentWindows, } from "./useCalendarEvents";
18
18
  export { useCalendarFreeBusyWeeks, } from "./useCalendarFreeBusy";
19
19
  export { useCalendarJump } from "./useCalendarJump";
20
+ export { useCalendarSenders, useGuestSuggestions, useSendsFollowUp, } from "./useCalendarScheduling";
20
21
  export { useCalendarSuggestionAnswers, useMessageCalendarSuggestions, usePendingCalendarSuggestion, usePendingCalendarSuggestions, } from "./useCalendarSuggestions";
21
22
  export { useCalendars } from "./useCalendars";
23
+ export { toTaskData, useCalendarTask, useCalendarTasks, useCalendarTaskWrites, } from "./useCalendarTasks";
22
24
  export { useCalendarWrites, useInvalidateCalendarReads, } from "./useCalendarWrites";
23
25
  export { useDraftClashes } from "./useDraftClashes";
26
+ export { useMoveEvent } from "./useMoveEvent";
24
27
  export { addDays, calendarWindow, calendarWindowOfDays, isoAt, isoAtInZone, isoOnClock, startOfDay, } from "./window";
@@ -6,7 +6,7 @@
6
6
  * recurrence: the server returns instances, and this reads them.
7
7
  */
8
8
  import type { RemitImapCalendarEventInstance, RemitImapCalendarResponse } from "@remit/api-http-client/types.gen.ts";
9
- import type { CalendarDescriptor, CalendarEventData } from "@remit/ui";
9
+ import type { CalendarDescriptor, CalendarEventData, RsvpState } from "@remit/ui";
10
10
  /** The device's own clock, the only zone a browser can honestly draw in. */
11
11
  export declare const deviceTimeZone: () => string;
12
12
  /** A collection that names no zone of its own, spelled the way the API spells it. */
@@ -19,6 +19,7 @@ export declare const UNZONED_CALENDAR = "";
19
19
  * sends nothing, which the server reads as UTC.
20
20
  */
21
21
  export declare function anchorZoneFor(collectionZone: string): string;
22
+ export declare const rsvpOfParticipation: (participation: RemitImapCalendarEventInstance["participation"]) => RsvpState;
22
23
  export declare function calendarInstanceId(calendarObjectId: string, recurrenceId: string): string;
23
24
  export interface CalendarInstanceRef {
24
25
  calendarObjectId: string;
@@ -26,6 +26,19 @@ const COLORS = {
26
26
  Cal5: "cal-5",
27
27
  Cal6: "cal-6",
28
28
  };
29
+ /**
30
+ * The reader's own answer, as an event is drawn. An event the reader
31
+ * organizes, or one nobody was invited to, is theirs and drawn as a yes.
32
+ */
33
+ const RSVP_OF = {
34
+ Unscheduled: "accepted",
35
+ Organizer: "accepted",
36
+ Accepted: "accepted",
37
+ Tentative: "tentative",
38
+ Declined: "declined",
39
+ NeedsAction: "noReply",
40
+ };
41
+ export const rsvpOfParticipation = (participation) => RSVP_OF[participation];
29
42
  const ZONES = {
30
43
  Local: "local",
31
44
  Explicit: "explicit",
@@ -126,7 +139,7 @@ export function toCalendarEventData(instance, timeZone, clockZone) {
126
139
  location: "",
127
140
  notes: "",
128
141
  attendees: [],
129
- myRsvp: "accepted",
142
+ myRsvp: RSVP_OF[instance.participation],
130
143
  threadId: "",
131
144
  threadSubject: "",
132
145
  timeZone,
@@ -10,8 +10,6 @@ export type CalendarJumpSearch = {
10
10
  kind: "Deleted";
11
11
  } | {
12
12
  kind: "NoOccurrenceFound";
13
- } | {
14
- kind: "SignedOut";
15
13
  } | {
16
14
  kind: "Failed";
17
15
  reason: string;
@@ -5,8 +5,8 @@ import { getErrorStatus, softErrorStatuses } from "../../lib/error-classifier";
5
5
  import { calendarJumpOf, deviceTimeZone } from "./instance";
6
6
  const WINDOW_MS = 365 * 24 * 60 * 60_000;
7
7
  const DAY_MS = 24 * 60 * 60_000;
8
- const LISTING_META = softErrorStatuses(401);
9
- const RESOURCE_META = softErrorStatuses(401, 404);
8
+ const LISTING_META = softErrorStatuses();
9
+ const RESOURCE_META = softErrorStatuses(404);
10
10
  const instant = (ms) => new Date(ms).toISOString().replace(/\.\d{3}Z$/, "+00:00");
11
11
  const reasonOf = (error) => {
12
12
  const message = error instanceof Error && error.message !== ""
@@ -78,9 +78,7 @@ export function useCalendarJump(calendarObjectId, enabled) {
78
78
  first.error,
79
79
  ].find((error) => error !== null);
80
80
  if (failure !== undefined) {
81
- return getErrorStatus(failure) === 401
82
- ? { kind: "SignedOut" }
83
- : { kind: "Failed", reason: reasonOf(failure) };
81
+ return { kind: "Failed", reason: reasonOf(failure) };
84
82
  }
85
83
  if (deleted)
86
84
  return { kind: "Deleted" };
@@ -0,0 +1,33 @@
1
+ import type { RemitImapCalendarSchedulingSend } from "@remit/api-http-client/types.gen.ts";
2
+ import type { CalendarSender, GuestSuggestion } from "@remit/ui";
3
+ export interface CalendarSenders {
4
+ senders: CalendarSender[];
5
+ /**
6
+ * The account the editor starts on: the default sender in effect, as the
7
+ * settings API answers it. Absent while it loads, or when no account sends mail.
8
+ */
9
+ defaultSenderId: string | undefined;
10
+ setDefaultSender: (accountId: string) => Promise<void>;
11
+ }
12
+ /** The reader's accounts that can send mail, and the default one. */
13
+ export declare function useCalendarSenders(): CalendarSenders;
14
+ /** Contacts matching what is typed in a Guests field, as the composer finds them. */
15
+ export declare function useGuestSuggestions(query: string): GuestSuggestion[];
16
+ export interface SendsFollowUp {
17
+ /** The guests a message has not reached, once its row settled as failed. */
18
+ missed: string[];
19
+ /** Sends every failed message again. */
20
+ retry: () => Promise<void>;
21
+ /** Why the state of a queued message could not be read; null when every read answered. */
22
+ checkError: unknown;
23
+ /** The guests whose message could not be followed, while `checkError` stands. */
24
+ unchecked: string[];
25
+ /** Reads the unanswered rows again. */
26
+ recheck: () => void;
27
+ }
28
+ /**
29
+ * Follows each queued scheduling message until it settles. A row that left the
30
+ * outbox was sent and filed, which reads as a 404 here and as reached; any
31
+ * other failed read is said, never taken as reached.
32
+ */
33
+ export declare function useSendsFollowUp(sends: readonly RemitImapCalendarSchedulingSend[]): SendsFollowUp;
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Who an event's invitations go out from, who can be invited, and whether the
3
+ * messages a save queued reached their guests.
4
+ *
5
+ * A save answers with the scheduling messages it put in the outbox. They are
6
+ * sent after the save returns, so whether each one went is followed here, by
7
+ * reading the outbox row until the send worker settles it.
8
+ */
9
+ import { addressOperationsSearchAddressesOptions, configOperationsGetConfigOptions, outboxDetailOperationsGetOutboxMessageOptions, outboxDetailOperationsSendOutboxMessageMutation, userSettingsOperationsGetUserSettingsOptions, userSettingsOperationsUpdateUserSettingsMutation, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
10
+ import { useMutation, useQueries, useQuery, useQueryClient, } from "@tanstack/react-query";
11
+ import { useCallback, useMemo } from "react";
12
+ import { getErrorStatus } from "../../lib/error-classifier";
13
+ import { useDebouncedValue } from "../useDebouncedValue";
14
+ /** The reader's accounts that can send mail, and the default one. */
15
+ export function useCalendarSenders() {
16
+ const queryClient = useQueryClient();
17
+ const { data } = useQuery({
18
+ ...configOperationsGetConfigOptions(),
19
+ staleTime: 60_000,
20
+ });
21
+ const { data: settings } = useQuery(userSettingsOperationsGetUserSettingsOptions());
22
+ const update = useMutation(userSettingsOperationsUpdateUserSettingsMutation());
23
+ const senders = useMemo(() => (data?.accounts ?? [])
24
+ .filter((account) => account.syncedServices.includes("Mail"))
25
+ .map((account) => ({
26
+ accountId: account.accountId,
27
+ email: account.email,
28
+ })), [data?.accounts]);
29
+ const defaultSenderId = settings?.defaultInvitationSenderAccountId;
30
+ const setDefaultSender = useCallback(async (accountId) => {
31
+ await update.mutateAsync({
32
+ body: { defaultInvitationSenderAccountId: accountId },
33
+ });
34
+ await queryClient.invalidateQueries({
35
+ queryKey: userSettingsOperationsGetUserSettingsOptions().queryKey,
36
+ });
37
+ }, [update, queryClient]);
38
+ return { senders, defaultSenderId, setDefaultSender };
39
+ }
40
+ const MIN_QUERY = 2;
41
+ /** Contacts matching what is typed in a Guests field, as the composer finds them. */
42
+ export function useGuestSuggestions(query) {
43
+ const debounced = useDebouncedValue(query.trim(), 200);
44
+ const { data } = useQuery({
45
+ ...addressOperationsSearchAddressesOptions({
46
+ query: { q: debounced, limit: 8 },
47
+ }),
48
+ enabled: debounced.length >= MIN_QUERY,
49
+ });
50
+ return useMemo(() => (data?.items ?? []).map((address) => ({
51
+ email: address.normalizedEmail,
52
+ name: address.displayName ?? "",
53
+ })), [data?.items]);
54
+ }
55
+ const SETTLED = [
56
+ "sent",
57
+ "unfiled",
58
+ "failed",
59
+ "blocked",
60
+ ];
61
+ const MISSED = ["failed", "blocked"];
62
+ /**
63
+ * Follows each queued scheduling message until it settles. A row that left the
64
+ * outbox was sent and filed, which reads as a 404 here and as reached; any
65
+ * other failed read is said, never taken as reached.
66
+ */
67
+ export function useSendsFollowUp(sends) {
68
+ const queryClient = useQueryClient();
69
+ const resend = useMutation(outboxDetailOperationsSendOutboxMessageMutation());
70
+ const results = useQueries({
71
+ queries: sends.map((send) => ({
72
+ ...outboxDetailOperationsGetOutboxMessageOptions({
73
+ path: { outboxMessageId: send.outboxMessageId },
74
+ }),
75
+ meta: { softErrorStatuses: [404] },
76
+ retry: false,
77
+ refetchInterval: (query) => {
78
+ if (query.state.error)
79
+ return false;
80
+ const status = query.state.data?.status;
81
+ return status && SETTLED.includes(status) ? false : 1500;
82
+ },
83
+ })),
84
+ });
85
+ const unreadable = sends.flatMap((send, index) => {
86
+ const result = results[index];
87
+ if (!result?.error || getErrorStatus(result.error) === 404)
88
+ return [];
89
+ return [{ send, error: result.error, refetch: result.refetch }];
90
+ });
91
+ const recheck = () => {
92
+ for (const entry of unreadable)
93
+ void entry.refetch();
94
+ };
95
+ const missed = sends.filter((_, index) => {
96
+ const status = results[index]?.data?.status;
97
+ return status !== undefined && MISSED.includes(status);
98
+ });
99
+ const retry = useCallback(async () => {
100
+ for (const send of missed) {
101
+ await resend.mutateAsync({
102
+ path: { outboxMessageId: send.outboxMessageId },
103
+ });
104
+ await queryClient.invalidateQueries({
105
+ queryKey: outboxDetailOperationsGetOutboxMessageOptions({
106
+ path: { outboxMessageId: send.outboxMessageId },
107
+ }).queryKey,
108
+ });
109
+ }
110
+ }, [missed, resend, queryClient]);
111
+ return {
112
+ missed: missed.map((send) => send.email),
113
+ retry,
114
+ checkError: unreadable[0]?.error ?? null,
115
+ unchecked: unreadable.map((entry) => entry.send.email),
116
+ recheck,
117
+ };
118
+ }
@@ -0,0 +1,53 @@
1
+ import type { RemitImapCalendarTaskResponse, RemitImapCreateCalendarTaskInput, RemitImapUpdateCalendarTaskInput } from "@remit/api-http-client/types.gen.ts";
2
+ import type { CalendarTaskData } from "@remit/ui";
3
+ import type { CalendarWindow } from "./window";
4
+ /** A task as the grid draws it, on its due day. */
5
+ export declare const toTaskData: (task: RemitImapCalendarTaskResponse) => CalendarTaskData;
6
+ export declare function useCalendarTasks(window: CalendarWindow, enabled?: boolean): {
7
+ tasks: RemitImapCalendarTaskResponse[];
8
+ error: import("@remit/api-http-client").CalendarTaskOperationsListCalendarTasksError | null;
9
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<NoInfer<import("@remit/api-http-client").RemitImapCalendarTaskListResponse>, import("@remit/api-http-client").CalendarTaskOperationsListCalendarTasksError>>;
10
+ };
11
+ export type CalendarTaskRead = {
12
+ kind: "loading";
13
+ } | {
14
+ kind: "found";
15
+ task: RemitImapCalendarTaskResponse;
16
+ } | {
17
+ kind: "gone";
18
+ } | {
19
+ kind: "failed";
20
+ error: unknown;
21
+ retry: () => void;
22
+ };
23
+ /** One task by its id, the way the popup opens it from the address. */
24
+ export declare function useCalendarTask(calendarTaskId: string): CalendarTaskRead;
25
+ export type TaskWriteOutcome = {
26
+ kind: "written";
27
+ } | {
28
+ kind: "refused";
29
+ message: string;
30
+ };
31
+ type TaskRef = Pick<RemitImapCalendarTaskResponse, "calendarTaskId" | "calendarId" | "etag">;
32
+ export declare function useCalendarTaskWrites(): {
33
+ createTask: (input: RemitImapCreateCalendarTaskInput) => Promise<{
34
+ kind: "written";
35
+ } | {
36
+ kind: "refused";
37
+ message: string;
38
+ }>;
39
+ updateTask: (task: TaskRef, patch: RemitImapUpdateCalendarTaskInput) => Promise<{
40
+ kind: "written";
41
+ } | {
42
+ kind: "refused";
43
+ message: string;
44
+ }>;
45
+ deleteTask: (task: TaskRef) => Promise<{
46
+ kind: "written";
47
+ } | {
48
+ kind: "refused";
49
+ message: string;
50
+ }>;
51
+ isWriting: boolean;
52
+ };
53
+ export {};