@rapidmx/web-client 0.5.0 → 0.6.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 (164) hide show
  1. package/README.md +88 -0
  2. package/apps/shared/components/admin/layout/AdminShell.tsx +25 -8
  3. package/apps/shared/components/calendar/layout/CalendarShell.tsx +194 -192
  4. package/apps/shared/components/contacts/layout/ContactsShell.tsx +199 -197
  5. package/apps/shared/components/layout/AppShell.tsx +36 -18
  6. package/apps/shared/components/mail/layout/MailShell.tsx +420 -418
  7. package/apps/shared/components/settings/layout/SettingsShell.tsx +23 -9
  8. package/apps/shared/components/tasks/layout/TasksShell.tsx +201 -199
  9. package/apps/shared/plugins/pluginNav.ts +73 -0
  10. package/apps/shared/search/localIndexRpcClient.ts +3 -1
  11. package/dist/apps/admin/_404.d.ts +2 -0
  12. package/dist/apps/admin/_500.d.ts +2 -0
  13. package/dist/apps/admin/_layout.d.ts +8 -0
  14. package/dist/apps/admin/audit-log/index.d.ts +11 -0
  15. package/dist/apps/admin/branding/index.d.ts +3 -0
  16. package/dist/apps/admin/data-requests/index.d.ts +3 -0
  17. package/dist/apps/admin/distribution-lists/[uid].d.ts +7 -0
  18. package/dist/apps/admin/distribution-lists/index.d.ts +3 -0
  19. package/dist/apps/admin/distribution-lists/new/index.d.ts +3 -0
  20. package/dist/apps/admin/domains/[uid].d.ts +7 -0
  21. package/dist/apps/admin/domains/index.d.ts +3 -0
  22. package/dist/apps/admin/domains/new/index.d.ts +3 -0
  23. package/dist/apps/admin/encryption-policy/index.d.ts +3 -0
  24. package/dist/apps/admin/escrow-scopes/[uid].d.ts +21 -0
  25. package/dist/apps/admin/escrow-scopes/index.d.ts +3 -0
  26. package/dist/apps/admin/escrow-scopes/new/index.d.ts +3 -0
  27. package/dist/apps/admin/index.d.ts +3 -0
  28. package/dist/apps/admin/ingest-queue/index.d.ts +4 -0
  29. package/dist/apps/admin/mailbox-policy/index.d.ts +3 -0
  30. package/dist/apps/admin/mailboxes/[uid].d.ts +7 -0
  31. package/dist/apps/admin/mailboxes/new/index.d.ts +3 -0
  32. package/dist/apps/admin/plugins/index.d.ts +3 -0
  33. package/dist/apps/admin/quarantine/index.d.ts +6 -0
  34. package/dist/apps/admin/retention-policy/index.d.ts +3 -0
  35. package/dist/apps/admin/setup/index.d.ts +3 -0
  36. package/dist/apps/admin/transport-rules/[uid].d.ts +7 -0
  37. package/dist/apps/admin/transport-rules/_transportRuleConfig.d.ts +21 -0
  38. package/dist/apps/admin/transport-rules/index.d.ts +3 -0
  39. package/dist/apps/admin/transport-rules/new/index.d.ts +3 -0
  40. package/dist/apps/escrow/_layout.d.ts +10 -0
  41. package/dist/apps/escrow/audit-log/index.d.ts +9 -0
  42. package/dist/apps/escrow/index.d.ts +3 -0
  43. package/dist/apps/escrow/matters/[uid].d.ts +7 -0
  44. package/dist/apps/escrow/matters/new/index.d.ts +3 -0
  45. package/dist/apps/shared/components/admin/distributionLists/MemberListCard.d.ts +17 -0
  46. package/dist/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.d.ts +32 -0
  47. package/dist/apps/shared/components/admin/layout/AdminShell.d.ts +32 -0
  48. package/dist/apps/shared/components/admin/layout/AdminShell.js +12 -5
  49. package/dist/apps/shared/components/admin/mailboxes/EscrowScopeCard.d.ts +12 -0
  50. package/dist/apps/shared/components/admin/mailboxes/MailboxTable.d.ts +6 -0
  51. package/dist/apps/shared/components/admin/mailboxes/ResourceSettingsCard.d.ts +19 -0
  52. package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.d.ts +12 -0
  53. package/dist/apps/shared/components/admin/settings/BrandingForm.d.ts +9 -0
  54. package/dist/apps/shared/components/admin/settings/DomainDnsSetup.d.ts +12 -0
  55. package/dist/apps/shared/components/admin/settings/EncryptionPolicyForm.d.ts +12 -0
  56. package/dist/apps/shared/components/admin/settings/LoadedSettingsForm.d.ts +9 -0
  57. package/dist/apps/shared/components/admin/settings/MailboxCreateForm.d.ts +19 -0
  58. package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.d.ts +10 -0
  59. package/dist/apps/shared/components/admin/settings/PluginsManager.d.ts +4 -0
  60. package/dist/apps/shared/components/admin/settings/RetentionPolicyForm.d.ts +9 -0
  61. package/dist/apps/shared/components/admin/setup/EscrowSetupStep.d.ts +14 -0
  62. package/dist/apps/shared/components/admin/setup/SetupWizard.d.ts +36 -0
  63. package/dist/apps/shared/components/admin/signOut.d.ts +23 -0
  64. package/dist/apps/shared/components/admin/usePagedList.d.ts +39 -0
  65. package/dist/apps/shared/components/calendar/CalendarListSidebar.d.ts +26 -0
  66. package/dist/apps/shared/components/calendar/EventModal.d.ts +46 -0
  67. package/dist/apps/shared/components/calendar/MonthView.d.ts +15 -0
  68. package/dist/apps/shared/components/calendar/RecurrenceEditor.d.ts +20 -0
  69. package/dist/apps/shared/components/calendar/ResourcePicker.d.ts +19 -0
  70. package/dist/apps/shared/components/calendar/SplitDayView.d.ts +28 -0
  71. package/dist/apps/shared/components/calendar/TimeGridView.d.ts +17 -0
  72. package/dist/apps/shared/components/calendar/allDay.d.ts +51 -0
  73. package/dist/apps/shared/components/calendar/layout/CalendarShell.d.ts +40 -0
  74. package/dist/apps/shared/components/calendar/layout/CalendarShell.js +2 -2
  75. package/dist/apps/shared/components/contacts/ContactDetailPane.d.ts +23 -0
  76. package/dist/apps/shared/components/contacts/ContactForm.d.ts +20 -0
  77. package/dist/apps/shared/components/contacts/ContactsSidebar.d.ts +40 -0
  78. package/dist/apps/shared/components/contacts/ContactsToolbar.d.ts +25 -0
  79. package/dist/apps/shared/components/contacts/KeyChangeReview.d.ts +40 -0
  80. package/dist/apps/shared/components/contacts/contactKeys.d.ts +29 -0
  81. package/dist/apps/shared/components/contacts/layout/ContactsShell.d.ts +21 -0
  82. package/dist/apps/shared/components/contacts/layout/ContactsShell.js +2 -2
  83. package/dist/apps/shared/components/escrow/layout/EscrowShell.d.ts +25 -0
  84. package/dist/apps/shared/components/forms/StringListField.d.ts +22 -0
  85. package/dist/apps/shared/components/layout/AppShell.d.ts +49 -0
  86. package/dist/apps/shared/components/layout/AppShell.js +15 -13
  87. package/dist/apps/shared/components/layout/BrandingChrome.d.ts +18 -0
  88. package/dist/apps/shared/components/layout/KeyEnrollmentGate.d.ts +51 -0
  89. package/dist/apps/shared/components/layout/MailboxProvisioning.d.ts +13 -0
  90. package/dist/apps/shared/components/layout/RecoveryCodeUnlock.d.ts +66 -0
  91. package/dist/apps/shared/components/layout/UnlockPromptProvider.d.ts +45 -0
  92. package/dist/apps/shared/components/layout/UserMenu.d.ts +23 -0
  93. package/dist/apps/shared/components/mail/ConversationList.d.ts +11 -0
  94. package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +23 -0
  95. package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +93 -0
  96. package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +58 -0
  97. package/dist/apps/shared/components/mail/compose/ComposeToolbar.d.ts +15 -0
  98. package/dist/apps/shared/components/mail/compose/ComposeWindow.d.ts +37 -0
  99. package/dist/apps/shared/components/mail/compose/EmojiPicker.d.ts +14 -0
  100. package/dist/apps/shared/components/mail/compose/GifPicker.d.ts +13 -0
  101. package/dist/apps/shared/components/mail/compose/RichTextEditor.d.ts +34 -0
  102. package/dist/apps/shared/components/mail/compose/ScheduleSendPicker.d.ts +16 -0
  103. package/dist/apps/shared/components/mail/compose/composeFlushRegistry.d.ts +27 -0
  104. package/dist/apps/shared/components/mail/layout/MailShell.d.ts +57 -0
  105. package/dist/apps/shared/components/mail/layout/MailShell.js +2 -2
  106. package/dist/apps/shared/components/mail/pinnedSigners.d.ts +33 -0
  107. package/dist/apps/shared/components/mail/verificationSeals.d.ts +22 -0
  108. package/dist/apps/shared/components/mail/writableMailboxes.d.ts +15 -0
  109. package/dist/apps/shared/components/rules/RuleBuilder.d.ts +70 -0
  110. package/dist/apps/shared/components/settings/layout/SettingsShell.d.ts +41 -0
  111. package/dist/apps/shared/components/settings/layout/SettingsShell.js +19 -9
  112. package/dist/apps/shared/components/tasks/TasksSidebar.d.ts +41 -0
  113. package/dist/apps/shared/components/tasks/TasksToolbar.d.ts +14 -0
  114. package/dist/apps/shared/components/tasks/layout/TasksShell.d.ts +24 -0
  115. package/dist/apps/shared/components/tasks/layout/TasksShell.js +2 -2
  116. package/dist/apps/shared/mail/findWellKnownFolderUid.d.ts +5 -0
  117. package/dist/apps/shared/mail/listAllPages.d.ts +17 -0
  118. package/dist/apps/shared/plugins/pluginNav.d.ts +39 -0
  119. package/dist/apps/shared/plugins/pluginNav.js +33 -0
  120. package/dist/apps/shared/search/LocalIndexLifecycle.d.ts +13 -0
  121. package/dist/apps/shared/search/localIndexBlockCipher.d.ts +36 -0
  122. package/dist/apps/shared/search/localIndexBuilder.d.ts +85 -0
  123. package/dist/apps/shared/search/localIndexKey.d.ts +4 -0
  124. package/dist/apps/shared/search/localIndexRpcClient.d.ts +71 -0
  125. package/dist/apps/shared/search/localIndexRpcClient.js +3 -1
  126. package/dist/apps/shared/search/localIndexSchema.d.ts +111 -0
  127. package/dist/apps/shared/search/localIndexSizePreference.d.ts +27 -0
  128. package/dist/apps/shared/search/localIndexStorage.d.ts +28 -0
  129. package/dist/apps/shared/search/localIndexVFS.d.ts +101 -0
  130. package/dist/apps/shared/search/localIndexWorker.d.ts +145 -0
  131. package/dist/apps/shared/search/searchTier2.d.ts +30 -0
  132. package/dist/apps/www/_404.d.ts +2 -0
  133. package/dist/apps/www/_500.d.ts +2 -0
  134. package/dist/apps/www/_layout.d.ts +14 -0
  135. package/dist/apps/www/calendar/index.d.ts +3 -0
  136. package/dist/apps/www/contacts/[uid].d.ts +13 -0
  137. package/dist/apps/www/contacts/index.d.ts +3 -0
  138. package/dist/apps/www/index.d.ts +3 -0
  139. package/dist/apps/www/messages/[uid].d.ts +11 -0
  140. package/dist/apps/www/settings/auto-reply/index.d.ts +4 -0
  141. package/dist/apps/www/settings/encryption/index.d.ts +7 -0
  142. package/dist/apps/www/settings/filters/[uid].d.ts +8 -0
  143. package/dist/apps/www/settings/filters/_mailFilterRuleConfig.d.ts +11 -0
  144. package/dist/apps/www/settings/filters/index.d.ts +4 -0
  145. package/dist/apps/www/settings/filters/new/index.d.ts +4 -0
  146. package/dist/apps/www/settings/focused-inbox/index.d.ts +4 -0
  147. package/dist/apps/www/settings/labels/index.d.ts +4 -0
  148. package/dist/apps/www/settings/privacy/index.d.ts +4 -0
  149. package/dist/apps/www/settings/read-receipts/index.d.ts +4 -0
  150. package/dist/apps/www/settings/sharing/index.d.ts +4 -0
  151. package/dist/apps/www/settings/signatures/[uid].d.ts +8 -0
  152. package/dist/apps/www/settings/signatures/index.d.ts +4 -0
  153. package/dist/apps/www/settings/signatures/new/index.d.ts +4 -0
  154. package/dist/apps/www/settings/signatures/signatureDefaults.d.ts +10 -0
  155. package/dist/apps/www/tasks/index.d.ts +3 -0
  156. package/package.json +3 -3
  157. package/apps/shared/components/booking/AvailabilityEditor.tsx +0 -118
  158. package/apps/www/settings/booking-types/[uid].tsx +0 -306
  159. package/apps/www/settings/booking-types/index.tsx +0 -98
  160. package/apps/www/settings/booking-types/new/index.tsx +0 -212
  161. package/dist/apps/shared/components/booking/AvailabilityEditor.js +0 -45
  162. package/dist/apps/www/settings/booking-types/[uid].js +0 -134
  163. package/dist/apps/www/settings/booking-types/index.js +0 -29
  164. package/dist/apps/www/settings/booking-types/new/index.js +0 -86
