@burdenoff/microfe-calendar 2026.1124.3 → 2026.1124.4

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 (88) hide show
  1. package/dist/generated/wspace-operations.d.ts +342 -69
  2. package/dist/generated/wspace-operations.js +73 -31
  3. package/dist/generated/wspace-operations.js.map +1 -1
  4. package/dist/generated/wspace-types.d.ts +405 -6
  5. package/dist/translations/en.d.ts +22 -4
  6. package/dist/v2/CalendarPageV2.js +45 -41
  7. package/dist/v2/CalendarPageV2.js.map +1 -1
  8. package/dist/v2/CalendarRoutesV2.js +64 -64
  9. package/dist/v2/CalendarRoutesV2.js.map +1 -1
  10. package/dist/v2/data/errors.d.ts +5 -0
  11. package/dist/v2/data/errors.js +6 -2
  12. package/dist/v2/data/errors.js.map +1 -1
  13. package/dist/v2/data/normalize.d.ts +31 -3
  14. package/dist/v2/data/normalize.js +57 -13
  15. package/dist/v2/data/normalize.js.map +1 -1
  16. package/dist/v2/data/seriesDateLookup.d.ts +9 -0
  17. package/dist/v2/data/seriesDateLookup.js +12 -0
  18. package/dist/v2/data/seriesDateLookup.js.map +1 -0
  19. package/dist/v2/data/useEventActions.d.ts +9 -3
  20. package/dist/v2/data/useEventActions.js +239 -186
  21. package/dist/v2/data/useEventActions.js.map +1 -1
  22. package/dist/v2/data/useEventForPeek.js +63 -21
  23. package/dist/v2/data/useEventForPeek.js.map +1 -1
  24. package/dist/v2/data/useEventsInRangeV2.d.ts +40 -2
  25. package/dist/v2/data/useEventsInRangeV2.js +76 -47
  26. package/dist/v2/data/useEventsInRangeV2.js.map +1 -1
  27. package/dist/v2/day/DayPanel.js +1 -1
  28. package/dist/v2/day/DayPanel.js.map +1 -1
  29. package/dist/v2/event/EventDialog.d.ts +13 -3
  30. package/dist/v2/event/EventDialog.js +189 -166
  31. package/dist/v2/event/EventDialog.js.map +1 -1
  32. package/dist/v2/event/EventDialogs.js +57 -50
  33. package/dist/v2/event/EventDialogs.js.map +1 -1
  34. package/dist/v2/event/EventMoreTab.js +8 -7
  35. package/dist/v2/event/EventMoreTab.js.map +1 -1
  36. package/dist/v2/event/EventPlaceTab.js +2 -2
  37. package/dist/v2/event/EventPlaceTab.js.map +1 -1
  38. package/dist/v2/event/FindTimeDialog.js +1 -1
  39. package/dist/v2/event/FindTimeDialog.js.map +1 -1
  40. package/dist/v2/event/RepeatField.js +10 -7
  41. package/dist/v2/event/RepeatField.js.map +1 -1
  42. package/dist/v2/event/dialogLogic.d.ts +10 -0
  43. package/dist/v2/event/dialogLogic.js +25 -22
  44. package/dist/v2/event/dialogLogic.js.map +1 -1
  45. package/dist/v2/event/dialogModel.d.ts +3 -0
  46. package/dist/v2/event/dialogModel.js.map +1 -1
  47. package/dist/v2/event/eventForm.d.ts +26 -0
  48. package/dist/v2/event/eventForm.js +145 -92
  49. package/dist/v2/event/eventForm.js.map +1 -1
  50. package/dist/v2/event/findTimeSource.js +44 -44
  51. package/dist/v2/event/findTimeSource.js.map +1 -1
  52. package/dist/v2/event/rrule.js.map +1 -1
  53. package/dist/v2/event/savePlan.d.ts +125 -15
  54. package/dist/v2/event/savePlan.js +162 -68
  55. package/dist/v2/event/savePlan.js.map +1 -1
  56. package/dist/v2/event/useEventData.d.ts +7 -2
  57. package/dist/v2/event/useEventData.js +107 -80
  58. package/dist/v2/event/useEventData.js.map +1 -1
  59. package/dist/v2/event/useEventDialogModel.d.ts +16 -3
  60. package/dist/v2/event/useEventDialogModel.js +82 -67
  61. package/dist/v2/event/useEventDialogModel.js.map +1 -1
  62. package/dist/v2/event/useEventSave.d.ts +20 -4
  63. package/dist/v2/event/useEventSave.js +181 -90
  64. package/dist/v2/event/useEventSave.js.map +1 -1
  65. package/dist/v2/events/eventLook.js +16 -16
  66. package/dist/v2/events/eventLook.js.map +1 -1
  67. package/dist/v2/events/eventModel.d.ts +17 -4
  68. package/dist/v2/events/eventModel.js +46 -34
  69. package/dist/v2/events/eventModel.js.map +1 -1
  70. package/dist/v2/events/localChanges.d.ts +4 -1
  71. package/dist/v2/events/localChanges.js +4 -2
  72. package/dist/v2/events/localChanges.js.map +1 -1
  73. package/dist/v2/page/CalendarPageContext.d.ts +2 -2
  74. package/dist/v2/page/CalendarPageContext.js.map +1 -1
  75. package/dist/v2/page/useCalendarPageModel.js +141 -139
  76. package/dist/v2/page/useCalendarPageModel.js.map +1 -1
  77. package/dist/v2/page/viewState.d.ts +9 -1
  78. package/dist/v2/page/viewState.js +5 -3
  79. package/dist/v2/page/viewState.js.map +1 -1
  80. package/dist/v2/peek/PeekEvent.js +210 -204
  81. package/dist/v2/peek/PeekEvent.js.map +1 -1
  82. package/dist/v2/rail/useMonthEventDates.js +1 -1
  83. package/dist/v2/rail/useMonthEventDates.js.map +1 -1
  84. package/dist/v2/states/CalendarStates.d.ts +15 -0
  85. package/dist/v2/states/CalendarStates.js +42 -11
  86. package/dist/v2/states/CalendarStates.js.map +1 -1
  87. package/dist/v2/types.d.ts +30 -2
  88. package/package.json +1 -1
@@ -1,46 +1,73 @@
1
- import { CalendarV2EventDocument as e, CalendarV2EventRoomsDocument as t, CalendarV2MemberIdentitiesDocument as n, CalendarV2MembersDocument as r, CalendarV2RoomBookingsDocument as i, CalendarV2SearchTeamsDocument as a, CalendarV2TeamMembersDocument as o } from "../../generated/wspace-operations.js";
2
- import { useCalendar as s } from "../../providers/CalendarProvider.js";
3
- import { graphQLErrorCode as c } from "../data/errors.js";
4
- import { useCalendarEventsRevision as l } from "../data/invalidation.js";
5
- import { parseInstant as u, toCalendarEventV2 as d } from "../data/normalize.js";
6
- import { useKeyedLoad as f } from "../data/useKeyedLoad.js";
7
- import { knownUntilOf as p, roomKnownFor as m } from "./place.js";
8
- import { useMemo as h } from "react";
9
- import { useApolloClient as g } from "@apollo/client/react";
1
+ import { CalendarV2EventDocument as e, CalendarV2EventOccurrencesDocument as t, CalendarV2EventRoomsDocument as n, CalendarV2MemberIdentitiesDocument as r, CalendarV2MembersDocument as i, CalendarV2RoomBookingsDocument as a, CalendarV2SearchTeamsDocument as o, CalendarV2TeamMembersDocument as s } from "../../generated/wspace-operations.js";
2
+ import { useCalendar as c } from "../../providers/CalendarProvider.js";
3
+ import { graphQLErrorCode as l } from "../data/errors.js";
4
+ import { useCalendarEventsRevision as u } from "../data/invalidation.js";
5
+ import { occurrenceId as d, parseInstant as f, toCalendarEventV2 as p, toOccurrenceV2 as m } from "../data/normalize.js";
6
+ import { seriesDateQuestion as h } from "../data/seriesDateLookup.js";
7
+ import { useKeyedLoad as g } from "../data/useKeyedLoad.js";
8
+ import { knownUntilOf as _, roomKnownFor as v } from "./place.js";
9
+ import { useMemo as y } from "react";
10
+ import { useApolloClient as b } from "@apollo/client/react";
10
11
  // src/v2/event/useEventData.ts
