@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,105 @@
1
+ /**
2
+ * Tasks: read for the window on screen, drawn on their due day, and written
3
+ * one at a time. A task lives in a task list (a `VtodoOnly` collection), never
4
+ * in an event calendar, and is drawn on every view whatever calendars are ticked.
5
+ */
6
+ import { calendarTaskDetailOperationsDeleteCalendarTaskMutation, calendarTaskDetailOperationsGetCalendarTaskOptions, calendarTaskDetailOperationsUpdateCalendarTaskMutation, calendarTaskOperationsCreateCalendarTaskMutation, calendarTaskOperationsListCalendarTasksOptions, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
7
+ import { formatErrorMessage } from "@remit/ui";
8
+ import { useMutation, useQuery } from "@tanstack/react-query";
9
+ import { useCallback, useMemo } from "react";
10
+ import { getErrorStatus, softErrorStatuses } from "../../lib/error-classifier";
11
+ import { CALENDAR_WRITE_META, useInvalidateCalendarReads, } from "./useCalendarWrites";
12
+ /** A task as the grid draws it, on its due day. */
13
+ export const toTaskData = (task) => ({
14
+ calendarTaskId: task.calendarTaskId,
15
+ calendarId: task.calendarId,
16
+ title: task.summary,
17
+ due: task.allDay ? task.due.slice(0, 10) : task.dueAt,
18
+ allDay: task.allDay,
19
+ completed: task.completed,
20
+ });
21
+ export function useCalendarTasks(window, enabled = true) {
22
+ const { data, error, refetch } = useQuery({
23
+ ...calendarTaskOperationsListCalendarTasksOptions({
24
+ query: { from: window.from, to: window.to },
25
+ }),
26
+ meta: softErrorStatuses(400, 404),
27
+ enabled,
28
+ });
29
+ const tasks = useMemo(() => data?.items ?? [], [data?.items]);
30
+ return { tasks, error, refetch };
31
+ }
32
+ /** One task by its id, the way the popup opens it from the address. */
33
+ export function useCalendarTask(calendarTaskId) {
34
+ const { data, error, refetch } = useQuery({
35
+ ...calendarTaskDetailOperationsGetCalendarTaskOptions({
36
+ path: { calendarTaskId },
37
+ }),
38
+ meta: softErrorStatuses(404),
39
+ retry: false,
40
+ });
41
+ if (data)
42
+ return { kind: "found", task: data };
43
+ if (error === null)
44
+ return { kind: "loading" };
45
+ if (getErrorStatus(error) === 404)
46
+ return { kind: "gone" };
47
+ return {
48
+ kind: "failed",
49
+ error,
50
+ retry: () => {
51
+ void refetch();
52
+ },
53
+ };
54
+ }
55
+ const refused = (error) => ({
56
+ kind: "refused",
57
+ message: getErrorStatus(error) === 412
58
+ ? "This task changed while you were looking at it. Close it and open it again."
59
+ : formatErrorMessage(error),
60
+ });
61
+ export function useCalendarTaskWrites() {
62
+ const invalidate = useInvalidateCalendarReads();
63
+ const create = useMutation({
64
+ ...calendarTaskOperationsCreateCalendarTaskMutation(),
65
+ meta: CALENDAR_WRITE_META,
66
+ onSuccess: invalidate,
67
+ });
68
+ const update = useMutation({
69
+ ...calendarTaskDetailOperationsUpdateCalendarTaskMutation(),
70
+ meta: CALENDAR_WRITE_META,
71
+ onSuccess: invalidate,
72
+ });
73
+ const remove = useMutation({
74
+ ...calendarTaskDetailOperationsDeleteCalendarTaskMutation(),
75
+ meta: CALENDAR_WRITE_META,
76
+ onSuccess: invalidate,
77
+ });
78
+ const createTask = useCallback((input) => create
79
+ .mutateAsync({ body: input })
80
+ .then(() => ({ kind: "written" }))
81
+ .catch(refused), [create]);
82
+ const updateTask = useCallback((task, patch) => update
83
+ .mutateAsync({
84
+ path: { calendarTaskId: task.calendarTaskId },
85
+ query: { calendarId: task.calendarId },
86
+ headers: { "If-Match": task.etag },
87
+ body: patch,
88
+ })
89
+ .then(() => ({ kind: "written" }))
90
+ .catch(refused), [update]);
91
+ const deleteTask = useCallback((task) => remove
92
+ .mutateAsync({
93
+ path: { calendarTaskId: task.calendarTaskId },
94
+ query: { calendarId: task.calendarId },
95
+ headers: { "If-Match": task.etag },
96
+ })
97
+ .then(() => ({ kind: "written" }))
98
+ .catch(refused), [remove]);
99
+ return {
100
+ createTask,
101
+ updateTask,
102
+ deleteTask,
103
+ isWriting: create.isPending || update.isPending || remove.isPending,
104
+ };
105
+ }
@@ -13,10 +13,26 @@
13
13
  * statuses this surface owns, so a lapsed session takes the screen the way it
14
14
  * does everywhere else.
15
15
  */
16
- import type { RemitImapCreateCalendarEventInput, RemitImapUpdateCalendarEventInput } from "@remit/api-http-client/types.gen.ts";
16
+ import type { RemitImapCalendarSchedulingSend, RemitImapCreateCalendarEventInput, RemitImapUpdateCalendarEventInput } from "@remit/api-http-client/types.gen.ts";
17
17
  import type { RecurrenceScope } from "@remit/ui";
18
+ /** The refusals a calendar surface renders itself. A 401 is not among them. */
19
+ export declare const CALENDAR_WRITE_META: {
20
+ softErrorStatuses: number[];
21
+ };
18
22
  export type CalendarWriteOutcome = {
19
23
  kind: "written";
24
+ sends: RemitImapCalendarSchedulingSend[];
25
+ } | {
26
+ kind: "conflict";
27
+ } | {
28
+ kind: "refused";
29
+ message: string;
30
+ };
31
+ /** A create that lands names the resource it made, so the grid can focus it. */
32
+ export type CalendarCreateOutcome = {
33
+ kind: "created";
34
+ calendarObjectId: string;
35
+ sends: RemitImapCalendarSchedulingSend[];
20
36
  } | {
21
37
  kind: "conflict";
22
38
  } | {
@@ -34,7 +50,7 @@ export interface ScopedWrite {
34
50
  etag: string;
35
51
  }
36
52
  export interface CalendarWrites {
37
- createEvent: (input: RemitImapCreateCalendarEventInput) => Promise<CalendarWriteOutcome>;
53
+ createEvent: (input: RemitImapCreateCalendarEventInput) => Promise<CalendarCreateOutcome>;
38
54
  updateEvent: (write: ScopedWrite, patch: RemitImapUpdateCalendarEventInput) => Promise<CalendarWriteOutcome>;
39
55
  deleteEvent: (write: ScopedWrite) => Promise<CalendarWriteOutcome>;
40
56
  isWriting: boolean;
@@ -19,14 +19,15 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
19
19
  import { useCallback, useMemo } from "react";
20
20
  import { getErrorStatus, softErrorStatuses } from "../../lib/error-classifier";
21
21
  /** The refusals a calendar surface renders itself. A 401 is not among them. */
22
- const CALENDAR_WRITE_META = softErrorStatuses(400, 404, 412);
22
+ export const CALENDAR_WRITE_META = softErrorStatuses(400, 404, 412);
23
23
  /** Every read whose answer a write can change. */
24
24
  const CALENDAR_QUERY_IDS = new Set([
25
25
  "calendarEventOperationsListCalendarEvents",
26
26
  "calendarEventDetailOperationsGetCalendarEvent",
27
27
  "calendarFreeBusyOperationsListCalendarFreeBusy",
28
+ "calendarTaskOperationsListCalendarTasks",
29
+ "calendarTaskDetailOperationsGetCalendarTask",
28
30
  ]);
29
- const WRITTEN = { kind: "written" };
30
31
  const outcomeFor = (error) => getErrorStatus(error) === 412
31
32
  ? { kind: "conflict" }
32
33
  : { kind: "refused", message: formatErrorMessage(error) };
@@ -74,8 +75,14 @@ export function useCalendarWrites() {
74
75
  });
75
76
  const createEvent = useCallback((input) => create
76
77
  .mutateAsync({ body: input })
77
- .then(() => WRITTEN)
78
- .catch(outcomeFor), [create]);
78
+ .then((created) => ({
79
+ kind: "created",
80
+ calendarObjectId: created.calendarObjectId,
81
+ sends: created.sends,
82
+ }))
83
+ .catch((error) => getErrorStatus(error) === 412
84
+ ? { kind: "conflict" }
85
+ : { kind: "refused", message: formatErrorMessage(error) }), [create]);
79
86
  const updateEvent = useCallback((write, patch) => update
80
87
  .mutateAsync({
81
88
  path: { calendarObjectId: write.calendarObjectId },
@@ -83,7 +90,10 @@ export function useCalendarWrites() {
83
90
  headers: { "If-Match": write.etag },
84
91
  body: patch,
85
92
  })
86
- .then(() => WRITTEN)
93
+ .then((updated) => ({
94
+ kind: "written",
95
+ sends: updated.sends,
96
+ }))
87
97
  .catch(outcomeFor), [update]);
88
98
  const deleteEvent = useCallback((write) => remove
89
99
  .mutateAsync({
@@ -91,7 +101,10 @@ export function useCalendarWrites() {
91
101
  query: { calendarId: write.calendarId, ...scopeQuery(write) },
92
102
  headers: { "If-Match": write.etag },
93
103
  })
94
- .then(() => WRITTEN)
104
+ .then((removed) => ({
105
+ kind: "written",
106
+ sends: removed.sends,
107
+ }))
95
108
  .catch(outcomeFor), [remove]);
96
109
  return useMemo(() => ({
97
110
  createEvent,
@@ -2,6 +2,8 @@ import type { RemitImapCalendarResponse } from "@remit/api-http-client/types.gen
2
2
  import type { CalendarColorId, CalendarDescriptor } from "@remit/ui";
3
3
  export interface CalendarsResult {
4
4
  calendars: CalendarDescriptor[];
5
+ /** The task lists: collections that hold tasks and no events, left out of `calendars`. */
6
+ taskLists: CalendarDescriptor[];
5
7
  /** The collections as the API returned them, for a surface that manages them. */
6
8
  collections: RemitImapCalendarResponse[];
7
9
  colorByCalendarId: Record<string, CalendarColorId>;
@@ -16,5 +18,6 @@ export interface CalendarsResult {
16
18
  isLoading: boolean;
17
19
  /** Why the listing could not be read; null when it was. */
18
20
  error: unknown;
21
+ retry: () => void;
19
22
  }
20
23
  export declare function useCalendars(): CalendarsResult;
@@ -12,19 +12,27 @@ import { useQuery } from "@tanstack/react-query";
12
12
  import { useMemo } from "react";
13
13
  import { toCalendarDescriptor } from "./instance";
14
14
  export function useCalendars() {
15
- const { data, isLoading, error } = useQuery(calendarOperationsListCalendarsOptions());
15
+ const { data, isLoading, error, refetch } = useQuery(calendarOperationsListCalendarsOptions());
16
16
  return useMemo(() => {
17
- const items = data?.items ?? [];
17
+ const all = data?.items ?? [];
18
+ const items = all.filter((item) => item.componentSet !== "VtodoOnly");
18
19
  const calendars = items.map(toCalendarDescriptor);
20
+ const taskLists = all
21
+ .filter((item) => item.componentSet === "VtodoOnly")
22
+ .map(toCalendarDescriptor);
19
23
  return {
20
24
  calendars,
21
- collections: items,
25
+ taskLists,
26
+ collections: all,
22
27
  colorByCalendarId: Object.fromEntries(calendars.map((calendar) => [calendar.id, calendar.color])),
23
- timeZoneByCalendarId: Object.fromEntries(items.map((item) => [item.calendarId, item.timezone])),
28
+ timeZoneByCalendarId: Object.fromEntries(all.map((item) => [item.calendarId, item.timezone])),
24
29
  defaultCalendarId: (items.find((item) => item.source === "Default") ?? items[0])
25
30
  ?.calendarId ?? "",
26
31
  isLoading,
27
32
  error: error ?? null,
33
+ retry: () => {
34
+ void refetch();
35
+ },
28
36
  };
29
- }, [data, isLoading, error]);
37
+ }, [data, isLoading, error, refetch]);
30
38
  }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The calendar screen's draft session, with everything that answers to it: the
3
+ * grid's gestures, a press outside the popup, Esc, and where focus goes back
4
+ * to. The reducer in `draft-session.ts` decides; this binds it to the page.
5
+ */
6
+ import type { GridGesture } from "@remit/ui";
7
+ import { type Dispatch, type MutableRefObject } from "react";
8
+ import { type DraftSession, type SessionAction, type SessionLayers } from "./draft-session";
9
+ export interface DraftSessionBindings {
10
+ layers: SessionLayers;
11
+ /** A finger's tap on an empty slot selects nothing; a hold does. */
12
+ isPhone: boolean;
13
+ /** Closes the event popup or the sidebar, back to the view. */
14
+ closeToView: () => void;
15
+ closeNav: () => void;
16
+ /** The events on the grid, so a saved event is focused once it is drawn. */
17
+ drawnEvents: readonly unknown[];
18
+ }
19
+ export interface DraftSessionHandle {
20
+ session: DraftSession;
21
+ dispatch: Dispatch<SessionAction>;
22
+ takeGesture: (gesture: GridGesture) => void;
23
+ /** The control focus returns to when quick-create closes unsaved. */
24
+ setOrigin: (element: HTMLElement | null) => void;
25
+ /** The sidebar's own close, asked by Esc; it confirms a touched draft. */
26
+ requestClose: MutableRefObject<(() => void) | null>;
27
+ /** The field quick-create had focus in when it expanded, by its label. */
28
+ carriedFocus: MutableRefObject<string>;
29
+ /** Focus the saved event once the grid draws it. */
30
+ focusSaved: (calendarObjectId: string) => void;
31
+ }
32
+ export declare function useDraftSession({ layers, isPhone, closeToView, closeNav, drawnEvents, }: DraftSessionBindings): DraftSessionHandle;
@@ -0,0 +1,106 @@
1
+ import { useCallback, useEffect, useReducer, useRef, useState, } from "react";
2
+ import { draftSessionReducer, escapeTarget, IDLE, } from "./draft-session";
3
+ /** Presses the grid answers itself, and the popups they open. */
4
+ const GRID_OWNED = "[data-calendar-popover], [data-event-id], [data-task-id], [data-time-columns], [data-all-day-row], [role='dialog']";
5
+ export function useDraftSession({ layers, isPhone, closeToView, closeNav, drawnEvents, }) {
6
+ const [session, dispatch] = useReducer(draftSessionReducer, IDLE);
7
+ const bound = useRef({ session, layers, isPhone, closeToView, closeNav });
8
+ bound.current = { session, layers, isPhone, closeToView, closeNav };
9
+ const origin = useRef(null);
10
+ const requestClose = useRef(null);
11
+ const carriedFocus = useRef("");
12
+ const saved = useRef(false);
13
+ const wasQuick = useRef(false);
14
+ const [focusAfterSave, setFocusAfterSave] = useState("");
15
+ const takeGesture = useCallback((gesture) => {
16
+ const current = bound.current;
17
+ const idle = current.session.mode === "idle";
18
+ if (current.isPhone &&
19
+ gesture.type === "click" &&
20
+ idle &&
21
+ !current.layers.eventPopup)
22
+ return;
23
+ const settles = gesture.type === "click" ||
24
+ gesture.type === "drag-end" ||
25
+ gesture.type === "keyboard";
26
+ if (settles && current.layers.eventPopup)
27
+ current.closeToView();
28
+ if (idle && (gesture.type === "click" || gesture.type === "keyboard"))
29
+ origin.current = gesture.origin;
30
+ if (idle && gesture.type === "drag-end")
31
+ origin.current = document.querySelector("[role='grid'][aria-label='Time grid']");
32
+ dispatch({ type: "gesture", gesture, layers: current.layers });
33
+ }, []);
34
+ useEffect(() => {
35
+ const onPointerDown = (event) => {
36
+ if (!(event.target instanceof Element))
37
+ return;
38
+ if (event.target.closest(GRID_OWNED))
39
+ return;
40
+ if (bound.current.layers.eventPopup)
41
+ bound.current.closeToView();
42
+ dispatch({ type: "outside" });
43
+ };
44
+ const onKeyDown = (event) => {
45
+ if (event.key !== "Escape" || event.defaultPrevented)
46
+ return;
47
+ const { session: now, layers: up } = bound.current;
48
+ const target = escapeTarget(now, up);
49
+ if (target === null || target === "drag")
50
+ return;
51
+ event.preventDefault();
52
+ if (target === "event-popup")
53
+ bound.current.closeToView();
54
+ else if (target === "sidebar")
55
+ requestClose.current?.();
56
+ else if (target === "nav")
57
+ bound.current.closeNav();
58
+ else
59
+ dispatch({ type: "escape", layers: up });
60
+ };
61
+ document.addEventListener("pointerdown", onPointerDown, true);
62
+ window.addEventListener("keydown", onKeyDown);
63
+ return () => {
64
+ document.removeEventListener("pointerdown", onPointerDown, true);
65
+ window.removeEventListener("keydown", onKeyDown);
66
+ };
67
+ }, []);
68
+ useEffect(() => {
69
+ const isQuick = session.mode === "quick";
70
+ if (wasQuick.current && session.mode === "idle" && !saved.current)
71
+ origin.current?.focus();
72
+ if (isQuick)
73
+ saved.current = false;
74
+ wasQuick.current = isQuick;
75
+ }, [session.mode]);
76
+ useEffect(() => {
77
+ if (focusAfterSave === "" || drawnEvents.length === 0)
78
+ return;
79
+ const chip = document.querySelector(`[data-event-id^="${CSS.escape(focusAfterSave)}"]`);
80
+ if (!chip)
81
+ return;
82
+ chip.focus();
83
+ setFocusAfterSave("");
84
+ }, [focusAfterSave, drawnEvents]);
85
+ const sidebarOpen = layers.sidebar;
86
+ useEffect(() => {
87
+ if (!sidebarOpen)
88
+ dispatch({ type: "sidebar-closed" });
89
+ }, [sidebarOpen]);
90
+ const setOrigin = useCallback((element) => {
91
+ origin.current = element;
92
+ }, []);
93
+ const focusSaved = useCallback((calendarObjectId) => {
94
+ saved.current = true;
95
+ setFocusAfterSave(calendarObjectId);
96
+ }, []);
97
+ return {
98
+ session,
99
+ dispatch,
100
+ takeGesture,
101
+ setOrigin,
102
+ requestClose,
103
+ carriedFocus,
104
+ focusSaved,
105
+ };
106
+ }
@@ -0,0 +1,4 @@
1
+ import { type CalendarEventData, type CalendarSlotPick, type RecurrenceScope } from "@remit/ui";
2
+ import { type CalendarWriteOutcome } from "./useCalendarWrites";
3
+ export type MoveEvent = (event: CalendarEventData, range: CalendarSlotPick, scope: RecurrenceScope | undefined, collectionZone: string) => Promise<CalendarWriteOutcome>;
4
+ export declare function useMoveEvent(): MoveEvent;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Moving or resizing a stored event by dragging it on the grid.
3
+ *
4
+ * The drop is a write like any other: it reads the stored version first, so
5
+ * the `If-Match` it sends is the one that is stored now, and a conflict comes
6
+ * back as an outcome the grid states.
7
+ */
8
+ import { calendarEventDetailOperationsGetCalendarEventOptions } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
9
+ import { formatErrorMessage, } from "@remit/ui";
10
+ import { useQueryClient } from "@tanstack/react-query";
11
+ import { useCallback } from "react";
12
+ import { softErrorStatuses } from "../../lib/error-classifier";
13
+ import { draftFromEvent, patchFromDrafts } from "./draft";
14
+ import { deviceTimeZone, readCalendarInstanceId, UNZONED_CALENDAR, } from "./instance";
15
+ import { storedAnchorZone } from "./resource";
16
+ import { useCalendarWrites, } from "./useCalendarWrites";
17
+ export function useMoveEvent() {
18
+ const queryClient = useQueryClient();
19
+ const { updateEvent } = useCalendarWrites();
20
+ return useCallback(async (event, range, scope, collectionZone) => {
21
+ const { calendarObjectId, recurrenceId } = readCalendarInstanceId(event.id);
22
+ const resource = await queryClient
23
+ .fetchQuery({
24
+ ...calendarEventDetailOperationsGetCalendarEventOptions({
25
+ path: { calendarObjectId },
26
+ query: { calendarId: event.calendarId },
27
+ }),
28
+ meta: softErrorStatuses(404),
29
+ staleTime: 0,
30
+ })
31
+ .catch((error) => ({ unread: formatErrorMessage(error) }));
32
+ if ("unread" in resource)
33
+ return { kind: "refused", message: resource.unread };
34
+ const before = draftFromEvent(event, {
35
+ repeat: "",
36
+ location: "",
37
+ notes: "",
38
+ guests: [],
39
+ });
40
+ const after = {
41
+ ...before,
42
+ date: range.date,
43
+ endDate: range.endDate,
44
+ startTime: range.startTime,
45
+ endTime: range.endTime,
46
+ allDay: range.allDay,
47
+ };
48
+ const patch = patchFromDrafts(before, after, {
49
+ clock: deviceTimeZone(),
50
+ anchor: storedAnchorZone(resource.icalData, collectionZone === "" ? UNZONED_CALENDAR : collectionZone),
51
+ });
52
+ if (!patch.ok)
53
+ return { kind: "refused", message: patch.problem };
54
+ return updateEvent({
55
+ calendarObjectId,
56
+ calendarId: event.calendarId,
57
+ recurrenceId,
58
+ scope,
59
+ etag: resource.etag,
60
+ }, patch.patch);
61
+ }, [queryClient, updateEvent]);
62
+ }
@@ -19,8 +19,8 @@ import { systemOperationsApplySystemUpdateMutation, systemOperationsGetSystemUpd
19
19
  import { systemOperationsGetSystemUpdate } from "@remit/api-http-client/sdk.gen.ts";
20
20
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
21
21
  import { createContext, createElement, useCallback, useContext, useEffect, useRef, useState, } from "react";
22
- import { restartExpectedMeta, shouldEscalate, softErrorMeta, } from "../lib/error-classifier";
23
- import { reportFatalError } from "../lib/fatal-error";
22
+ import { restartExpectedMeta, softErrorMeta } from "../lib/error-classifier";
23
+ import { escalate } from "../lib/escalate";
24
24
  import { appliesSchemaMigration, checkAnswered, checkRequestFailureReason, deriveUpdateSurface, isSurfaceAbsent, mapUpdatePhase, releaseFromCheck, runInFlight, } from "../lib/self-update-state";
25
25
  const IDLE_POLL_MS = 30_000;
26
26
  const RUN_POLL_MS = 5_000;
@@ -158,9 +158,7 @@ export function useSystemUpdate() {
158
158
  // This is a raw SDK call, outside the query cache that feeds the
159
159
  // global sink, so the 5xx the seam answers when the control volume
160
160
  // is unwritable escalates from here or from nowhere.
161
- if (shouldEscalate(error, softErrorMeta, "user")) {
162
- reportFatalError(error);
163
- }
161
+ escalate(error, softErrorMeta);
164
162
  setCheckPress(null);
165
163
  setCheckFailure(checkRequestFailureReason(error));
166
164
  });
@@ -1,7 +1,7 @@
1
1
  import { messageBulkOperationsUpdateMessageLabelsMutation } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
2
2
  import { useMutation, useQueryClient } from "@tanstack/react-query";
3
3
  import { useCallback } from "react";
4
- import { useErrorBanners } from "../components/ui/ErrorBannerProvider";
4
+ import { useErrorBanners } from "../components/ui/error-banner-context";
5
5
  import { formatErrorDetail } from "../components/ui/error-banners";
6
6
  import { runChunkedMutation } from "../lib/bulk-actions";
7
7
  import { invalidateThreadListQueries, threadListCacheKeys, } from "../lib/thread-list-cache";
@@ -5,8 +5,9 @@
5
5
  * and expands no recurrence of its own — the server returns instances and this
6
6
  * turns them into what the kit draws. Every caller keeps the call it makes.
7
7
  */
8
- import type { CalendarColorId, CalendarDescriptor, CalendarEventData, CalendarViewId } from "@remit/ui";
8
+ import type { CalendarColorId, CalendarDescriptor, CalendarEventData, CalendarTaskData, CalendarViewId } from "@remit/ui";
9
9
  import { type CalendarInstanceRef } from "./calendar";
10
+ import { useCalendarTasks } from "./calendar/useCalendarTasks";
10
11
  export interface CalendarDataRequest {
11
12
  view: CalendarViewId;
12
13
  /** The day the view is centred on, `YYYY-MM-DD`. */
@@ -28,10 +29,16 @@ export interface CalendarData {
28
29
  /** The zone each collection's times are read on — never the device's. */
29
30
  timeZoneByCalendarId: Record<string, string>;
30
31
  isLoading: boolean;
31
- /** A refusal the calendar renders itself. Null when the read succeeded. */
32
+ /** A refusal the calendar renders itself. Null when every read succeeded. */
32
33
  error: unknown;
33
34
  retry: () => void;
35
+ /** The tasks due in the window, as the API returned them. */
36
+ storedTasks: ReturnType<typeof useCalendarTasks>["tasks"];
37
+ /** The same tasks, as the grid draws them. */
38
+ tasks: CalendarTaskData[];
34
39
  /** The resource and occurrence behind an event the grid selected. */
35
40
  instanceOf: (eventId: string) => CalendarInstanceRef;
41
+ /** The events that leave their time free rather than busy. */
42
+ freeIds: ReadonlySet<string>;
36
43
  }
37
44
  export declare function useCalendarData({ view, date, calendarIds, enabled, }: CalendarDataRequest): CalendarData;
@@ -1,4 +1,6 @@
1
- import { calendarWindow, readCalendarInstanceId, useCalendarEventWindow, useCalendarSelection, useDrawnEvents, usePrefetchAdjacentWindows, } from "./calendar";
1
+ import { useCallback, useMemo } from "react";
2
+ import { calendarInstanceId, calendarWindow, readCalendarInstanceId, useCalendarEventWindow, useCalendarSelection, useDrawnEvents, usePrefetchAdjacentWindows, } from "./calendar";
3
+ import { toTaskData, useCalendarTasks } from "./calendar/useCalendarTasks";
2
4
  export function useCalendarData({ view, date, calendarIds, enabled = true, }) {
3
5
  const { calendars, colorByCalendarId, timeZoneByCalendarId, shown, narrowed, resolved, isLoading, } = useCalendarSelection(calendarIds);
4
6
  const window = calendarWindow(view, date);
@@ -9,15 +11,30 @@ export function useCalendarData({ view, date, calendarIds, enabled = true, }) {
9
11
  enabled: active,
10
12
  });
11
13
  usePrefetchAdjacentWindows(view, date, narrowed, active);
12
- const eventData = useDrawnEvents(events.instances, timeZoneByCalendarId, shown);
14
+ const drawnEvents = useDrawnEvents(events.instances, timeZoneByCalendarId, shown);
15
+ const taskRead = useCalendarTasks(window, active);
16
+ const storedTasks = taskRead.tasks;
17
+ const tasks = useMemo(() => storedTasks.map(toTaskData), [storedTasks]);
18
+ const refetchEvents = events.refetch;
19
+ const refetchTasks = taskRead.refetch;
20
+ const retry = useCallback(() => {
21
+ refetchEvents();
22
+ void refetchTasks();
23
+ }, [refetchEvents, refetchTasks]);
24
+ const freeIds = useMemo(() => new Set(events.instances
25
+ .filter((instance) => instance.transparency === "Transparent")
26
+ .map((instance) => calendarInstanceId(instance.calendarObjectId, instance.recurrenceId))), [events.instances]);
13
27
  return {
14
28
  calendars,
15
- events: eventData,
29
+ events: drawnEvents,
16
30
  colorByCalendarId,
17
31
  timeZoneByCalendarId,
18
32
  isLoading: isLoading || events.isLoading,
19
- error: events.error,
20
- retry: events.refetch,
33
+ error: events.error ?? taskRead.error,
34
+ retry,
35
+ storedTasks,
36
+ tasks,
21
37
  instanceOf: readCalendarInstanceId,
38
+ freeIds,
22
39
  };
23
40
  }
@@ -0,0 +1,14 @@
1
+ export interface CalendarSidePane {
2
+ /** The pane beside the grid on a wide tier. */
3
+ open: boolean;
4
+ toggle: () => void;
5
+ /** The slide-over that holds the same pane on a phone. */
6
+ navOpen: boolean;
7
+ setNavOpen: (open: boolean) => void;
8
+ }
9
+ /**
10
+ * The hamburger's state. On a wide tier it shows and hides the `sidebar` pane
11
+ * by replace and records the choice on this device; on a phone it raises the
12
+ * `nav` slide-over instead.
13
+ */
14
+ export declare function useCalendarSidePane(isPhone: boolean): CalendarSidePane;
@@ -0,0 +1,30 @@
1
+ import { useCallback, useState } from "react";
2
+ import { readSidePanePref, resolveSidePaneOpen, writeSidePanePref, } from "../lib/calendar-side-pane-pref";
3
+ import { panelsWithOverlay, useOpenPanels, useSetOpenPanels } from "../routing";
4
+ /**
5
+ * The hamburger's state. On a wide tier it shows and hides the `sidebar` pane
6
+ * by replace and records the choice on this device; on a phone it raises the
7
+ * `nav` slide-over instead.
8
+ */
9
+ export function useCalendarSidePane(isPhone) {
10
+ const panels = useOpenPanels();
11
+ const setOpenPanels = useSetOpenPanels();
12
+ const [prefersOpen, setPrefersOpen] = useState(readSidePanePref);
13
+ const open = !isPhone && resolveSidePaneOpen(panels, prefersOpen);
14
+ const navOpen = isPhone && panels.includes("nav");
15
+ const toggle = useCallback(() => {
16
+ if (isPhone) {
17
+ setOpenPanels(panelsWithOverlay(panels, navOpen ? undefined : "nav"));
18
+ return;
19
+ }
20
+ const next = !open;
21
+ writeSidePanePref(next);
22
+ setPrefersOpen(next);
23
+ const others = panels.filter((panel) => panel !== "sidebar");
24
+ setOpenPanels(next ? [...others, "sidebar"] : others);
25
+ }, [isPhone, navOpen, open, panels, setOpenPanels]);
26
+ const setNavOpen = useCallback((next) => {
27
+ setOpenPanels(panelsWithOverlay(panels, next ? "nav" : undefined));
28
+ }, [panels, setOpenPanels]);
29
+ return { open, toggle, navOpen, setNavOpen };
30
+ }
@@ -2,7 +2,7 @@ import { accountDetailOperationsUpdateAccountMutation, configOperationsGetConfig
2
2
  import { defaultComposeLanguages } from "@remit/ui";
3
3
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
4
4
  import { useCallback, useMemo } from "react";
5
- import { useErrorBanners } from "../components/ui/ErrorBannerProvider";
5
+ import { useErrorBanners } from "../components/ui/error-banner-context";
6
6
  import { buildMutationErrorBanner } from "../components/ui/error-banners";
7
7
  /**
8
8
  * The account's writing languages: the menu the composer's language chip
@@ -2,7 +2,7 @@ import { mailboxOperationsListMailboxesQueryKey, messageBulkOperationsDeleteMess
2
2
  import { useMutation, useQueryClient } from "@tanstack/react-query";
3
3
  import { useCallback, useEffect, useRef } from "react";
4
4
  import { useRoleAppointmentPrompt } from "../components/mail/RoleAppointmentPromptProvider";
5
- import { useErrorBanners } from "../components/ui/ErrorBannerProvider";
5
+ import { useErrorBanners } from "../components/ui/error-banner-context";
6
6
  import { formatErrorDetail } from "../components/ui/error-banners";
7
7
  import { isFolderRoleRefusal } from "../components/ui/folder-role-refusal";
8
8
  import { isPlacementRefusal, placementRefusalBanner, } from "../components/ui/placement-refusal";
@@ -11,7 +11,7 @@ import { configOperationsGetConfigQueryKey, mailboxOperationsListMailboxesQueryK
11
11
  import { useMutation, useQueryClient } from "@tanstack/react-query";
12
12
  import { useCallback, useRef, useState } from "react";
13
13
  import { useRoleAppointmentPrompt } from "../components/mail/RoleAppointmentPromptProvider";
14
- import { useErrorBanners } from "../components/ui/ErrorBannerProvider";
14
+ import { useErrorBanners } from "../components/ui/error-banner-context";
15
15
  import { formatErrorDetail } from "../components/ui/error-banners";
16
16
  import { isFolderRoleRefusal, } from "../components/ui/folder-role-refusal";
17
17
  import { softErrorStatuses } from "../lib/error-classifier";
@@ -1,7 +1,7 @@
1
1
  import { messageBulkOperationsDeleteMessages, messageBulkOperationsMoveMessages, messageBulkOperationsUpdateFlags, threadOperationsSearchThreads, } from "@remit/api-http-client/sdk.gen.ts";
2
2
  import { useCallback, useEffect, useRef, useState } from "react";
3
3
  import { useBulkRun, } from "../components/mail/BulkRunProvider";
4
- import { useErrorBanners } from "../components/ui/ErrorBannerProvider";
4
+ import { useErrorBanners } from "../components/ui/error-banner-context";
5
5
  import { buildMutationErrorBanner } from "../components/ui/error-banners";
6
6
  /** Page size for the execution loop. Set to the write side's own 100-id cap so
7
7
  * an execution page IS a write chunk — no in-memory accumulation step between