@@ -1,306 +0,0 @@
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
- // Split so a failed save keeps the form (and the user's edits) on screen - only a failed *load* has
49
- // nothing to show but the error.
50
- const [loadError, setLoadError] = useState<string | null>(null);
51
- const [saveError, setSaveError] = useState<string | null>(null);
52
- const [saving, setSaving] = useState(false);
53
- const [saved, setSaved] = useState(false);
54
- const [copied, setCopied] = useState(false);
55
- const [confirmingDelete, setConfirmingDelete] = useState(false);
56
- const [deleting, setDeleting] = useState(false);
57
- const [deleteError, setDeleteError] = useState<string | null>(null);
58
-
59
- useEffect(() => {
60
- setLoading(true);
61
- setLoadError(null);
62
- getBookingType(uid)
63
- .then((bt) => {
64
- setBookingType(bt);
65
- setName(bt.name);
66
- setDescription(bt.description ?? "");
67
- setHostDisplayName(bt.hostDisplayName);
68
- setDurationMinutes(bt.durationMinutes);
69
- setTimezone(bt.timezone);
70
- setAvailability(bt.availability);
71
- setMinimumNoticeMinutes(bt.minimumNoticeMinutes);
72
- setBookingWindowDays(bt.bookingWindowDays);
73
- setRequiresApproval(bt.requiresApproval);
74
- setEnabled(bt.enabled);
75
- })
76
- .catch((err) => setLoadError(err instanceof ApiRequestError ? err.message : "Could not load this booking link."))
77
- .finally(() => setLoading(false));
78
- }, [uid]);
79
-
80
- async function handleSubmit(e: FormEvent) {
81
- e.preventDefault();
82
- setSaveError(null);
83
- setSaved(false);
84
- setSaving(true);
85
- try {
86
- const updated = await updateBookingType({
87
- uid: bookingType!.uid,
88
- version: bookingType!.version,
89
- name,
90
- // `null` (not omitted) clears a saved description - an omitted field is left unchanged by the
91
- // server's partial update. `UpdateBookingTypeInput` doesn't declare `null` yet, hence the cast.
92
- description: description.trim() || (null as unknown as undefined),
93
- hostDisplayName,
94
- durationMinutes,
95
- timezone,
96
- availability,
97
- minimumNoticeMinutes,
98
- bookingWindowDays,
99
- requiresApproval,
100
- enabled,
101
- });
102
- setBookingType(updated);
103
- setSaved(true);
104
- } catch (err) {
105
- setSaveError(err instanceof ApiRequestError ? err.message : "Could not save this booking link.");
106
- } finally {
107
- setSaving(false);
108
- }
109
- }
110
-
111
- async function handleCopy(value: string) {
112
- try {
113
- await navigator.clipboard.writeText(value);
114
- setCopied(true);
115
- setTimeout(() => setCopied(false), 2000);
116
- } catch {
117
- // Clipboard access can be denied by the browser — the value is still selectable/copyable by hand.
118
- }
119
- }
120
-
121
- async function handleDelete() {
122
- setDeleting(true);
123
- setDeleteError(null);
124
- try {
125
- await deleteBookingType(bookingType!.uid, bookingType!.version);
126
- window.location.href = `/settings/booking-types?mailboxUid=${encodeURIComponent(mailboxUid!)}`;
127
- } catch (err) {
128
- setDeleteError(err instanceof ApiRequestError ? err.message : "Could not delete this booking link.");
129
- setDeleting(false);
130
- }
131
- }
132
-
133
- if (loading) {
134
- return <p className="p-6 text-sm text-text-muted">Loading&hellip;</p>;
135
- }
136
- if (loadError || !bookingType) {
137
- // `loadError` is always set whenever `bookingType` is falsy here: the load effect above destructures
138
- // every field off the resolved value directly (`bt.name`, `bt.hostDisplayName`, ...), so a
139
- // successful-but-empty response throws into `.catch()` — which sets `loadError` — before this
140
- // component ever renders past the `loading` guard above. `!bookingType` alone (with `loadError` still
141
- // `null`) is therefore unreachable, unlike e.g. `messages/[uid].tsx`'s identical-looking check,
142
- // which stores its fetched value whole rather than destructuring it.
143
- return (
144
- <div className="p-6">
145
- <Alert>{loadError!}</Alert>
146
- </div>
147
- );
148
- }
149
-
150
- // `bookingType` only ever becomes non-null via the client-only fetch above, so by the time this line
151
- // runs `window` is always defined — the `!bookingType` early return just above covers every real SSR
152
- // pass, where `bookingType` is still `null`.
153
- const publicUrl = `${window.location.origin}/book/${encodeURIComponent(bookingType.slug)}`;
154
-
155
- return (
156
- <div className="flex-1 min-w-0 overflow-y-auto p-6">
157
- <div className="max-w-2xl">
158
- <div className="flex items-start justify-between gap-4 mb-1">
159
- <div>
160
- <a
161
- href={`/settings/booking-types?mailboxUid=${encodeURIComponent(mailboxUid!)}`}
162
- className="text-sm text-primary-dark hover:underline"
163
- >
164
- &larr; All booking links
165
- </a>
166
- <h1 className="text-xl font-bold tracking-tight mt-1">{bookingType.name}</h1>
167
- </div>
168
- <Button
169
- type="button"
170
- variant="secondary"
171
- className="!w-auto shrink-0 !border-danger !text-danger hover:!border-danger hover:!text-danger"
172
- onClick={() => setConfirmingDelete(true)}
173
- >
174
- Delete
175
- </Button>
176
- </div>
177
-
178
- <div className="flex items-center gap-2 mb-5">
179
- <code className="flex-1 text-xs bg-surface-alt border border-border rounded-sm py-2 px-3 overflow-x-auto whitespace-nowrap">
180
- {publicUrl}
181
- </code>
182
- <Button type="button" variant="secondary" className="!w-auto shrink-0" onClick={() => handleCopy(publicUrl)}>
183
- {copied ? "Copied" : "Copy"}
184
- </Button>
185
- </div>
186
-
187
- {saveError && <Alert>{saveError}</Alert>}
188
- {saved && !saveError && <div className="mb-4 text-sm text-success font-medium">Saved.</div>}
189
-
190
- <form onSubmit={handleSubmit} className="flex flex-col gap-1">
191
- <label className="flex items-center gap-2 text-sm mb-3">
192
- <input type="checkbox" checked={enabled} onChange={(e) => setEnabled(e.target.checked)} />
193
- Enabled (publicly bookable)
194
- </label>
195
- <FormField label="Name" htmlFor="name">
196
- <input id="name" type="text" className={INPUT_CLASS} value={name} onChange={(e) => setName(e.target.value)} />
197
- </FormField>
198
- <FormField label="Description (optional)" htmlFor="description">
199
- <textarea
200
- id="description"
201
- className={INPUT_CLASS}
202
- rows={2}
203
- value={description}
204
- onChange={(e) => setDescription(e.target.value)}
205
- />
206
- </FormField>
207
- <FormField label="Host name shown to visitors" htmlFor="hostDisplayName">
208
- <input
209
- id="hostDisplayName"
210
- type="text"
211
- className={INPUT_CLASS}
212
- value={hostDisplayName}
213
- onChange={(e) => setHostDisplayName(e.target.value)}
214
- />
215
- </FormField>
216
- <div className="grid grid-cols-2 gap-3">
217
- <FormField label="Duration (minutes)" htmlFor="durationMinutes">
218
- <input
219
- id="durationMinutes"
220
- type="number"
221
- min={1}
222
- className={INPUT_CLASS}
223
- value={durationMinutes}
224
- onChange={(e) => setDurationMinutes(Number(e.target.value))}
225
- />
226
- </FormField>
227
- <FormField label="Timezone" htmlFor="timezone">
228
- <input
229
- id="timezone"
230
- type="text"
231
- className={INPUT_CLASS}
232
- value={timezone}
233
- onChange={(e) => setTimezone(e.target.value)}
234
- />
235
- </FormField>
236
- </div>
237
- <div className="grid grid-cols-2 gap-3">
238
- <FormField label="Minimum notice (minutes)" htmlFor="minimumNoticeMinutes">
239
- <input
240
- id="minimumNoticeMinutes"
241
- type="number"
242
- min={0}
243
- className={INPUT_CLASS}
244
- value={minimumNoticeMinutes}
245
- onChange={(e) => setMinimumNoticeMinutes(Number(e.target.value))}
246
- />
247
- </FormField>
248
- <FormField label="Booking window (days ahead)" htmlFor="bookingWindowDays">
249
- <input
250
- id="bookingWindowDays"
251
- type="number"
252
- min={1}
253
- className={INPUT_CLASS}
254
- value={bookingWindowDays}
255
- onChange={(e) => setBookingWindowDays(Number(e.target.value))}
256
- />
257
- </FormField>
258
- </div>
259
- <label className="flex items-center gap-2 text-sm my-3">
260
- <input type="checkbox" checked={requiresApproval} onChange={(e) => setRequiresApproval(e.target.checked)} />
261
- Require my approval before confirming a booking
262
- </label>
263
-
264
- <div className="mb-4">
265
- <span className="block text-sm font-semibold mb-1.5 text-text">Weekly availability</span>
266
- <AvailabilityEditor value={availability} onChange={setAvailability} />
267
- </div>
268
-
269
- <div>
270
- <Button type="submit" loading={saving} disabled={saving} className="!w-auto">
271
- Save
272
- </Button>
273
- </div>
274
- </form>
275
-
276
- <Modal open={confirmingDelete} onClose={() => setConfirmingDelete(false)} title="Delete booking link">
277
- <p className="text-sm mb-5">
278
- Are you sure you want to delete <strong>{bookingType.name}</strong>? Its public link will stop
279
- working immediately. This cannot be undone.
280
- </p>
281
- {deleteError && <Alert>{deleteError}</Alert>}
282
- <div className="flex gap-3 justify-end mt-5">
283
- <Button
284
- type="button"
285
- variant="secondary"
286
- className="!w-auto"
287
- disabled={deleting}
288
- onClick={() => setConfirmingDelete(false)}
289
- >
290
- Cancel
291
- </Button>
292
- <Button
293
- type="button"
294
- className="!w-auto !bg-none !bg-danger !border-danger hover:!bg-danger"
295
- loading={deleting}
296
- disabled={deleting}
297
- onClick={handleDelete}
298
- >
299
- Delete
300
- </Button>
301
- </div>
302
- </Modal>
303
- </div>
304
- </div>
305
- );
306
- }
@@ -1,98 +0,0 @@
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
- }
@@ -1,212 +0,0 @@
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
- }