@rapidmx/web-client 0.2.0

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 (168) hide show
  1. package/LICENSE +382 -0
  2. package/apps/admin/_404.tsx +9 -0
  3. package/apps/admin/_500.tsx +9 -0
  4. package/apps/admin/_layout.tsx +41 -0
  5. package/apps/admin/audit-log/index.tsx +187 -0
  6. package/apps/admin/branding/index.tsx +404 -0
  7. package/apps/admin/distribution-lists/[uid].tsx +70 -0
  8. package/apps/admin/distribution-lists/index.tsx +115 -0
  9. package/apps/admin/distribution-lists/new/index.tsx +114 -0
  10. package/apps/admin/domains/[uid].tsx +259 -0
  11. package/apps/admin/domains/index.tsx +125 -0
  12. package/apps/admin/domains/new/index.tsx +84 -0
  13. package/apps/admin/index.tsx +82 -0
  14. package/apps/admin/ingest-queue/index.tsx +116 -0
  15. package/apps/admin/mailboxes/[uid].tsx +126 -0
  16. package/apps/admin/mailboxes/new/index.tsx +291 -0
  17. package/apps/admin/quarantine/index.tsx +171 -0
  18. package/apps/admin/transport-rules/[uid].tsx +143 -0
  19. package/apps/admin/transport-rules/_transportRuleConfig.tsx +75 -0
  20. package/apps/admin/transport-rules/index.tsx +117 -0
  21. package/apps/admin/transport-rules/new/index.tsx +105 -0
  22. package/apps/shared/components/admin/distributionLists/MemberListCard.tsx +117 -0
  23. package/apps/shared/components/admin/layout/AdminShell.tsx +186 -0
  24. package/apps/shared/components/admin/mailboxes/MailboxTable.tsx +73 -0
  25. package/apps/shared/components/admin/mailboxes/ResourceSettingsCard.tsx +154 -0
  26. package/apps/shared/components/admin/mailboxes/ShareAccessCard.tsx +124 -0
  27. package/apps/shared/components/booking/AvailabilityEditor.tsx +118 -0
  28. package/apps/shared/components/calendar/CalendarListSidebar.tsx +119 -0
  29. package/apps/shared/components/calendar/EventModal.tsx +513 -0
  30. package/apps/shared/components/calendar/MonthView.tsx +139 -0
  31. package/apps/shared/components/calendar/RecurrenceEditor.tsx +180 -0
  32. package/apps/shared/components/calendar/ResourcePicker.tsx +80 -0
  33. package/apps/shared/components/calendar/SplitDayView.tsx +137 -0
  34. package/apps/shared/components/calendar/TimeGridView.tsx +198 -0
  35. package/apps/shared/components/calendar/layout/CalendarShell.tsx +211 -0
  36. package/apps/shared/components/contacts/ContactDetailPane.tsx +99 -0
  37. package/apps/shared/components/contacts/ContactForm.tsx +314 -0
  38. package/apps/shared/components/contacts/ContactsSidebar.tsx +242 -0
  39. package/apps/shared/components/contacts/ContactsToolbar.tsx +115 -0
  40. package/apps/shared/components/contacts/layout/ContactsShell.tsx +197 -0
  41. package/apps/shared/components/layout/AppShell.tsx +165 -0
  42. package/apps/shared/components/layout/BrandingChrome.tsx +25 -0
  43. package/apps/shared/components/layout/MailboxProvisioning.tsx +110 -0
  44. package/apps/shared/components/layout/UserMenu.tsx +150 -0
  45. package/apps/shared/components/mail/ConversationList.tsx +61 -0
  46. package/apps/shared/components/mail/ConversationThreadPane.tsx +174 -0
  47. package/apps/shared/components/mail/MessageDetailPane.tsx +390 -0
  48. package/apps/shared/components/mail/compose/ComposeContext.tsx +114 -0
  49. package/apps/shared/components/mail/compose/ComposeToolbar.tsx +418 -0
  50. package/apps/shared/components/mail/compose/ComposeWindow.tsx +518 -0
  51. package/apps/shared/components/mail/compose/EmojiPicker.tsx +64 -0
  52. package/apps/shared/components/mail/compose/GifPicker.tsx +82 -0
  53. package/apps/shared/components/mail/compose/RichTextEditor.tsx +83 -0
  54. package/apps/shared/components/mail/compose/ScheduleSendPicker.tsx +64 -0
  55. package/apps/shared/components/mail/layout/MailShell.tsx +287 -0
  56. package/apps/shared/components/rules/RuleBuilder.tsx +276 -0
  57. package/apps/shared/components/settings/layout/SettingsShell.tsx +223 -0
  58. package/apps/shared/components/tasks/TasksSidebar.tsx +201 -0
  59. package/apps/shared/components/tasks/TasksToolbar.tsx +68 -0
  60. package/apps/shared/components/tasks/layout/TasksShell.tsx +199 -0
  61. package/apps/shared/styles/app.css +265 -0
  62. package/apps/www/_404.tsx +9 -0
  63. package/apps/www/_500.tsx +9 -0
  64. package/apps/www/_layout.tsx +45 -0
  65. package/apps/www/calendar/index.tsx +407 -0
  66. package/apps/www/contacts/[uid].tsx +88 -0
  67. package/apps/www/contacts/index.tsx +436 -0
  68. package/apps/www/index.tsx +375 -0
  69. package/apps/www/messages/[uid].tsx +70 -0
  70. package/apps/www/settings/auto-reply/index.tsx +129 -0
  71. package/apps/www/settings/booking-types/[uid].tsx +300 -0
  72. package/apps/www/settings/booking-types/index.tsx +98 -0
  73. package/apps/www/settings/booking-types/new/index.tsx +212 -0
  74. package/apps/www/settings/filters/[uid].tsx +155 -0
  75. package/apps/www/settings/filters/_mailFilterRuleConfig.tsx +102 -0
  76. package/apps/www/settings/filters/index.tsx +99 -0
  77. package/apps/www/settings/filters/new/index.tsx +126 -0
  78. package/apps/www/settings/focused-inbox/index.tsx +148 -0
  79. package/apps/www/settings/read-receipts/index.tsx +125 -0
  80. package/apps/www/settings/signatures/[uid].tsx +167 -0
  81. package/apps/www/settings/signatures/index.tsx +85 -0
  82. package/apps/www/settings/signatures/new/index.tsx +129 -0
  83. package/apps/www/settings/signatures/signatureDefaults.ts +36 -0
  84. package/apps/www/tasks/index.tsx +530 -0
  85. package/dist/apps/admin/_404.js +4 -0
  86. package/dist/apps/admin/_500.js +4 -0
  87. package/dist/apps/admin/_layout.js +10 -0
  88. package/dist/apps/admin/audit-log/index.js +66 -0
  89. package/dist/apps/admin/branding/index.js +126 -0
  90. package/dist/apps/admin/distribution-lists/[uid].js +34 -0
  91. package/dist/apps/admin/distribution-lists/index.js +31 -0
  92. package/dist/apps/admin/distribution-lists/new/index.js +51 -0
  93. package/dist/apps/admin/domains/[uid].js +102 -0
  94. package/dist/apps/admin/domains/index.js +31 -0
  95. package/dist/apps/admin/domains/new/index.js +41 -0
  96. package/dist/apps/admin/index.js +32 -0
  97. package/dist/apps/admin/ingest-queue/index.js +48 -0
  98. package/dist/apps/admin/mailboxes/[uid].js +59 -0
  99. package/dist/apps/admin/mailboxes/new/index.js +93 -0
  100. package/dist/apps/admin/quarantine/index.js +66 -0
  101. package/dist/apps/admin/transport-rules/[uid].js +87 -0
  102. package/dist/apps/admin/transport-rules/_transportRuleConfig.js +37 -0
  103. package/dist/apps/admin/transport-rules/index.js +32 -0
  104. package/dist/apps/admin/transport-rules/new/index.js +50 -0
  105. package/dist/apps/shared/components/admin/distributionLists/MemberListCard.js +64 -0
  106. package/dist/apps/shared/components/admin/layout/AdminShell.js +94 -0
  107. package/dist/apps/shared/components/admin/mailboxes/MailboxTable.js +16 -0
  108. package/dist/apps/shared/components/admin/mailboxes/ResourceSettingsCard.js +59 -0
  109. package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.js +67 -0
  110. package/dist/apps/shared/components/booking/AvailabilityEditor.js +45 -0
  111. package/dist/apps/shared/components/calendar/CalendarListSidebar.js +44 -0
  112. package/dist/apps/shared/components/calendar/EventModal.js +167 -0
  113. package/dist/apps/shared/components/calendar/MonthView.js +38 -0
  114. package/dist/apps/shared/components/calendar/RecurrenceEditor.js +55 -0
  115. package/dist/apps/shared/components/calendar/ResourcePicker.js +36 -0
  116. package/dist/apps/shared/components/calendar/SplitDayView.js +44 -0
  117. package/dist/apps/shared/components/calendar/TimeGridView.js +58 -0
  118. package/dist/apps/shared/components/calendar/layout/CalendarShell.js +96 -0
  119. package/dist/apps/shared/components/contacts/ContactDetailPane.js +11 -0
  120. package/dist/apps/shared/components/contacts/ContactForm.js +85 -0
  121. package/dist/apps/shared/components/contacts/ContactsSidebar.js +105 -0
  122. package/dist/apps/shared/components/contacts/ContactsToolbar.js +32 -0
  123. package/dist/apps/shared/components/contacts/layout/ContactsShell.js +93 -0
  124. package/dist/apps/shared/components/layout/AppShell.js +68 -0
  125. package/dist/apps/shared/components/layout/BrandingChrome.js +18 -0
  126. package/dist/apps/shared/components/layout/MailboxProvisioning.js +75 -0
  127. package/dist/apps/shared/components/layout/UserMenu.js +59 -0
  128. package/dist/apps/shared/components/mail/ConversationList.js +17 -0
  129. package/dist/apps/shared/components/mail/ConversationThreadPane.js +112 -0
  130. package/dist/apps/shared/components/mail/MessageDetailPane.js +153 -0
  131. package/dist/apps/shared/components/mail/compose/ComposeContext.js +55 -0
  132. package/dist/apps/shared/components/mail/compose/ComposeToolbar.js +88 -0
  133. package/dist/apps/shared/components/mail/compose/ComposeWindow.js +261 -0
  134. package/dist/apps/shared/components/mail/compose/EmojiPicker.js +25 -0
  135. package/dist/apps/shared/components/mail/compose/GifPicker.js +36 -0
  136. package/dist/apps/shared/components/mail/compose/RichTextEditor.js +60 -0
  137. package/dist/apps/shared/components/mail/compose/ScheduleSendPicker.js +33 -0
  138. package/dist/apps/shared/components/mail/layout/MailShell.js +139 -0
  139. package/dist/apps/shared/components/rules/RuleBuilder.js +78 -0
  140. package/dist/apps/shared/components/settings/layout/SettingsShell.js +100 -0
  141. package/dist/apps/shared/components/tasks/TasksSidebar.js +81 -0
  142. package/dist/apps/shared/components/tasks/TasksToolbar.js +15 -0
  143. package/dist/apps/shared/components/tasks/layout/TasksShell.js +92 -0
  144. package/dist/apps/shared/styles/app.css +265 -0
  145. package/dist/apps/www/_404.js +4 -0
  146. package/dist/apps/www/_500.js +4 -0
  147. package/dist/apps/www/_layout.js +8 -0
  148. package/dist/apps/www/calendar/index.js +228 -0
  149. package/dist/apps/www/contacts/[uid].js +62 -0
  150. package/dist/apps/www/contacts/index.js +262 -0
  151. package/dist/apps/www/index.js +228 -0
  152. package/dist/apps/www/messages/[uid].js +47 -0
  153. package/dist/apps/www/settings/auto-reply/index.js +54 -0
  154. package/dist/apps/www/settings/booking-types/[uid].js +129 -0
  155. package/dist/apps/www/settings/booking-types/index.js +29 -0
  156. package/dist/apps/www/settings/booking-types/new/index.js +86 -0
  157. package/dist/apps/www/settings/filters/[uid].js +94 -0
  158. package/dist/apps/www/settings/filters/_mailFilterRuleConfig.js +65 -0
  159. package/dist/apps/www/settings/filters/index.js +30 -0
  160. package/dist/apps/www/settings/filters/new/index.js +61 -0
  161. package/dist/apps/www/settings/focused-inbox/index.js +69 -0
  162. package/dist/apps/www/settings/read-receipts/index.js +51 -0
  163. package/dist/apps/www/settings/signatures/[uid].js +96 -0
  164. package/dist/apps/www/settings/signatures/index.js +34 -0
  165. package/dist/apps/www/settings/signatures/new/index.js +63 -0
  166. package/dist/apps/www/settings/signatures/signatureDefaults.js +30 -0
  167. package/dist/apps/www/tasks/index.js +280 -0
  168. package/package.json +87 -0