11
- var _ = class extends Error {};
12
- function v(t) {
13
- let n = g(), { currentUser: r } = s(), i = r?.id ?? null, a = l(), o = f(t, async () => {
14
- let r = await n.query({
15
- query: e,
16
- variables: { id: t ?? "" },
17
- fetchPolicy: "network-only"
18
- }), a = r.data?.event ? d(r.data.event, i) : null;
19
- if (!a) throw new _("The event could not be found");
20
- return a;
21
- }, a);
22
- if (!t) return { status: "none" };
23
- let u = o.error;
24
- if (u instanceof _ || u && c(u) === "NOT_FOUND") return { status: "missing" };
25
- let p = o.dataKey === t ? o.data : void 0;
26
- if (p) {
27
- let e = u ? "failed" : o.loading ? "loading" : "current";
12
+ var x = class extends Error {};
13
+ async function S(e, n, r, i) {
14
+ let a = h(n, r);
15
+ if (!a) return null;
16
+ let o = (await e.query({
17
+ query: t,
18
+ variables: a,
19
+ fetchPolicy: "network-only"
20
+ })).data?.eventsInRangeForCalendars;
21
+ if (!o) throw Error("The series’ dates could not be read");
22
+ let s = d(n.eventId, new Date(r)), c = o.occurrences.find((e) => e.id === s);
23
+ return c ? m(c, i) : null;
24
+ }
25
+ async function C(t, n, r, i) {
26
+ let a = await t.query({
27
+ query: e,
28
+ variables: { id: n },
29
+ fetchPolicy: "network-only"
30
+ }), o = a.data?.event ? p(a.data.event, i) : null;
31
+ if (!o) throw new x("The event could not be found");
32
+ if (r === null) return {
33
+ event: o,
34
+ row: o
35
+ };
36
+ let s = await S(t, o, r, i);
37
+ if (!s) throw new x("That date of the series is not on the calendar");
38
+ return {
39
+ event: s,
40
+ row: o
41
+ };
42
+ }
43
+ function w(e, t) {
44
+ if (!e) return { status: "none" };
45
+ let n = t.error;
46
+ if (n instanceof x || n && l(n) === "NOT_FOUND") return { status: "missing" };
47
+ let r = t.dataKey === e ? t.data : void 0;
48
+ if (r) {
49
+ let e = n ? "failed" : t.loading ? "loading" : "current";
28
50
  return {
29
51
  status: "ready",
30
- event: p,
31
- retry: o.reload,
52
+ event: r.event,
53
+ row: r.row,
54
+ retry: t.reload,
32
55
  refresh: e
33
56
  };
34
57
  }
35
- return u ? {
58
+ return n ? {
36
59
  status: "error",
37
- error: u,
38
- retry: o.reload
60
+ error: n,
61
+ retry: t.reload
39
62
  } : { status: "loading" };
40
63
  }
41
- function y(e) {
64
+ function T(e, t = null) {
65
+ let n = b(), { currentUser: r } = c(), i = r?.id ?? null, a = u(), o = t?.getTime() ?? null, s = e === null ? null : `${e}|${o ?? ""}`;
66
+ return w(s, g(s, () => C(n, e ?? "", o, i), a));
67
+ }
68
+ function E(e) {
42
69
  if (e.status !== "APPROVED" && e.status !== "PENDING") return null;
43
- let t = u(e.startTime), n = u(e.endTime);
70
+ let t = f(e.startTime), n = f(e.endTime);
44
71
  return !t || !n ? null : {
45
72
  id: e.id,
46
73
  eventId: e.eventId,
@@ -49,21 +76,21 @@ function y(e) {
49
76
  pending: e.status === "PENDING"
50
77
  };
51
78
  }
52
- function b(e) {
79
+ function D(e) {
53
80
  return e.flatMap((e) => {
54
- let t = y(e);
81
+ let t = E(e);
55
82
  return t ? [t] : [];
56
83
  }).sort((e, t) => e.start.getTime() - t.start.getTime());
57
84
  }
58
- function x(e) {
85
+ function O(e) {
59
86
  return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim() !== "") : e && typeof e == "object" ? Object.entries(e).filter(([, e]) => e === !0).map(([e]) => e) : [];
60
87
  }
61
- function S(e) {
88
+ function k(e) {
62
89
  let t = [
63
90
  e.location,
64
91
  e.building,
65
92
  e.floor
66
- ].map((e) => e?.trim()).filter((e) => !!e), n = e.bookings.filter((e) => e.status === "APPROVED" || e.status === "PENDING"), r = b(n);
93
+ ].map((e) => e?.trim()).filter((e) => !!e), n = e.bookings.filter((e) => e.status === "APPROVED" || e.status === "PENDING"), r = D(n);
67
94
  return {
68
95
  id: e.id,
69
96
  name: e.name,
@@ -71,51 +98,51 @@ function S(e) {
71
98
  capacity: e.capacity ?? null,
72
99
  bookable: e.isBookable,
73
100
  needsApproval: e.requireApproval,
74
- features: x(e.features),
101
+ features: O(e.features),
75
102
  bufferBefore: Math.max(0, e.bufferBefore),
76
103
  bufferAfter: Math.max(0, e.bufferAfter),
77
104
  bookings: r,
78
- knownUntil: n.length < 5 ? null : p(r, 5)
105
+ knownUntil: n.length < 5 ? null : _(r, 5)
79
106
  };
80
107
  }
81
- async function C(e, n) {
108
+ async function A(e, t) {
82
109
  let r = await e.query({
83
- query: t,
110
+ query: n,
84
111
  fetchPolicy: "network-only"
85
112
  });
86
113
  if (!r.data) throw Error("The rooms could not be loaded");
87
- let a = r.data.getCalendarResources.filter((e) => e.isActive).map(S).sort((e, t) => e.name.localeCompare(t.name));
88
- return n ? Promise.all(a.map(async (t) => {
89
- if (m(t, n)) return t;
114
+ let i = r.data.getCalendarResources.filter((e) => e.isActive).map(k).sort((e, t) => e.name.localeCompare(t.name));
115
+ return t ? Promise.all(i.map(async (n) => {
116
+ if (v(n, t)) return n;
90
117
  let r = (await e.query({
91
- query: i,
92
- variables: { id: t.id },
118
+ query: a,
119
+ variables: { id: n.id },
93
120
  fetchPolicy: "network-only"
94
121
  })).data?.getCalendarResource?.bookings;
95
122
  if (!r) throw Error("The room’s bookings could not be loaded");
96
123
  return {
97
- ...t,
98
- bookings: b(r),
124
+ ...n,
125
+ bookings: D(r),
99
126
  knownUntil: null
100
127
  };
101
- })) : a;
128
+ })) : i;
102
129
  }
103
- var w = 864e5;
104
- function T(e, t = {}) {
105
- let n = g(), r = l(), i = e ? Math.ceil(e.getTime() / w) * w : 0, a = t.skip ? null : `rooms|${i}`, o = f(a, () => C(n, i ? new Date(i) : null), r);
130
+ var j = 864e5;
131
+ function M(e, t = {}) {
132
+ let n = b(), r = u(), i = e ? Math.ceil(e.getTime() / j) * j : 0, a = t.skip ? null : `rooms|${i}`, o = g(a, () => A(n, i ? new Date(i) : null), r);
106
133
  return {
107
- rooms: o.data ?? E,
134
+ rooms: o.data ?? N,
108
135
  status: t.skip ? "idle" : o.error ? "error" : o.data && o.dataKey === a ? "ready" : "loading",
109
136
  error: o.error,
110
137
  retry: o.reload
111
138
  };
112
139
  }
113
- var E = [], D = 100;
114
- async function O(e, t) {
115
- let r = [];
116
- for (let e = 0; e < t.length; e += D) r.push(t.slice(e, e + D));
117
- return (await Promise.all(r.map((t) => e.query({
118
- query: n,
140
+ var N = [], P = 100;
141
+ async function F(e, t) {
142
+ let n = [];
143
+ for (let e = 0; e < t.length; e += P) n.push(t.slice(e, e + P));
144
+ return (await Promise.all(n.map((t) => e.query({
145
+ query: r,
119
146
  variables: { userIds: t },
120
147
  fetchPolicy: "cache-first"
121
148
  })))).flatMap((e) => {
@@ -127,25 +154,25 @@ async function O(e, t) {
127
154
  }));
128
155
  });
129
156
  }
130
- function k(e) {
131
- let t = g(), n = h(() => [...new Set(e.filter(Boolean))].sort(), [e]), r = n.length === 0 ? null : n.join("\n"), i = f(r, () => O(t, n));
157
+ function I(e) {
158
+ let t = b(), n = y(() => [...new Set(e.filter(Boolean))].sort(), [e]), r = n.length === 0 ? null : n.join("\n"), i = g(r, () => F(t, n));
132
159
  return {
133
- byUserId: h(() => new Map((i.data ?? []).map((e) => [e.userId, e])), [i.data]),
160
+ byUserId: y(() => new Map((i.data ?? []).map((e) => [e.userId, e])), [i.data]),
134
161
  status: r === null ? "idle" : i.error ? "error" : i.dataKey === r ? "ready" : "loading",
135
162
  retry: i.reload
136
163
  };
137
164
  }
138
- var A = 100, j = 10;
139
- async function M(e, t) {
165
+ var L = 100, R = 10;
166
+ async function z(e, t) {
140
167
  let n = [];
141
- for (let i = 0; i < j; i += 1) {
168
+ for (let r = 0; r < R; r += 1) {
142
169
  let a = (await e.query({
143
- query: r,
170
+ query: i,
144
171
  variables: {
145
172
  workspaceId: t,
146
173
  pagination: {
147
- limit: A,
148
- offset: i * A
174
+ limit: L,
175
+ offset: r * L
149
176
  }
150
177
  },
151
178
  fetchPolicy: "network-only"
@@ -154,21 +181,21 @@ async function M(e, t) {
154
181
  for (let e of a.items) e.status.toLowerCase() === "active" && n.push(e.userId);
155
182
  if (!a.hasMore || a.items.length === 0) break;
156
183
  }
157
- return (await O(e, [...new Set(n)])).sort((e, t) => e.name.localeCompare(t.name, void 0, { sensitivity: "base" }));
184
+ return (await F(e, [...new Set(n)])).sort((e, t) => e.name.localeCompare(t.name, void 0, { sensitivity: "base" }));
158
185
  }
159
- function N(e) {
160
- let t = g(), { workspaceId: n } = s(), r = e && n ? `members|${n}` : null, i = f(r, () => M(t, n ?? ""));
186
+ function B(e) {
187
+ let t = b(), { workspaceId: n } = c(), r = e && n ? `members|${n}` : null, i = g(r, () => z(t, n ?? ""));
161
188
  return {
162
- members: i.data ?? P,
189
+ members: i.data ?? V,
163
190
  status: r === null ? "idle" : i.error ? "error" : i.dataKey === r ? "ready" : "loading",
164
191
  retry: i.reload
165
192
  };
166
193
  }
167
- var P = [];
168
- function F(e) {
169
- let t = g(), n = e.trim(), r = n.length >= 2 ? `teams|${n.toLowerCase()}` : null, i = f(r, async () => {
194
+ var V = [];
195
+ function H(e) {
196
+ let t = b(), n = e.trim(), r = n.length >= 2 ? `teams|${n.toLowerCase()}` : null, i = g(r, async () => {
170
197
  let e = await t.query({
171
- query: a,
198
+ query: o,
172
199
  variables: { query: n },
173
200
  fetchPolicy: "network-only"
174
201
  });
@@ -184,9 +211,9 @@ function F(e) {
184
211
  status: r === null ? "idle" : i.error ? "error" : i.dataKey === r ? "ready" : "loading"
185
212
  };
186
213
  }
187
- async function I(e, t) {
214
+ async function U(e, t) {
188
215
  let n = (await e.query({
189
- query: o,
216
+ query: s,
190
217
  variables: { groupId: t },
191
218
  fetchPolicy: "network-only"
192
219
  })).data?.groupMembers;
@@ -197,6 +224,6 @@ async function I(e, t) {
197
224
  total: n.totalCount
198
225
  };
199
226
  }
200
- export { x as featuresOf, O as loadIdentities, I as loadTeamMemberIds, S as toRoomForEvent, v as useEditedEvent, k as useIdentities, N as useMemberDirectory, T as useRoomsForEvent, F as useTeamSearch };
227
+ export { O as featuresOf, F as loadIdentities, U as loadTeamMemberIds, k as toRoomForEvent, T as useEditedEvent, I as useIdentities, B as useMemberDirectory, M as useRoomsForEvent, H as useTeamSearch };
201
228
 
202
229
  //# sourceMappingURL=useEventData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEventData.js","names":["EventMissingError","useEditedEvent","client","useApolloClient","useCalendar","me","currentUser","revision","useCalendarEventsRevision","load","useKeyedLoad","eventId","result","CalendarV2EventDocument","event","toCalendarEventV2","error","graphQLErrorCode","refresh","toBooking","raw","start","parseInstant","end","toBookings","parsed","booking","a","b","featuresOf","value","item","on","name","toRoomForEvent","place","part","listed","bookings","knownUntilOf","loadRooms","CalendarV2EventRoomsDocument","rooms","room","until","roomKnownFor","CalendarV2RoomBookingsDocument","DAY_MS","useRoomsForEvent","dayEnd","key","options","NO_ROOMS","IDENTITY_BATCH","loadIdentities","batches","index","userIds","CalendarV2MemberIdentitiesDocument","batch","answer","identity","useIdentities","ids","useMemo","MEMBER_PAGE","MAX_MEMBER_PAGES","loadMembers","page","list","CalendarV2MembersDocument","useMemberDirectory","enabled","workspaceId","NO_MEMBERS","useTeamSearch","text","query","CalendarV2SearchTeamsDocument","team","loadTeamMemberIds","members","CalendarV2TeamMembersDocument","edge","node"],"sources":["../../../src/v2/event/useEventData.ts"],"sourcesContent":["/**\n * What the event dialog and Find a time read (BOFF-15698 A2): the event being edited, the rooms\n * with their bookings, the names of the people on an event, and the workspace's members and\n * teams for the guest picker. Each reloads after a write (`invalidateCalendarEvents`), and each\n * says when it failed: a failed load is never an empty list.\n */\nimport { useMemo } from 'react';\nimport { useApolloClient } from '@apollo/client/react';\nimport {\n CalendarV2EventDocument,\n CalendarV2EventRoomsDocument,\n CalendarV2MemberIdentitiesDocument,\n CalendarV2MembersDocument,\n CalendarV2RoomBookingsDocument,\n CalendarV2SearchTeamsDocument,\n CalendarV2TeamMembersDocument,\n type CalendarV2EventQuery,\n type CalendarV2EventQueryVariables,\n type CalendarV2EventRoomsQuery,\n type CalendarV2EventRoomsQueryVariables,\n type CalendarV2MemberIdentitiesQuery,\n type CalendarV2MemberIdentitiesQueryVariables,\n type CalendarV2MembersQuery,\n type CalendarV2MembersQueryVariables,\n type CalendarV2RoomBookingsQuery,\n type CalendarV2RoomBookingsQueryVariables,\n type CalendarV2SearchTeamsQuery,\n type CalendarV2SearchTeamsQueryVariables,\n type CalendarV2TeamMembersQuery,\n type CalendarV2TeamMembersQueryVariables,\n} from '../../generated/wspace-operations';\nimport { useCalendar } from '../../providers/CalendarProvider';\nimport { graphQLErrorCode } from '../data/errors';\nimport { useCalendarEventsRevision } from '../data/invalidation';\nimport { parseInstant, toCalendarEventV2 } from '../data/normalize';\nimport { useKeyedLoad } from '../data/useKeyedLoad';\nimport type { CalendarEventV2 } from '../types';\nimport { knownUntilOf, roomKnownFor, type RoomBookingForEvent, type RoomForEvent } from './place';\n\ntype Client = ReturnType<typeof useApolloClient>;\ntype LoadStatus = 'idle' | 'loading' | 'ready' | 'error';\n\n// ── The event being edited ───────────────────────────────────────────────────\n\nexport type EditedEvent =\n | { status: 'none' }\n | { status: 'loading' }\n | { status: 'missing' }\n | { status: 'error'; error: Error; retry: () => void }\n | {\n status: 'ready';\n event: CalendarEventV2;\n retry: () => void;\n /**\n * After a write the event is read again: until then (or when that fails) `event` is the\n * one read before, fine to show but not to plan a save on.\n */\n refresh: 'current' | 'loading' | 'failed';\n };\n\nclass EventMissingError extends Error {}\n\n/**\n * The event as the service has it now (never the view's copy, which may carry a move the\n * service hasn't confirmed), read again after every write.\n */\nexport function useEditedEvent(eventId: string | null): EditedEvent {\n const client = useApolloClient();\n const { currentUser } = useCalendar();\n const me = currentUser?.id ?? null;\n const revision = useCalendarEventsRevision();\n const load = useKeyedLoad<CalendarEventV2>(\n eventId,\n async () => {\n const result = await client.query<CalendarV2EventQuery, CalendarV2EventQueryVariables>({\n query: CalendarV2EventDocument,\n variables: { id: eventId ?? '' },\n fetchPolicy: 'network-only',\n });\n const event = result.data?.event ? toCalendarEventV2(result.data.event, me) : null;\n if (!event) throw new EventMissingError('The event could not be found');\n return event;\n },\n revision\n );\n if (!eventId) return { status: 'none' };\n const error = load.error;\n if (error instanceof EventMissingError || (error && graphQLErrorCode(error) === 'NOT_FOUND')) {\n return { status: 'missing' };\n }\n const event = load.dataKey === eventId ? load.data : undefined;\n // After a write the last answer stands while the next one loads (or if it fails).\n if (event) {\n const refresh = error ? 'failed' : load.loading ? 'loading' : 'current';\n return { status: 'ready', event, retry: load.reload, refresh };\n }\n return error ? { status: 'error', error, retry: load.reload } : { status: 'loading' };\n}\n\n// ── Rooms ────────────────────────────────────────────────────────────────────\n\n/** The bookings the service's room list holds per room. */\nexport const ROOM_LIST_BOOKINGS = 5;\n\ntype RawRoom = CalendarV2EventRoomsQuery['getCalendarResources'][number];\ntype RawBooking = RawRoom['bookings'][number];\n\nfunction toBooking(raw: RawBooking): RoomBookingForEvent | null {\n if (raw.status !== 'APPROVED' && raw.status !== 'PENDING') return null;\n const start = parseInstant(raw.startTime);\n const end = parseInstant(raw.endTime);\n if (!start || !end) return null;\n return { id: raw.id, eventId: raw.eventId, start, end, pending: raw.status === 'PENDING' };\n}\n\nfunction toBookings(raw: readonly RawBooking[]): RoomBookingForEvent[] {\n return raw\n .flatMap((booking) => {\n const parsed = toBooking(booking);\n return parsed ? [parsed] : [];\n })\n .sort((a, b) => a.start.getTime() - b.start.getTime());\n}\n\n/** What a room has, from its stored features: a list of words, or the names set to true. */\nexport function featuresOf(value: unknown): string[] {\n if (Array.isArray(value)) {\n return value.filter((item): item is string => typeof item === 'string' && item.trim() !== '');\n }\n if (value && typeof value === 'object') {\n return Object.entries(value)\n .filter(([, on]) => on === true)\n .map(([name]) => name);\n }\n return [];\n}\n\nexport function toRoomForEvent(raw: RawRoom): RoomForEvent {\n const place = [raw.location, raw.building, raw.floor]\n .map((part) => part?.trim())\n .filter((part): part is string => Boolean(part));\n const listed = raw.bookings.filter(\n (booking) => booking.status === 'APPROVED' || booking.status === 'PENDING'\n );\n const bookings = toBookings(listed);\n return {\n id: raw.id,\n name: raw.name,\n place: place.length > 0 ? [...new Set(place)].join(' · ') : null,\n capacity: raw.capacity ?? null,\n bookable: raw.isBookable,\n needsApproval: raw.requireApproval,\n features: featuresOf(raw.features),\n bufferBefore: Math.max(0, raw.bufferBefore),\n bufferAfter: Math.max(0, raw.bufferAfter),\n bookings,\n // The list's limit counts the bookings it returned, parsed or not.\n knownUntil:\n listed.length < ROOM_LIST_BOOKINGS ? null : knownUntilOf(bookings, ROOM_LIST_BOOKINGS),\n };\n}\n\nasync function loadRooms(client: Client, until: Date | null): Promise<RoomForEvent[]> {\n const result = await client.query<CalendarV2EventRoomsQuery, CalendarV2EventRoomsQueryVariables>({\n query: CalendarV2EventRoomsDocument,\n fetchPolicy: 'network-only',\n });\n if (!result.data) throw new Error('The rooms could not be loaded');\n const rooms = result.data.getCalendarResources\n .filter((room) => room.isActive)\n .map(toRoomForEvent)\n .sort((a, b) => a.name.localeCompare(b.name));\n if (!until) return rooms;\n // Rooms booked beyond their five listed bookings before `until`: read their whole list.\n return Promise.all(\n rooms.map(async (room) => {\n if (roomKnownFor(room, until)) return room;\n const full = await client.query<\n CalendarV2RoomBookingsQuery,\n CalendarV2RoomBookingsQueryVariables\n >({\n query: CalendarV2RoomBookingsDocument,\n variables: { id: room.id },\n fetchPolicy: 'network-only',\n });\n const bookings = full.data?.getCalendarResource?.bookings;\n if (!bookings) throw new Error('The room’s bookings could not be loaded');\n return { ...room, bookings: toBookings(bookings), knownUntil: null };\n })\n );\n}\n\nexport interface RoomsForEvent {\n rooms: RoomForEvent[];\n status: LoadStatus;\n error: Error | null;\n retry: () => void;\n}\n\nconst DAY_MS = 86_400_000;\n\n/**\n * The workspace's rooms with every booking up to `until` known (the end of the time the dialog\n * looks at, rounded up to a UTC day so moving within it reads nothing again).\n */\nexport function useRoomsForEvent(\n until: Date | null,\n options: { skip?: boolean } = {}\n): RoomsForEvent {\n const client = useApolloClient();\n const revision = useCalendarEventsRevision();\n const dayEnd = until ? Math.ceil(until.getTime() / DAY_MS) * DAY_MS : 0;\n const key = options.skip ? null : `rooms|${dayEnd}`;\n const load = useKeyedLoad<RoomForEvent[]>(\n key,\n () => loadRooms(client, dayEnd ? new Date(dayEnd) : null),\n revision\n );\n const rooms = load.data ?? NO_ROOMS;\n return {\n rooms,\n status: options.skip\n ? 'idle'\n : load.error\n ? 'error'\n : load.data && load.dataKey === key\n ? 'ready'\n : 'loading',\n error: load.error,\n retry: load.reload,\n };\n}\n\nconst NO_ROOMS: RoomForEvent[] = [];\n\n// ── People ───────────────────────────────────────────────────────────────────\n\nexport interface MemberIdentity {\n userId: string;\n name: string;\n email: string | null;\n}\n\nexport interface Identities {\n /** Workspace members among the ids asked about; anyone else isn't (or is no longer) one. */\n byUserId: ReadonlyMap<string, MemberIdentity>;\n status: LoadStatus;\n retry: () => void;\n}\n\n/** The most ids one identity question carries. */\nconst IDENTITY_BATCH = 100;\n\n/** Names for these ids: only the workspace's active members come back. */\nexport async function loadIdentities(\n client: Client,\n userIds: readonly string[]\n): Promise<MemberIdentity[]> {\n const batches: string[][] = [];\n for (let index = 0; index < userIds.length; index += IDENTITY_BATCH) {\n batches.push(userIds.slice(index, index + IDENTITY_BATCH));\n }\n const answers = await Promise.all(\n batches.map((batch) =>\n client.query<CalendarV2MemberIdentitiesQuery, CalendarV2MemberIdentitiesQueryVariables>({\n query: CalendarV2MemberIdentitiesDocument,\n variables: { userIds: batch },\n fetchPolicy: 'cache-first',\n })\n )\n );\n return answers.flatMap((answer) => {\n if (!answer.data) throw new Error('Names could not be loaded');\n return answer.data.workspaceMemberIdentities.map((identity) => ({\n userId: identity.userId,\n name: identity.displayName.trim() || identity.email?.trim() || identity.userId,\n email: identity.email?.trim() || null,\n }));\n });\n}\n\n/** Names for these ids, and which of them are the workspace's members. */\nexport function useIdentities(userIds: readonly string[]): Identities {\n const client = useApolloClient();\n const ids = useMemo(() => [...new Set(userIds.filter(Boolean))].sort(), [userIds]);\n const key = ids.length === 0 ? null : ids.join('\\n');\n const load = useKeyedLoad<MemberIdentity[]>(key, () => loadIdentities(client, ids));\n const byUserId = useMemo(\n () => new Map((load.data ?? []).map((identity) => [identity.userId, identity])),\n [load.data]\n );\n return {\n byUserId,\n status:\n key === null ? 'idle' : load.error ? 'error' : load.dataKey === key ? 'ready' : 'loading',\n retry: load.reload,\n };\n}\n\n/** The most members the guest picker lists (100 a page). */\nconst MEMBER_PAGE = 100;\nconst MAX_MEMBER_PAGES = 10;\n\nasync function loadMembers(client: Client, workspaceId: string): Promise<MemberIdentity[]> {\n const userIds: string[] = [];\n for (let page = 0; page < MAX_MEMBER_PAGES; page += 1) {\n const result = await client.query<CalendarV2MembersQuery, CalendarV2MembersQueryVariables>({\n query: CalendarV2MembersDocument,\n variables: { workspaceId, pagination: { limit: MEMBER_PAGE, offset: page * MEMBER_PAGE } },\n fetchPolicy: 'network-only',\n });\n const list = result.data?.workspaceMembers;\n if (!list) throw new Error('The workspace’s members could not be loaded');\n for (const item of list.items) {\n if (item.status.toLowerCase() === 'active') userIds.push(item.userId);\n }\n if (!list.hasMore || list.items.length === 0) break;\n }\n const people = await loadIdentities(client, [...new Set(userIds)]);\n return people.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }));\n}\n\nexport interface MemberDirectory {\n members: MemberIdentity[];\n status: LoadStatus;\n retry: () => void;\n}\n\n/** The workspace's active members, for the guest picker (read once it opens). */\nexport function useMemberDirectory(enabled: boolean): MemberDirectory {\n const client = useApolloClient();\n const { workspaceId } = useCalendar();\n const key = enabled && workspaceId ? `members|${workspaceId}` : null;\n const load = useKeyedLoad<MemberIdentity[]>(key, () => loadMembers(client, workspaceId ?? ''));\n return {\n members: load.data ?? NO_MEMBERS,\n status:\n key === null ? 'idle' : load.error ? 'error' : load.dataKey === key ? 'ready' : 'loading',\n retry: load.reload,\n };\n}\n\nconst NO_MEMBERS: MemberIdentity[] = [];\n\nexport interface TeamMatch {\n id: string;\n name: string;\n memberCount: number;\n}\n\nexport interface TeamSearch {\n teams: TeamMatch[];\n status: LoadStatus;\n}\n\n/** Teams whose name matches `query` (two letters at least). */\nexport function useTeamSearch(query: string): TeamSearch {\n const client = useApolloClient();\n const text = query.trim();\n const key = text.length >= 2 ? `teams|${text.toLowerCase()}` : null;\n const load = useKeyedLoad<TeamMatch[]>(key, async () => {\n const result = await client.query<\n CalendarV2SearchTeamsQuery,\n CalendarV2SearchTeamsQueryVariables\n >({\n query: CalendarV2SearchTeamsDocument,\n variables: { query: text },\n fetchPolicy: 'network-only',\n });\n if (!result.data) throw new Error('Teams could not be searched');\n return result.data.searchGroups.map((team) => ({\n id: team.id,\n name: team.name,\n memberCount: team.memberCount,\n }));\n });\n return {\n teams: key !== null && load.dataKey === key ? (load.data ?? []) : [],\n status:\n key === null ? 'idle' : load.error ? 'error' : load.dataKey === key ? 'ready' : 'loading',\n };\n}\n\n/** The most members a team adds at once. */\nexport const MAX_TEAM_GUESTS = 100;\n\n/** A team's members' ids (people only), for inviting each. */\nexport async function loadTeamMemberIds(\n client: Client,\n groupId: string\n): Promise<{ userIds: string[]; total: number }> {\n const result = await client.query<\n CalendarV2TeamMembersQuery,\n CalendarV2TeamMembersQueryVariables\n >({\n query: CalendarV2TeamMembersDocument,\n variables: { groupId },\n fetchPolicy: 'network-only',\n });\n const members = result.data?.groupMembers;\n if (!members) throw new Error('The team’s members could not be loaded');\n const userIds = members.edges\n .map((edge) => edge.node)\n .filter((node) => node.entityType.toLowerCase() === 'user')\n .map((node) => node.entityId);\n return { userIds: [...new Set(userIds)].slice(0, MAX_TEAM_GUESTS), total: members.totalCount };\n}\n"],"mappings":";;;;;;;;;;AA4DA,IAAMA,IAAN,cAAgC,MAAM,CAAC;AAMvC,SAAgBC,EAAe,GAAqC;CAClE,IAAMC,IAASC,EAAgB,GACzB,EAAE,mBAAgBC,EAAY,GAC9BC,IAAKC,GAAa,MAAM,MACxBC,IAAWC,EAA0B,GACrCC,IAAOC,EACXC,GACA,YAAY;EACV,IAAMC,IAAS,MAAMV,EAAO,MAA2D;GACrF,OAAOW;GACP,WAAW,EAAE,IAAIF,KAAW,GAAG;GAC/B,aAAa;EACf,CAAC,GACKG,IAAQF,EAAO,MAAM,QAAQG,EAAkBH,EAAO,KAAK,OAAOP,CAAE,IAAI;EAC9E,IAAI,CAACS,GAAO,MAAM,IAAId,EAAkB,8BAA8B;EACtE,OAAOc;CACT,GACAP,CACF;CACA,IAAI,CAACI,GAAS,OAAO,EAAE,QAAQ,OAAO;CACtC,IAAMK,IAAQP,EAAK;CACnB,IAAIO,aAAiBhB,KAAsBgB,KAASC,EAAiBD,CAAK,MAAM,aAC9E,OAAO,EAAE,QAAQ,UAAU;CAE7B,IAAMF,IAAQL,EAAK,YAAYE,IAAUF,EAAK,OAAO,KAAA;CAErD,IAAIK,GAAO;EACT,IAAMI,IAAUF,IAAQ,WAAWP,EAAK,UAAU,YAAY;EAC9D,OAAO;GAAE,QAAQ;GAAS;GAAO,OAAOA,EAAK;GAAQ;EAAQ;CAC/D;CACA,OAAOO,IAAQ;EAAE,QAAQ;EAAS;EAAO,OAAOP,EAAK;CAAO,IAAI,EAAE,QAAQ,UAAU;AACtF;AAUA,SAASU,EAAU,GAA6C;CAC9D,IAAIC,EAAI,WAAW,cAAcA,EAAI,WAAW,WAAW,OAAO;CAClE,IAAMC,I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EA,IAAMiE,IAA+B,CAAC;AActC,SAAgBC,EAAc,GAA2B;CACvD,IAAMzE,IAASC,EAAgB,GACzByE,IAAOC,EAAM,KAAK,GAClB3B,IAAM0B,EAAK,UAAU,IAAI,SAASA,EAAK,YAAY,MAAM,MACzDnE,IAAOC,EAA0BwC,GAAK,YAAY;EACtD,IAAMtC,IAAS,MAAMV,EAAO,MAG1B;GACA,OAAO4E;GACP,WAAW,EAAE,OAAOF,EAAK;GACzB,aAAa;EACf,CAAC;EACD,IAAI,CAAChE,EAAO,MAAM,MAAU,MAAM,6BAA6B;EAC/D,OAAOA,EAAO,KAAK,aAAa,KAAK,OAAU;GAC7C,IAAImE,EAAK;GACT,MAAMA,EAAK;GACX,aAAaA,EAAK;EACpB,EAAE;CACJ,CAAC;CACD,OAAO;EACL,OAAO7B,MAAQ,QAAQzC,EAAK,YAAYyC,IAAOzC,EAAK,QAAQ,CAAC,IAAK,CAAC;EACnE,QACEyC,MAAQ,OAAO,SAASzC,EAAK,QAAQ,UAAUA,EAAK,YAAYyC,IAAM,UAAU;CACpF;AACF;AAMA,eAAsB8B,EACpB,GACA,GAC+C;CAS/C,IAAMC,KAAU,MARK/E,EAAO,MAG1B;EACA,OAAOgF;EACP,WAAW,EAAE,WAAQ;EACrB,aAAa;CACf,CAAC,EAAA,CACsB,MAAM;CAC7B,IAAI,CAACD,GAAS,MAAU,MAAM,wCAAwC;CACtE,IAAMxB,IAAUwB,EAAQ,MACrB,KAAK,MAASE,EAAK,IAAI,CAAC,CACxB,QAAQ,MAASC,EAAK,WAAW,YAAY,MAAM,MAAM,CAAC,CAC1D,KAAK,MAASA,EAAK,QAAQ;CAC9B,OAAO;EAAE,SAAS,CAAC,GAAG,IAAI,IAAI3B,CAAO,CAAC,CAAC,CAAC,MAAM,GAAA,GAAkB;EAAG,OAAOwB,EAAQ;CAAW;AAC/F"}
1
+ {"version":3,"file":"useEventData.js","names":["EventMissingError","readSeriesDate","question","seriesDateQuestion","series","instanceMs","answer","client","CalendarV2EventOccurrencesDocument","id","occurrenceId","raw","occurrence","toOccurrenceV2","me","readEdited","result","CalendarV2EventDocument","eventId","row","toCalendarEventV2","event","editedState","key","error","load","graphQLErrorCode","read","refresh","useEditedEvent","useApolloClient","useCalendar","currentUser","revision","useCalendarEventsRevision","instanceDate","useKeyedLoad","toBooking","start","parseInstant","end","toBookings","parsed","booking","a","b","featuresOf","value","item","on","name","toRoomForEvent","place","part","listed","bookings","knownUntilOf","loadRooms","CalendarV2EventRoomsDocument","rooms","room","until","roomKnownFor","CalendarV2RoomBookingsDocument","DAY_MS","useRoomsForEvent","dayEnd","options","NO_ROOMS","IDENTITY_BATCH","loadIdentities","batches","index","userIds","CalendarV2MemberIdentitiesDocument","batch","identity","useIdentities","ids","useMemo","MEMBER_PAGE","MAX_MEMBER_PAGES","loadMembers","page","list","CalendarV2MembersDocument","useMemberDirectory","enabled","workspaceId","NO_MEMBERS","useTeamSearch","text","query","CalendarV2SearchTeamsDocument","team","loadTeamMemberIds","members","CalendarV2TeamMembersDocument","edge","node"],"sources":["../../../src/v2/event/useEventData.ts"],"sourcesContent":["/**\n * What the event dialog and Find a time read (BOFF-15698 A2): the event being edited, the rooms\n * with their bookings, the names of the people on an event, and the workspace's members and\n * teams for the guest picker. Each reloads after a write (`invalidateCalendarEvents`), and each\n * says when it failed: a failed load is never an empty list.\n */\nimport { useMemo } from 'react';\nimport { useApolloClient } from '@apollo/client/react';\nimport {\n CalendarV2EventDocument,\n CalendarV2EventOccurrencesDocument,\n CalendarV2EventRoomsDocument,\n CalendarV2MemberIdentitiesDocument,\n CalendarV2MembersDocument,\n CalendarV2RoomBookingsDocument,\n CalendarV2SearchTeamsDocument,\n CalendarV2TeamMembersDocument,\n type CalendarV2EventOccurrencesQuery,\n type CalendarV2EventOccurrencesQueryVariables,\n type CalendarV2EventQuery,\n type CalendarV2EventQueryVariables,\n type CalendarV2EventRoomsQuery,\n type CalendarV2EventRoomsQueryVariables,\n type CalendarV2MemberIdentitiesQuery,\n type CalendarV2MemberIdentitiesQueryVariables,\n type CalendarV2MembersQuery,\n type CalendarV2MembersQueryVariables,\n type CalendarV2RoomBookingsQuery,\n type CalendarV2RoomBookingsQueryVariables,\n type CalendarV2SearchTeamsQuery,\n type CalendarV2SearchTeamsQueryVariables,\n type CalendarV2TeamMembersQuery,\n type CalendarV2TeamMembersQueryVariables,\n} from '../../generated/wspace-operations';\nimport { useCalendar } from '../../providers/CalendarProvider';\nimport { graphQLErrorCode } from '../data/errors';\nimport { useCalendarEventsRevision } from '../data/invalidation';\nimport { occurrenceId, parseInstant, toCalendarEventV2, toOccurrenceV2 } from '../data/normalize';\nimport { seriesDateQuestion } from '../data/seriesDateLookup';\nimport { useKeyedLoad, type KeyedLoadState } from '../data/useKeyedLoad';\nimport type { CalendarEventV2 } from '../types';\nimport { knownUntilOf, roomKnownFor, type RoomBookingForEvent, type RoomForEvent } from './place';\n\ntype Client = ReturnType<typeof useApolloClient>;\ntype LoadStatus = 'idle' | 'loading' | 'ready' | 'error';\n\n// ── The event being edited ───────────────────────────────────────────────────\n\nexport type EditedEvent =\n | { status: 'none' }\n | { status: 'loading' }\n | { status: 'missing' }\n | { status: 'error'; error: Error; retry: () => void }\n | {\n status: 'ready';\n /** The event as the dialog edits it: a series' date at that date (A4). */\n event: CalendarEventV2;\n /** The stored event behind it: for a series' date, the series at its first date. */\n row: CalendarEventV2;\n retry: () => void;\n /**\n * After a write the event is read again: until then (or when that fails) `event` is the\n * one read before, fine to show but not to plan a save on.\n */\n refresh: 'current' | 'loading' | 'failed';\n };\n\nclass EventMissingError extends Error {}\n\n/** The edited event and the stored event behind it, as read. */\ninterface EditedRead {\n event: CalendarEventV2;\n row: CalendarEventV2;\n}\n\n/**\n * One date of a series as the calendar has it now, looked up with the views' range query (a\n * date cancelled or moved since isn't found); null when it isn't there.\n */\nasync function readSeriesDate(\n client: Client,\n series: CalendarEventV2,\n instanceMs: number,\n me: string | null\n): Promise<CalendarEventV2 | null> {\n const question = seriesDateQuestion(series, instanceMs);\n if (!question) return null;\n const result = await client.query<\n CalendarV2EventOccurrencesQuery,\n CalendarV2EventOccurrencesQueryVariables\n >({\n query: CalendarV2EventOccurrencesDocument,\n variables: question,\n fetchPolicy: 'network-only',\n });\n const answer = result.data?.eventsInRangeForCalendars;\n if (!answer) throw new Error('The series’ dates could not be read');\n const id = occurrenceId(series.eventId, new Date(instanceMs));\n const raw = answer.occurrences.find((occurrence) => occurrence.id === id);\n return raw ? toOccurrenceV2(raw, me) : null;\n}\n\n/** Reads the event (and with `instanceMs`, that date of its series, as the calendar has it). */\nasync function readEdited(\n client: Client,\n eventId: string,\n instanceMs: number | null,\n me: string | null\n): Promise<EditedRead> {\n const result = await client.query<CalendarV2EventQuery, CalendarV2EventQueryVariables>({\n query: CalendarV2EventDocument,\n variables: { id: eventId },\n fetchPolicy: 'network-only',\n });\n const row = result.data?.event ? toCalendarEventV2(result.data.event, me) : null;\n if (!row) throw new EventMissingError('The event could not be found');\n if (instanceMs === null) return { event: row, row };\n const event = await readSeriesDate(client, row, instanceMs, me);\n if (!event) throw new EventMissingError('That date of the series is not on the calendar');\n return { event, row };\n}\n\n/** What the dialog is told about the read, from the load for its key. */\nfunction editedState(key: string | null, load: KeyedLoadState<EditedRead>): EditedEvent {\n if (!key) return { status: 'none' };\n const error = load.error;\n if (error instanceof EventMissingError || (error && graphQLErrorCode(error) === 'NOT_FOUND')) {\n return { status: 'missing' };\n }\n const read = load.dataKey === key ? load.data : undefined;\n // After a write the last answer stands while the next one loads (or if it fails).\n if (read) {\n const refresh = error ? 'failed' : load.loading ? 'loading' : 'current';\n return { status: 'ready', event: read.event, row: read.row, retry: load.reload, refresh };\n }\n return error ? { status: 'error', error, retry: load.reload } : { status: 'loading' };\n}\n\n/**\n * The event as the service has it now (never the view's copy, which may carry a move the\n * service hasn't confirmed), read again after every write. With `instanceDate`, a series is\n * edited at that date of it (A4), as the calendar has the date now: a date cancelled or moved\n * since the dialog opened is `missing`, never edited as if it were still there.\n */\nexport function useEditedEvent(\n eventId: string | null,\n instanceDate: Date | null = null\n): EditedEvent {\n const client = useApolloClient();\n const { currentUser } = useCalendar();\n const me = currentUser?.id ?? null;\n const revision = useCalendarEventsRevision();\n const instanceMs = instanceDate?.getTime() ?? null;\n const key = eventId === null ? null : `${eventId}|${instanceMs ?? ''}`;\n const load = useKeyedLoad<EditedRead>(\n key,\n () => readEdited(client, eventId ?? '', instanceMs, me),\n revision\n );\n return editedState(key, load);\n}\n\n// ── Rooms ────────────────────────────────────────────────────────────────────\n\n/** The bookings the service's room list holds per room. */\nexport const ROOM_LIST_BOOKINGS = 5;\n\ntype RawRoom = CalendarV2EventRoomsQuery['getCalendarResources'][number];\ntype RawBooking = RawRoom['bookings'][number];\n\nfunction toBooking(raw: RawBooking): RoomBookingForEvent | null {\n if (raw.status !== 'APPROVED' && raw.status !== 'PENDING') return null;\n const start = parseInstant(raw.startTime);\n const end = parseInstant(raw.endTime);\n if (!start || !end) return null;\n return { id: raw.id, eventId: raw.eventId, start, end, pending: raw.status === 'PENDING' };\n}\n\nfunction toBookings(raw: readonly RawBooking[]): RoomBookingForEvent[] {\n return raw\n .flatMap((booking) => {\n const parsed = toBooking(booking);\n return parsed ? [parsed] : [];\n })\n .sort((a, b) => a.start.getTime() - b.start.getTime());\n}\n\n/** What a room has, from its stored features: a list of words, or the names set to true. */\nexport function featuresOf(value: unknown): string[] {\n if (Array.isArray(value)) {\n return value.filter((item): item is string => typeof item === 'string' && item.trim() !== '');\n }\n if (value && typeof value === 'object') {\n return Object.entries(value)\n .filter(([, on]) => on === true)\n .map(([name]) => name);\n }\n return [];\n}\n\nexport function toRoomForEvent(raw: RawRoom): RoomForEvent {\n const place = [raw.location, raw.building, raw.floor]\n .map((part) => part?.trim())\n .filter((part): part is string => Boolean(part));\n const listed = raw.bookings.filter(\n (booking) => booking.status === 'APPROVED' || booking.status === 'PENDING'\n );\n const bookings = toBookings(listed);\n return {\n id: raw.id,\n name: raw.name,\n place: place.length > 0 ? [...new Set(place)].join(' · ') : null,\n capacity: raw.capacity ?? null,\n bookable: raw.isBookable,\n needsApproval: raw.requireApproval,\n features: featuresOf(raw.features),\n bufferBefore: Math.max(0, raw.bufferBefore),\n bufferAfter: Math.max(0, raw.bufferAfter),\n bookings,\n // The list's limit counts the bookings it returned, parsed or not.\n knownUntil:\n listed.length < ROOM_LIST_BOOKINGS ? null : knownUntilOf(bookings, ROOM_LIST_BOOKINGS),\n };\n}\n\nasync function loadRooms(client: Client, until: Date | null): Promise<RoomForEvent[]> {\n const result = await client.query<CalendarV2EventRoomsQuery, CalendarV2EventRoomsQueryVariables>({\n query: CalendarV2EventRoomsDocument,\n fetchPolicy: 'network-only',\n });\n if (!result.data) throw new Error('The rooms could not be loaded');\n const rooms = result.data.getCalendarResources\n .filter((room) => room.isActive)\n .map(toRoomForEvent)\n .sort((a, b) => a.name.localeCompare(b.name));\n if (!until) return rooms;\n // Rooms booked beyond their five listed bookings before `until`: read their whole list.\n return Promise.all(\n rooms.map(async (room) => {\n if (roomKnownFor(room, until)) return room;\n const full = await client.query<\n CalendarV2RoomBookingsQuery,\n CalendarV2RoomBookingsQueryVariables\n >({\n query: CalendarV2RoomBookingsDocument,\n variables: { id: room.id },\n fetchPolicy: 'network-only',\n });\n const bookings = full.data?.getCalendarResource?.bookings;\n if (!bookings) throw new Error('The room’s bookings could not be loaded');\n return { ...room, bookings: toBookings(bookings), knownUntil: null };\n })\n );\n}\n\nexport interface RoomsForEvent {\n rooms: RoomForEvent[];\n status: LoadStatus;\n error: Error | null;\n retry: () => void;\n}\n\nconst DAY_MS = 86_400_000;\n\n/**\n * The workspace's rooms with every booking up to `until` known (the end of the time the dialog\n * looks at, rounded up to a UTC day so moving within it reads nothing again).\n */\nexport function useRoomsForEvent(\n until: Date | null,\n options: { skip?: boolean } = {}\n): RoomsForEvent {\n const client = useApolloClient();\n const revision = useCalendarEventsRevision();\n const dayEnd = until ? Math.ceil(until.getTime() / DAY_MS) * DAY_MS : 0;\n const key = options.skip ? null : `rooms|${dayEnd}`;\n const load = useKeyedLoad<RoomForEvent[]>(\n key,\n () => loadRooms(client, dayEnd ? new Date(dayEnd) : null),\n revision\n );\n const rooms = load.data ?? NO_ROOMS;\n return {\n rooms,\n status: options.skip\n ? 'idle'\n : load.error\n ? 'error'\n : load.data && load.dataKey === key\n ? 'ready'\n : 'loading',\n error: load.error,\n retry: load.reload,\n };\n}\n\nconst NO_ROOMS: RoomForEvent[] = [];\n\n// ── People ───────────────────────────────────────────────────────────────────\n\nexport interface MemberIdentity {\n userId: string;\n name: string;\n email: string | null;\n}\n\nexport interface Identities {\n /** Workspace members among the ids asked about; anyone else isn't (or is no longer) one. */\n byUserId: ReadonlyMap<string, MemberIdentity>;\n status: LoadStatus;\n retry: () => void;\n}\n\n/** The most ids one identity question carries. */\nconst IDENTITY_BATCH = 100;\n\n/** Names for these ids: only the workspace's active members come back. */\nexport async function loadIdentities(\n client: Client,\n userIds: readonly string[]\n): Promise<MemberIdentity[]> {\n const batches: string[][] = [];\n for (let index = 0; index < userIds.length; index += IDENTITY_BATCH) {\n batches.push(userIds.slice(index, index + IDENTITY_BATCH));\n }\n const answers = await Promise.all(\n batches.map((batch) =>\n client.query<CalendarV2MemberIdentitiesQuery, CalendarV2MemberIdentitiesQueryVariables>({\n query: CalendarV2MemberIdentitiesDocument,\n variables: { userIds: batch },\n fetchPolicy: 'cache-first',\n })\n )\n );\n return answers.flatMap((answer) => {\n if (!answer.data) throw new Error('Names could not be loaded');\n return answer.data.workspaceMemberIdentities.map((identity) => ({\n userId: identity.userId,\n name: identity.displayName.trim() || identity.email?.trim() || identity.userId,\n email: identity.email?.trim() || null,\n }));\n });\n}\n\n/** Names for these ids, and which of them are the workspace's members. */\nexport function useIdentities(userIds: readonly string[]): Identities {\n const client = useApolloClient();\n const ids = useMemo(() => [...new Set(userIds.filter(Boolean))].sort(), [userIds]);\n const key = ids.length === 0 ? null : ids.join('\\n');\n const load = useKeyedLoad<MemberIdentity[]>(key, () => loadIdentities(client, ids));\n const byUserId = useMemo(\n () => new Map((load.data ?? []).map((identity) => [identity.userId, identity])),\n [load.data]\n );\n return {\n byUserId,\n status:\n key === null ? 'idle' : load.error ? 'error' : load.dataKey === key ? 'ready' : 'loading',\n retry: load.reload,\n };\n}\n\n/** The most members the guest picker lists (100 a page). */\nconst MEMBER_PAGE = 100;\nconst MAX_MEMBER_PAGES = 10;\n\nasync function loadMembers(client: Client, workspaceId: string): Promise<MemberIdentity[]> {\n const userIds: string[] = [];\n for (let page = 0; page < MAX_MEMBER_PAGES; page += 1) {\n const result = await client.query<CalendarV2MembersQuery, CalendarV2MembersQueryVariables>({\n query: CalendarV2MembersDocument,\n variables: { workspaceId, pagination: { limit: MEMBER_PAGE, offset: page * MEMBER_PAGE } },\n fetchPolicy: 'network-only',\n });\n const list = result.data?.workspaceMembers;\n if (!list) throw new Error('The workspace’s members could not be loaded');\n for (const item of list.items) {\n if (item.status.toLowerCase() === 'active') userIds.push(item.userId);\n }\n if (!list.hasMore || list.items.length === 0) break;\n }\n const people = await loadIdentities(client, [...new Set(userIds)]);\n return people.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }));\n}\n\nexport interface MemberDirectory {\n members: MemberIdentity[];\n status: LoadStatus;\n retry: () => void;\n}\n\n/** The workspace's active members, for the guest picker (read once it opens). */\nexport function useMemberDirectory(enabled: boolean): MemberDirectory {\n const client = useApolloClient();\n const { workspaceId } = useCalendar();\n const key = enabled && workspaceId ? `members|${workspaceId}` : null;\n const load = useKeyedLoad<MemberIdentity[]>(key, () => loadMembers(client, workspaceId ?? ''));\n return {\n members: load.data ?? NO_MEMBERS,\n status:\n key === null ? 'idle' : load.error ? 'error' : load.dataKey === key ? 'ready' : 'loading',\n retry: load.reload,\n };\n}\n\nconst NO_MEMBERS: MemberIdentity[] = [];\n\nexport interface TeamMatch {\n id: string;\n name: string;\n memberCount: number;\n}\n\nexport interface TeamSearch {\n teams: TeamMatch[];\n status: LoadStatus;\n}\n\n/** Teams whose name matches `query` (two letters at least). */\nexport function useTeamSearch(query: string): TeamSearch {\n const client = useApolloClient();\n const text = query.trim();\n const key = text.length >= 2 ? `teams|${text.toLowerCase()}` : null;\n const load = useKeyedLoad<TeamMatch[]>(key, async () => {\n const result = await client.query<\n CalendarV2SearchTeamsQuery,\n CalendarV2SearchTeamsQueryVariables\n >({\n query: CalendarV2SearchTeamsDocument,\n variables: { query: text },\n fetchPolicy: 'network-only',\n });\n if (!result.data) throw new Error('Teams could not be searched');\n return result.data.searchGroups.map((team) => ({\n id: team.id,\n name: team.name,\n memberCount: team.memberCount,\n }));\n });\n return {\n teams: key !== null && load.dataKey === key ? (load.data ?? []) : [],\n status:\n key === null ? 'idle' : load.error ? 'error' : load.dataKey === key ? 'ready' : 'loading',\n };\n}\n\n/** The most members a team adds at once. */\nexport const MAX_TEAM_GUESTS = 100;\n\n/** A team's members' ids (people only), for inviting each. */\nexport async function loadTeamMemberIds(\n client: Client,\n groupId: string\n): Promise<{ userIds: string[]; total: number }> {\n const result = await client.query<\n CalendarV2TeamMembersQuery,\n CalendarV2TeamMembersQueryVariables\n >({\n query: CalendarV2TeamMembersDocument,\n variables: { groupId },\n fetchPolicy: 'network-only',\n });\n const members = result.data?.groupMembers;\n if (!members) throw new Error('The team’s members could not be loaded');\n const userIds = members.edges\n .map((edge) => edge.node)\n .filter((node) => node.entityType.toLowerCase() === 'user')\n .map((node) => node.entityId);\n return { userIds: [...new Set(userIds)].slice(0, MAX_TEAM_GUESTS), total: members.totalCount };\n}\n"],"mappings":";;;;;;;;;;;AAmEA,IAAMA,IAAN,cAAgC,MAAM,CAAC;AAYvC,eAAeC,EACb,GACA,GACA,GACA,GACiC;CACjC,IAAMC,IAAWC,EAAmBC,GAAQC,CAAU;CACtD,IAAI,CAACH,GAAU,OAAO;CAStB,IAAMI,KAAS,MARMC,EAAO,MAG1B;EACA,OAAOC;EACP,WAAWN;EACX,aAAa;CACf,CAAC,EAAA,CACqB,MAAM;CAC5B,IAAI,CAAC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E,WAAQ;EACrB,aAAa;CACf,CAAC,EAAA,CACsB,MAAM;CAC7B,IAAI,CAACD,GAAS,MAAU,MAAM,wCAAwC;CACtE,IAAMvB,IAAUuB,EAAQ,MACrB,KAAK,MAASE,EAAK,IAAI,CAAC,CACxB,QAAQ,MAASC,EAAK,WAAW,YAAY,MAAM,MAAM,CAAC,CAC1D,KAAK,MAASA,EAAK,QAAQ;CAC9B,OAAO;EAAE,SAAS,CAAC,GAAG,IAAI,IAAI1B,CAAO,CAAC,CAAC,CAAC,MAAM,GAAA,GAAkB;EAAG,OAAOuB,EAAQ;CAAW;AAC/F"}
@@ -2,11 +2,16 @@ import { CalendarEventV2 } from '../types';
2
2
  import { EventSession } from './EventDialog';
3
3
  import { EventDialogModel } from './dialogModel';
4
4
  import { FooterNote, ReadBack } from './dialogLogic';
5
+ import { EventForm } from './eventForm';
5
6
  import { EditedEvent } from './useEventData';
6
7
  export interface EventDialogState {
7
8
  model: EventDialogModel;
8
- /** The event being edited; null for a new one. */
9
+ /** The event being edited (a series' date at that date, A4); null for a new one. */
9
10
  event: CalendarEventV2 | null;
11
+ /** The stored event behind it: for a series' date, the series at its first date. */
12
+ row: CalendarEventV2 | null;
13
+ /** A date of a repeating event: the footer asks which events change. */
14
+ seriesDate: boolean;
10
15
  readOnly: boolean;
11
16
  /**
12
17
  * Where reading the edited event back stands (`readBackOf`): null when the dialog holds it as
@@ -14,10 +19,18 @@ export interface EventDialogState {
14
19
  * plan made on the older copy would send again what saved (or create a new event twice).
15
20
  */
16
21
  readBack: ReadBack | null;
17
- /** Something would be lost by closing: the form isn't the event's (or as it opened). */
22
+ /**
23
+ * Something would be lost by closing: the form isn't the event's (or as it opened), or a save
24
+ * left work for the next one.
25
+ */
18
26
  dirty: boolean;
19
- /** Save has something to send (an edit's plan isn't empty; a new event always). */
27
+ /**
28
+ * Save has something to send (an edit's plan isn't empty, or a save left work for the next
29
+ * one; a new event always).
30
+ */
20
31
  toSave: boolean;
32
+ /** What the person's changes are told from (`baselineOf`). */
33
+ baseline: EventForm;
21
34
  /** The calendar a new event goes on (the person's default until they pick). */
22
35
  calendarId: string | null;
23
36
  /** Why the person can't change it; null when they can. */