@@ -0,0 +1,300 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import React, { FormEvent, useEffect, useState } from "react";
6
+ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
7
+ import {
8
+ BookingAvailabilityWindow,
9
+ BookingType,
10
+ deleteBookingType,
11
+ getBookingType,
12
+ updateBookingType,
13
+ } from "@rapidmx/react-shared/booking/bookingApi.js";
14
+ import SettingsShell, { SettingsShellProps, useSettingsShell } from "../../../shared/components/settings/layout/SettingsShell.js";
15
+ import AvailabilityEditor from "../../../shared/components/booking/AvailabilityEditor.js";
16
+ import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
17
+ import Button from "@rapidmx/react-shared/components/buttons/Button.js";
18
+ import FormField from "@rapidmx/react-shared/components/forms/FormField.js";
19
+ import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
20
+
21
+ const INPUT_CLASS =
22
+ "w-full text-sm py-2.5 px-3 border border-border rounded-sm bg-surface text-text focus:outline-none focus:border-primary";
23
+
24
+ export type BookingTypeDetailPageProps = Omit<SettingsShellProps, "active"> & { params: { uid: string } };
25
+
26
+ export default function BookingTypeDetailPage(props: BookingTypeDetailPageProps) {
27
+ return (
28
+ <SettingsShell {...props} active="booking-types">
29
+ <BookingTypeDetailContent uid={props.params.uid} />
30
+ </SettingsShell>
31
+ );
32
+ }
33
+
34
+ function BookingTypeDetailContent({ uid }: { uid: string }) {
35
+ const { mailboxUid } = useSettingsShell();
36
+ const [bookingType, setBookingType] = useState<BookingType | null>(null);
37
+ const [name, setName] = useState("");
38
+ const [description, setDescription] = useState("");
39
+ const [hostDisplayName, setHostDisplayName] = useState("");
40
+ const [durationMinutes, setDurationMinutes] = useState(30);
41
+ const [timezone, setTimezone] = useState("");
42
+ const [availability, setAvailability] = useState<BookingAvailabilityWindow[]>([]);
43
+ const [minimumNoticeMinutes, setMinimumNoticeMinutes] = useState(60);
44
+ const [bookingWindowDays, setBookingWindowDays] = useState(30);
45
+ const [requiresApproval, setRequiresApproval] = useState(false);
46
+ const [enabled, setEnabled] = useState(true);
47
+ const [loading, setLoading] = useState(true);
48
+ const [error, setError] = useState<string | null>(null);
49
+ const [saving, setSaving] = useState(false);
50
+ const [saved, setSaved] = useState(false);
51
+ const [copied, setCopied] = useState(false);
52
+ const [confirmingDelete, setConfirmingDelete] = useState(false);
53
+ const [deleting, setDeleting] = useState(false);
54
+ const [deleteError, setDeleteError] = useState<string | null>(null);
55
+
56
+ useEffect(() => {
57
+ setLoading(true);
58
+ setError(null);
59
+ getBookingType(uid)
60
+ .then((bt) => {
61
+ setBookingType(bt);
62
+ setName(bt.name);
63
+ setDescription(bt.description ?? "");
64
+ setHostDisplayName(bt.hostDisplayName);
65
+ setDurationMinutes(bt.durationMinutes);
66
+ setTimezone(bt.timezone);
67
+ setAvailability(bt.availability);
68
+ setMinimumNoticeMinutes(bt.minimumNoticeMinutes);
69
+ setBookingWindowDays(bt.bookingWindowDays);
70
+ setRequiresApproval(bt.requiresApproval);
71
+ setEnabled(bt.enabled);
72
+ })
73
+ .catch((err) => setError(err instanceof ApiRequestError ? err.message : "Could not load this booking link."))
74
+ .finally(() => setLoading(false));
75
+ }, [uid]);
76
+
77
+ async function handleSubmit(e: FormEvent) {
78
+ e.preventDefault();
79
+ setError(null);
80
+ setSaved(false);
81
+ setSaving(true);
82
+ try {
83
+ const updated = await updateBookingType({
84
+ uid: bookingType!.uid,
85
+ version: bookingType!.version,
86
+ name,
87
+ description: description.trim() || undefined,
88
+ hostDisplayName,
89
+ durationMinutes,
90
+ timezone,
91
+ availability,
92
+ minimumNoticeMinutes,
93
+ bookingWindowDays,
94
+ requiresApproval,
95
+ enabled,
96
+ });
97
+ setBookingType(updated);
98
+ setSaved(true);
99
+ } catch (err) {
100
+ setError(err instanceof ApiRequestError ? err.message : "Could not save this booking link.");
101
+ } finally {
102
+ setSaving(false);
103
+ }
104
+ }
105
+
106
+ async function handleCopy(value: string) {
107
+ try {
108
+ await navigator.clipboard.writeText(value);
109
+ setCopied(true);
110
+ setTimeout(() => setCopied(false), 2000);
111
+ } catch {
112
+ // Clipboard access can be denied by the browser — the value is still selectable/copyable by hand.
113
+ }
114
+ }
115
+
116
+ async function handleDelete() {
117
+ setDeleting(true);
118
+ setDeleteError(null);
119
+ try {
120
+ await deleteBookingType(bookingType!.uid, bookingType!.version);
121
+ window.location.href = `/settings/booking-types?mailboxUid=${encodeURIComponent(mailboxUid!)}`;
122
+ } catch (err) {
123
+ setDeleteError(err instanceof ApiRequestError ? err.message : "Could not delete this booking link.");
124
+ setDeleting(false);
125
+ }
126
+ }
127
+
128
+ if (loading) {
129
+ return <p className="p-6 text-sm text-text-muted">Loading&hellip;</p>;
130
+ }
131
+ if (error || !bookingType) {
132
+ // `error` is always set whenever `bookingType` is falsy here: the load effect above destructures
133
+ // every field off the resolved value directly (`bt.name`, `bt.hostDisplayName`, ...), so a
134
+ // successful-but-empty response throws into `.catch()` — which sets `error` — before this
135
+ // component ever renders past the `loading` guard above. `!bookingType` alone (with `error` still
136
+ // `null`) is therefore unreachable, unlike e.g. `messages/[uid].tsx`'s identical-looking check,
137
+ // which stores its fetched value whole rather than destructuring it.
138
+ return (
139
+ <div className="p-6">
140
+ <Alert>{error!}</Alert>
141
+ </div>
142
+ );
143
+ }
144
+
145
+ // `bookingType` only ever becomes non-null via the client-only fetch above, so by the time this line
146
+ // runs `window` is always defined — the `!bookingType` early return just above covers every real SSR
147
+ // pass, where `bookingType` is still `null`.
148
+ const publicUrl = `${window.location.origin}/book/${encodeURIComponent(bookingType.slug)}`;
149
+
150
+ return (
151
+ <div className="flex-1 min-w-0 overflow-y-auto p-6">
152
+ <div className="max-w-2xl">
153
+ <div className="flex items-start justify-between gap-4 mb-1">
154
+ <div>
155
+ <a
156
+ href={`/settings/booking-types?mailboxUid=${encodeURIComponent(mailboxUid!)}`}
157
+ className="text-sm text-primary-dark hover:underline"
158
+ >
159
+ &larr; All booking links
160
+ </a>
161
+ <h1 className="text-xl font-bold tracking-tight mt-1">{bookingType.name}</h1>
162
+ </div>
163
+ <Button
164
+ type="button"
165
+ variant="secondary"
166
+ className="!w-auto shrink-0 !border-danger !text-danger hover:!border-danger hover:!text-danger"
167
+ onClick={() => setConfirmingDelete(true)}
168
+ >
169
+ Delete
170
+ </Button>
171
+ </div>
172
+
173
+ <div className="flex items-center gap-2 mb-5">
174
+ <code className="flex-1 text-xs bg-surface-alt border border-border rounded-sm py-2 px-3 overflow-x-auto whitespace-nowrap">
175
+ {publicUrl}
176
+ </code>
177
+ <Button type="button" variant="secondary" className="!w-auto shrink-0" onClick={() => handleCopy(publicUrl)}>
178
+ {copied ? "Copied" : "Copy"}
179
+ </Button>
180
+ </div>
181
+
182
+ {saved && !error && <div className="mb-4 text-sm text-success font-medium">Saved.</div>}
183
+
184
+ <form onSubmit={handleSubmit} className="flex flex-col gap-1">
185
+ <label className="flex items-center gap-2 text-sm mb-3">
186
+ <input type="checkbox" checked={enabled} onChange={(e) => setEnabled(e.target.checked)} />
187
+ Enabled (publicly bookable)
188
+ </label>
189
+ <FormField label="Name" htmlFor="name">
190
+ <input id="name" type="text" className={INPUT_CLASS} value={name} onChange={(e) => setName(e.target.value)} />
191
+ </FormField>
192
+ <FormField label="Description (optional)" htmlFor="description">
193
+ <textarea
194
+ id="description"
195
+ className={INPUT_CLASS}
196
+ rows={2}
197
+ value={description}
198
+ onChange={(e) => setDescription(e.target.value)}
199
+ />
200
+ </FormField>
201
+ <FormField label="Host name shown to visitors" htmlFor="hostDisplayName">
202
+ <input
203
+ id="hostDisplayName"
204
+ type="text"
205
+ className={INPUT_CLASS}
206
+ value={hostDisplayName}
207
+ onChange={(e) => setHostDisplayName(e.target.value)}
208
+ />
209
+ </FormField>
210
+ <div className="grid grid-cols-2 gap-3">
211
+ <FormField label="Duration (minutes)" htmlFor="durationMinutes">
212
+ <input
213
+ id="durationMinutes"
214
+ type="number"
215
+ min={1}
216
+ className={INPUT_CLASS}
217
+ value={durationMinutes}
218
+ onChange={(e) => setDurationMinutes(Number(e.target.value))}
219
+ />
220
+ </FormField>
221
+ <FormField label="Timezone" htmlFor="timezone">
222
+ <input
223
+ id="timezone"
224
+ type="text"
225
+ className={INPUT_CLASS}
226
+ value={timezone}
227
+ onChange={(e) => setTimezone(e.target.value)}
228
+ />
229
+ </FormField>
230
+ </div>
231
+ <div className="grid grid-cols-2 gap-3">
232
+ <FormField label="Minimum notice (minutes)" htmlFor="minimumNoticeMinutes">
233
+ <input
234
+ id="minimumNoticeMinutes"
235
+ type="number"
236
+ min={0}
237
+ className={INPUT_CLASS}
238
+ value={minimumNoticeMinutes}
239
+ onChange={(e) => setMinimumNoticeMinutes(Number(e.target.value))}
240
+ />
241
+ </FormField>
242
+ <FormField label="Booking window (days ahead)" htmlFor="bookingWindowDays">
243
+ <input
244
+ id="bookingWindowDays"
245
+ type="number"
246
+ min={1}
247
+ className={INPUT_CLASS}
248
+ value={bookingWindowDays}
249
+ onChange={(e) => setBookingWindowDays(Number(e.target.value))}
250
+ />
251
+ </FormField>
252
+ </div>
253
+ <label className="flex items-center gap-2 text-sm my-3">
254
+ <input type="checkbox" checked={requiresApproval} onChange={(e) => setRequiresApproval(e.target.checked)} />
255
+ Require my approval before confirming a booking
256
+ </label>
257
+
258
+ <div className="mb-4">
259
+ <span className="block text-sm font-semibold mb-1.5 text-text">Weekly availability</span>
260
+ <AvailabilityEditor value={availability} onChange={setAvailability} />
261
+ </div>
262
+
263
+ <div>
264
+ <Button type="submit" loading={saving} disabled={saving} className="!w-auto">
265
+ Save
266
+ </Button>
267
+ </div>
268
+ </form>
269
+
270
+ <Modal open={confirmingDelete} onClose={() => setConfirmingDelete(false)} title="Delete booking link">
271
+ <p className="text-sm mb-5">
272
+ Are you sure you want to delete <strong>{bookingType.name}</strong>? Its public link will stop
273
+ working immediately. This cannot be undone.
274
+ </p>
275
+ {deleteError && <Alert>{deleteError}</Alert>}
276
+ <div className="flex gap-3 justify-end mt-5">
277
+ <Button
278
+ type="button"
279
+ variant="secondary"
280
+ className="!w-auto"
281
+ disabled={deleting}
282
+ onClick={() => setConfirmingDelete(false)}
283
+ >
284
+ Cancel
285
+ </Button>
286
+ <Button
287
+ type="button"
288
+ className="!w-auto !bg-none !bg-danger !border-danger hover:!bg-danger"
289
+ loading={deleting}
290
+ disabled={deleting}
291
+ onClick={handleDelete}
292
+ >
293
+ Delete
294
+ </Button>
295
+ </div>
296
+ </Modal>
297
+ </div>
298
+ </div>
299
+ );
300
+ }
@@ -0,0 +1,98 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import React, { useEffect, useState } from "react";
6
+ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
7
+ import { BookingType, listBookingTypes } from "@rapidmx/react-shared/booking/bookingApi.js";
8
+ import SettingsShell, { SettingsShellProps, useSettingsShell } from "../../../shared/components/settings/layout/SettingsShell.js";
9
+ import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
10
+ import Button from "@rapidmx/react-shared/components/buttons/Button.js";
11
+
12
+ export type SettingsBookingTypesPageProps = Omit<SettingsShellProps, "active">;
13
+
14
+ export default function SettingsBookingTypesPage(props: SettingsBookingTypesPageProps) {
15
+ return (
16
+ <SettingsShell {...props} active="booking-types">
17
+ <BookingTypesContent />
18
+ </SettingsShell>
19
+ );
20
+ }
21
+
22
+ function BookingTypesContent() {
23
+ const { mailboxUid } = useSettingsShell();
24
+ const [bookingTypes, setBookingTypes] = useState<BookingType[]>([]);
25
+ const [loading, setLoading] = useState(true);
26
+ const [error, setError] = useState<string | null>(null);
27
+
28
+ // `SettingsShell` only ever renders its children once `mailboxUid` has resolved — same established
29
+ // non-null pattern as `apps/www/settings/filters/index.tsx`.
30
+ useEffect(() => {
31
+ listBookingTypes(mailboxUid!)
32
+ .then(setBookingTypes)
33
+ .catch((err) => setError(err instanceof ApiRequestError ? err.message : "Could not load your booking links."))
34
+ .finally(() => setLoading(false));
35
+ }, [mailboxUid]);
36
+
37
+ return (
38
+ <div className="flex-1 min-w-0 overflow-y-auto p-6">
39
+ <div className="max-w-3xl">
40
+ <div className="flex items-center justify-between mb-5">
41
+ <h1 className="text-lg font-bold tracking-tight">Booking Links</h1>
42
+ <a href={`/settings/booking-types/new?mailboxUid=${encodeURIComponent(mailboxUid!)}`}>
43
+ <Button type="button" className="!w-auto">
44
+ + New booking link
45
+ </Button>
46
+ </a>
47
+ </div>
48
+ <p className="text-sm text-text-muted mb-4">
49
+ Share a link and let anyone pick a real open slot on your calendar — no account needed on
50
+ their end.
51
+ </p>
52
+
53
+ {error && <Alert>{error}</Alert>}
54
+
55
+ {loading ? (
56
+ <p className="text-sm text-text-muted">Loading&hellip;</p>
57
+ ) : bookingTypes.length === 0 ? (
58
+ <p className="text-sm text-text-muted">No booking links yet.</p>
59
+ ) : (
60
+ <div className="overflow-x-auto">
61
+ <table className="w-full text-sm border-collapse">
62
+ <thead>
63
+ <tr>
64
+ {["Name", "Link", "Duration", "Enabled", ""].map((h) => (
65
+ <th
66
+ key={h}
67
+ className="text-left text-xs uppercase tracking-wide text-text-muted py-2 px-2.5 border-b border-border"
68
+ >
69
+ {h}
70
+ </th>
71
+ ))}
72
+ </tr>
73
+ </thead>
74
+ <tbody>
75
+ {bookingTypes.map((bookingType) => (
76
+ <tr key={bookingType.uid}>
77
+ <td className="py-2.5 px-2.5 border-b border-border">{bookingType.name}</td>
78
+ <td className="py-2.5 px-2.5 border-b border-border">/book/{bookingType.slug}</td>
79
+ <td className="py-2.5 px-2.5 border-b border-border">{bookingType.durationMinutes} min</td>
80
+ <td className="py-2.5 px-2.5 border-b border-border">{bookingType.enabled ? "Yes" : "No"}</td>
81
+ <td className="py-2.5 px-2.5 border-b border-border text-right">
82
+ <a
83
+ href={`/settings/booking-types/${encodeURIComponent(bookingType.uid)}?mailboxUid=${encodeURIComponent(mailboxUid!)}`}
84
+ className="text-primary-dark hover:underline font-medium"
85
+ >
86
+ View
87
+ </a>
88
+ </td>
89
+ </tr>
90
+ ))}
91
+ </tbody>
92
+ </table>
93
+ </div>
94
+ )}
95
+ </div>
96
+ </div>
97
+ );
98
+ }
@@ -0,0 +1,212 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import React, { FormEvent, useEffect, useState } from "react";
6
+ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
7
+ import { Folder, listFolders } from "@rapidmx/react-shared/mail/mailApi.js";
8
+ import { BookingAvailabilityWindow, createBookingType } from "@rapidmx/react-shared/booking/bookingApi.js";
9
+ import SettingsShell, { SettingsShellProps, useSettingsShell } from "../../../../shared/components/settings/layout/SettingsShell.js";
10
+ import AvailabilityEditor from "../../../../shared/components/booking/AvailabilityEditor.js";
11
+ import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
12
+ import Button from "@rapidmx/react-shared/components/buttons/Button.js";
13
+ import FormField from "@rapidmx/react-shared/components/forms/FormField.js";
14
+
15
+ const INPUT_CLASS =
16
+ "w-full text-sm py-2.5 px-3 border border-border rounded-sm bg-surface text-text focus:outline-none focus:border-primary";
17
+
18
+ export type NewBookingTypePageProps = Omit<SettingsShellProps, "active">;
19
+
20
+ export default function NewBookingTypePage(props: NewBookingTypePageProps) {
21
+ return (
22
+ <SettingsShell {...props} active="booking-types">
23
+ <NewBookingTypeForm />
24
+ </SettingsShell>
25
+ );
26
+ }
27
+
28
+ function NewBookingTypeForm() {
29
+ const { mailboxUid, mailboxes } = useSettingsShell();
30
+ // Same established non-null pattern as `apps/www/settings/filters/new/index.tsx`.
31
+ const mailbox = mailboxes.find((mb) => mb.uid === mailboxUid)!;
32
+
33
+ const [calendarFolderUid, setCalendarFolderUid] = useState<string | null>(null);
34
+ const [folderError, setFolderError] = useState<string | null>(null);
35
+ const [slug, setSlug] = useState("");
36
+ const [name, setName] = useState("");
37
+ const [description, setDescription] = useState("");
38
+ const [hostDisplayName, setHostDisplayName] = useState(mailbox.displayName);
39
+ const [durationMinutes, setDurationMinutes] = useState(30);
40
+ const [timezone, setTimezone] = useState(mailbox.timezone);
41
+ const [availability, setAvailability] = useState<BookingAvailabilityWindow[]>([]);
42
+ const [minimumNoticeMinutes, setMinimumNoticeMinutes] = useState(60);
43
+ const [bookingWindowDays, setBookingWindowDays] = useState(30);
44
+ const [requiresApproval, setRequiresApproval] = useState(false);
45
+ const [error, setError] = useState<string | null>(null);
46
+ const [saving, setSaving] = useState(false);
47
+
48
+ useEffect(() => {
49
+ listFolders(mailboxUid!)
50
+ .then((folders) => {
51
+ const calendar = folders.find((f: Folder) => f.type === "calendar");
52
+ if (!calendar) {
53
+ setFolderError("This mailbox has no Calendar folder yet.");
54
+ return;
55
+ }
56
+ setCalendarFolderUid(calendar.uid);
57
+ })
58
+ .catch((err) => setFolderError(err instanceof ApiRequestError ? err.message : "Could not load this mailbox's folders."));
59
+ }, [mailboxUid]);
60
+
61
+ async function handleSubmit(e: FormEvent) {
62
+ e.preventDefault();
63
+ setError(null);
64
+
65
+ if (!slug.trim() || !name.trim() || !hostDisplayName.trim()) {
66
+ setError("Slug, name, and host name are all required.");
67
+ return;
68
+ }
69
+ if (!calendarFolderUid) {
70
+ setError("This mailbox has no Calendar folder yet.");
71
+ return;
72
+ }
73
+
74
+ setSaving(true);
75
+ try {
76
+ const created = await createBookingType({
77
+ mailboxUid: mailboxUid!,
78
+ calendarFolderUid,
79
+ slug: slug.trim(),
80
+ name: name.trim(),
81
+ description: description.trim() || undefined,
82
+ hostDisplayName: hostDisplayName.trim(),
83
+ durationMinutes,
84
+ timezone,
85
+ availability,
86
+ minimumNoticeMinutes,
87
+ bookingWindowDays,
88
+ requiresApproval,
89
+ });
90
+ window.location.href = `/settings/booking-types/${encodeURIComponent(created.uid)}?mailboxUid=${encodeURIComponent(mailboxUid!)}`;
91
+ } catch (err) {
92
+ setError(err instanceof ApiRequestError ? err.message : "Could not create this booking link.");
93
+ } finally {
94
+ setSaving(false);
95
+ }
96
+ }
97
+
98
+ return (
99
+ <div className="flex-1 min-w-0 overflow-y-auto p-6">
100
+ <div className="max-w-2xl">
101
+ <h1 className="text-lg font-bold tracking-tight mb-1">New booking link</h1>
102
+ <p className="text-sm text-text-muted mb-5">
103
+ Anyone with the link can pick an open slot from your live availability below — no account
104
+ needed on their end.
105
+ </p>
106
+
107
+ {error && <Alert>{error}</Alert>}
108
+ {folderError && <Alert>{folderError}</Alert>}
109
+
110
+ <form onSubmit={handleSubmit} className="flex flex-col gap-1">
111
+ <FormField label="Name" htmlFor="name">
112
+ <input
113
+ id="name"
114
+ type="text"
115
+ className={INPUT_CLASS}
116
+ value={name}
117
+ onChange={(e) => setName(e.target.value)}
118
+ placeholder="30 Minute Intro Call"
119
+ />
120
+ </FormField>
121
+ <FormField label="Slug (used in the public link)" htmlFor="slug">
122
+ <input
123
+ id="slug"
124
+ type="text"
125
+ className={INPUT_CLASS}
126
+ value={slug}
127
+ onChange={(e) => setSlug(e.target.value)}
128
+ placeholder="intro-call"
129
+ />
130
+ </FormField>
131
+ <FormField label="Description (optional)" htmlFor="description">
132
+ <textarea
133
+ id="description"
134
+ className={INPUT_CLASS}
135
+ rows={2}
136
+ value={description}
137
+ onChange={(e) => setDescription(e.target.value)}
138
+ />
139
+ </FormField>
140
+ <FormField label="Host name shown to visitors" htmlFor="hostDisplayName">
141
+ <input
142
+ id="hostDisplayName"
143
+ type="text"
144
+ className={INPUT_CLASS}
145
+ value={hostDisplayName}
146
+ onChange={(e) => setHostDisplayName(e.target.value)}
147
+ />
148
+ </FormField>
149
+ <div className="grid grid-cols-2 gap-3">
150
+ <FormField label="Duration (minutes)" htmlFor="durationMinutes">
151
+ <input
152
+ id="durationMinutes"
153
+ type="number"
154
+ min={1}
155
+ className={INPUT_CLASS}
156
+ value={durationMinutes}
157
+ onChange={(e) => setDurationMinutes(Number(e.target.value))}
158
+ />
159
+ </FormField>
160
+ <FormField label="Timezone" htmlFor="timezone">
161
+ <input
162
+ id="timezone"
163
+ type="text"
164
+ className={INPUT_CLASS}
165
+ value={timezone}
166
+ onChange={(e) => setTimezone(e.target.value)}
167
+ placeholder="America/New_York"
168
+ />
169
+ </FormField>
170
+ </div>
171
+ <div className="grid grid-cols-2 gap-3">
172
+ <FormField label="Minimum notice (minutes)" htmlFor="minimumNoticeMinutes">
173
+ <input
174
+ id="minimumNoticeMinutes"
175
+ type="number"
176
+ min={0}
177
+ className={INPUT_CLASS}
178
+ value={minimumNoticeMinutes}
179
+ onChange={(e) => setMinimumNoticeMinutes(Number(e.target.value))}
180
+ />
181
+ </FormField>
182
+ <FormField label="Booking window (days ahead)" htmlFor="bookingWindowDays">
183
+ <input
184
+ id="bookingWindowDays"
185
+ type="number"
186
+ min={1}
187
+ className={INPUT_CLASS}
188
+ value={bookingWindowDays}
189
+ onChange={(e) => setBookingWindowDays(Number(e.target.value))}
190
+ />
191
+ </FormField>
192
+ </div>
193
+ <label className="flex items-center gap-2 text-sm my-3">
194
+ <input type="checkbox" checked={requiresApproval} onChange={(e) => setRequiresApproval(e.target.checked)} />
195
+ Require my approval before confirming a booking
196
+ </label>
197
+
198
+ <div className="mb-4">
199
+ <span className="block text-sm font-semibold mb-1.5 text-text">Weekly availability</span>
200
+ <AvailabilityEditor value={availability} onChange={setAvailability} />
201
+ </div>
202
+
203
+ <div>
204
+ <Button type="submit" loading={saving} disabled={saving} className="!w-auto">
205
+ Create
206
+ </Button>
207
+ </div>
208
+ </form>
209
+ </div>
210
+ </div>
211
+ );
212
+ }