@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,125 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import React, { FormEvent, useState } from "react";
6
+ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
7
+ import { updateMailbox } from "@rapidmx/react-shared/mail/mailApi.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 SettingsReadReceiptsPageProps = Omit<SettingsShellProps, "active">;
13
+
14
+ export default function SettingsReadReceiptsPage(props: SettingsReadReceiptsPageProps) {
15
+ return (
16
+ <SettingsShell {...props} active="read-receipts">
17
+ <ReadReceiptsContent />
18
+ </SettingsShell>
19
+ );
20
+ }
21
+
22
+ function ReadReceiptsContent() {
23
+ const { mailboxUid, mailboxes } = useSettingsShell();
24
+ // `SettingsShell` only ever renders its children once `mailboxes` has loaded and `mailboxUid` has
25
+ // resolved to one of them — same established non-null pattern as `apps/www/settings/auto-reply/index.tsx`.
26
+ const mailbox = mailboxes.find((mb) => mb.uid === mailboxUid)!;
27
+
28
+ const [alwaysRequestReceiptInternal, setAlwaysRequestReceiptInternal] = useState(mailbox.alwaysRequestReceiptInternal ?? true);
29
+ const [alwaysRequestReceiptExternal, setAlwaysRequestReceiptExternal] = useState(mailbox.alwaysRequestReceiptExternal ?? false);
30
+ const [autoSendReceiptsInternal, setAutoSendReceiptsInternal] = useState(mailbox.autoSendReceiptsInternal ?? true);
31
+ const [autoSendReceiptsExternal, setAutoSendReceiptsExternal] = useState(mailbox.autoSendReceiptsExternal ?? false);
32
+ const [error, setError] = useState<string | null>(null);
33
+ const [saving, setSaving] = useState(false);
34
+ const [saved, setSaved] = useState(false);
35
+
36
+ async function handleSubmit(e: FormEvent) {
37
+ e.preventDefault();
38
+ setError(null);
39
+ setSaved(false);
40
+ setSaving(true);
41
+ try {
42
+ await updateMailbox({
43
+ uid: mailbox.uid,
44
+ version: mailbox.version,
45
+ alwaysRequestReceiptInternal,
46
+ alwaysRequestReceiptExternal,
47
+ autoSendReceiptsInternal,
48
+ autoSendReceiptsExternal,
49
+ });
50
+ setSaved(true);
51
+ } catch (err) {
52
+ setError(err instanceof ApiRequestError ? err.message : "Could not save read receipt settings.");
53
+ } finally {
54
+ setSaving(false);
55
+ }
56
+ }
57
+
58
+ return (
59
+ <div className="flex-1 min-w-0 overflow-y-auto p-6">
60
+ <div className="max-w-xl">
61
+ <h1 className="text-lg font-bold tracking-tight mb-1">Read Receipts</h1>
62
+ <p className="text-sm text-text-muted mb-4">
63
+ Controls when this mailbox requests a delivery/read receipt on mail it sends, and how it
64
+ responds to a receipt requested of it. A per-message &ldquo;Request a read receipt&rdquo;
65
+ checkbox in Compose always overrides the request-side settings below for that one message.
66
+ </p>
67
+
68
+ {error && <Alert>{error}</Alert>}
69
+ {saved && !error && <div className="mb-4 text-sm text-success font-medium">Saved.</div>}
70
+
71
+ <form onSubmit={handleSubmit} className="flex flex-col gap-5">
72
+ <fieldset className="flex flex-col gap-2">
73
+ <legend className="text-sm font-semibold mb-1">Request receipts when sending</legend>
74
+ <label className="flex items-center gap-2 text-sm">
75
+ <input
76
+ type="checkbox"
77
+ checked={alwaysRequestReceiptInternal}
78
+ onChange={(e) => setAlwaysRequestReceiptInternal(e.target.checked)}
79
+ />
80
+ From internal recipients (mail to this organization)
81
+ </label>
82
+ <label className="flex items-center gap-2 text-sm">
83
+ <input
84
+ type="checkbox"
85
+ checked={alwaysRequestReceiptExternal}
86
+ onChange={(e) => setAlwaysRequestReceiptExternal(e.target.checked)}
87
+ />
88
+ From external recipients
89
+ </label>
90
+ </fieldset>
91
+
92
+ <fieldset className="flex flex-col gap-2">
93
+ <legend className="text-sm font-semibold mb-1">Respond automatically to requests</legend>
94
+ <label className="flex items-center gap-2 text-sm">
95
+ <input
96
+ type="checkbox"
97
+ checked={autoSendReceiptsInternal}
98
+ onChange={(e) => setAutoSendReceiptsInternal(e.target.checked)}
99
+ />
100
+ From internal senders
101
+ </label>
102
+ <label className="flex items-center gap-2 text-sm">
103
+ <input
104
+ type="checkbox"
105
+ checked={autoSendReceiptsExternal}
106
+ onChange={(e) => setAutoSendReceiptsExternal(e.target.checked)}
107
+ />
108
+ From external senders
109
+ </label>
110
+ <p className="text-xs text-text-muted">
111
+ Unchecked means a request from that sender waits in your Inbox for you to send or
112
+ decline it explicitly.
113
+ </p>
114
+ </fieldset>
115
+
116
+ <div>
117
+ <Button type="submit" loading={saving} disabled={saving} className="!w-auto">
118
+ Save
119
+ </Button>
120
+ </div>
121
+ </form>
122
+ </div>
123
+ </div>
124
+ );
125
+ }
@@ -0,0 +1,167 @@
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 { MailSignature, getMailSignature, listMailSignatures, updateMailSignature } from "@rapidmx/react-shared/mail/mailSignaturesApi.js";
8
+ import { clearPreviousDefaults } from "./signatureDefaults.js";
9
+ import SettingsShell, { SettingsShellProps, useSettingsShell } from "../../../shared/components/settings/layout/SettingsShell.js";
10
+ import RichTextEditor from "../../../shared/components/mail/compose/RichTextEditor.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
+ /** Signatures aren't backed by a draft/attachment record the way Compose's own inline images are — see
19
+ * `settings/signatures/new/index.tsx`'s identical stub for the full reasoning. */
20
+ async function handleUploadImage(): Promise<string | null> {
21
+ return null;
22
+ }
23
+
24
+ export type SignatureDetailPageProps = Omit<SettingsShellProps, "active"> & { params: { uid: string } };
25
+
26
+ export default function SignatureDetailPage(props: SignatureDetailPageProps) {
27
+ return (
28
+ <SettingsShell {...props} active="signatures">
29
+ <SignatureDetailContent uid={props.params.uid} />
30
+ </SettingsShell>
31
+ );
32
+ }
33
+
34
+ function SignatureDetailContent({ uid }: { uid: string }) {
35
+ const { mailboxUid } = useSettingsShell();
36
+ const [original, setOriginal] = useState<MailSignature | null>(null);
37
+ const [name, setName] = useState("");
38
+ const [contentHtml, setContentHtml] = useState("");
39
+ const [isDefaultForNewMessages, setIsDefaultForNewMessages] = useState(false);
40
+ const [isDefaultForReplyForward, setIsDefaultForReplyForward] = useState(false);
41
+ const [loading, setLoading] = useState(true);
42
+ const [error, setError] = useState<string | null>(null);
43
+ const [saving, setSaving] = useState(false);
44
+ const [saved, setSaved] = useState(false);
45
+
46
+ useEffect(() => {
47
+ setLoading(true);
48
+ setError(null);
49
+ getMailSignature(uid)
50
+ .then((loaded) => {
51
+ setOriginal(loaded);
52
+ if (loaded) {
53
+ setName(loaded.name);
54
+ setContentHtml(loaded.contentHtml);
55
+ setIsDefaultForNewMessages(loaded.isDefaultForNewMessages);
56
+ setIsDefaultForReplyForward(loaded.isDefaultForReplyForward);
57
+ }
58
+ })
59
+ .catch((err) => setError(err instanceof ApiRequestError ? err.message : "Could not load this signature."))
60
+ .finally(() => setLoading(false));
61
+ }, [uid]);
62
+
63
+ // Only ever invoked from the form below, which itself only renders once `original` is loaded (the
64
+ // early returns above cover every other state) — the non-null assertions reflect that real
65
+ // invariant, matching `MailFilterDetailContent.handleSubmit`'s identical pattern.
66
+ async function handleSubmit(e: FormEvent) {
67
+ e.preventDefault();
68
+ setError(null);
69
+
70
+ if (!name.trim()) {
71
+ setError("A name is required.");
72
+ return;
73
+ }
74
+
75
+ setSaving(true);
76
+ setSaved(false);
77
+ try {
78
+ if (isDefaultForNewMessages || isDefaultForReplyForward) {
79
+ const existing = await listMailSignatures(mailboxUid!, { limit: 100 });
80
+ await clearPreviousDefaults(existing, original!.uid, isDefaultForNewMessages, isDefaultForReplyForward);
81
+ }
82
+ const updated = await updateMailSignature({
83
+ uid: original!.uid,
84
+ version: original!.version,
85
+ name: name.trim(),
86
+ contentHtml,
87
+ isDefaultForNewMessages,
88
+ isDefaultForReplyForward,
89
+ });
90
+ setOriginal(updated);
91
+ setSaved(true);
92
+ } catch (err) {
93
+ setError(err instanceof ApiRequestError ? err.message : "Could not save this signature.");
94
+ } finally {
95
+ setSaving(false);
96
+ }
97
+ }
98
+
99
+ if (loading) {
100
+ return <p className="p-6 text-sm text-text-muted">Loading&hellip;</p>;
101
+ }
102
+ if (error && !original) {
103
+ return (
104
+ <div className="p-6">
105
+ <Alert>{error}</Alert>
106
+ </div>
107
+ );
108
+ }
109
+ if (!original) {
110
+ return (
111
+ <div className="p-6">
112
+ <Alert>Signature not found.</Alert>
113
+ </div>
114
+ );
115
+ }
116
+
117
+ return (
118
+ <div className="flex-1 min-w-0 overflow-y-auto p-6">
119
+ <div className="max-w-3xl">
120
+ <a
121
+ href={`/settings/signatures?mailboxUid=${encodeURIComponent(mailboxUid!)}`}
122
+ className="text-sm text-primary-dark hover:underline"
123
+ >
124
+ &larr; All signatures
125
+ </a>
126
+ <h1 className="text-lg font-bold tracking-tight mt-1 mb-5">{original.name}</h1>
127
+
128
+ {error && <Alert>{error}</Alert>}
129
+ {saved && !error && <div className="mb-4 text-sm text-success font-medium">Saved.</div>}
130
+
131
+ <form onSubmit={handleSubmit} className="flex flex-col gap-5">
132
+ <div className="bg-surface border border-border rounded-md p-6 flex flex-col gap-4">
133
+ <FormField label="Name" htmlFor="name">
134
+ <input id="name" type="text" className={INPUT_CLASS} value={name} onChange={(e) => setName(e.target.value)} />
135
+ </FormField>
136
+ <label className="flex items-center gap-2 text-sm">
137
+ <input
138
+ type="checkbox"
139
+ checked={isDefaultForNewMessages}
140
+ onChange={(e) => setIsDefaultForNewMessages(e.target.checked)}
141
+ />
142
+ Use for new messages
143
+ </label>
144
+ <label className="flex items-center gap-2 text-sm">
145
+ <input
146
+ type="checkbox"
147
+ checked={isDefaultForReplyForward}
148
+ onChange={(e) => setIsDefaultForReplyForward(e.target.checked)}
149
+ />
150
+ Use for replies and forwards
151
+ </label>
152
+ </div>
153
+
154
+ <div className="h-64">
155
+ <RichTextEditor value={contentHtml} onChange={setContentHtml} fill onUploadImage={handleUploadImage} />
156
+ </div>
157
+
158
+ <div>
159
+ <Button type="submit" loading={saving} disabled={saving} className="!w-auto">
160
+ Save changes
161
+ </Button>
162
+ </div>
163
+ </form>
164
+ </div>
165
+ </div>
166
+ );
167
+ }
@@ -0,0 +1,85 @@
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 { MailSignature, listMailSignatures } from "@rapidmx/react-shared/mail/mailSignaturesApi.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 SettingsSignaturesPageProps = Omit<SettingsShellProps, "active">;
13
+
14
+ export default function SettingsSignaturesPage(props: SettingsSignaturesPageProps) {
15
+ return (
16
+ <SettingsShell {...props} active="signatures">
17
+ <SignaturesContent />
18
+ </SettingsShell>
19
+ );
20
+ }
21
+
22
+ function SignaturesContent() {
23
+ const { mailboxUid } = useSettingsShell();
24
+ const [signatures, setSignatures] = useState<MailSignature[]>([]);
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/auto-reply/index.tsx`.
30
+ useEffect(() => {
31
+ listMailSignatures(mailboxUid!)
32
+ .then(setSignatures)
33
+ .catch((err) => setError(err instanceof ApiRequestError ? err.message : "Could not load signatures."))
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">Signatures</h1>
42
+ <a href={`/settings/signatures/new?mailboxUid=${encodeURIComponent(mailboxUid!)}`}>
43
+ <Button type="button" className="!w-auto">
44
+ + New signature
45
+ </Button>
46
+ </a>
47
+ </div>
48
+
49
+ {error && <Alert>{error}</Alert>}
50
+
51
+ {loading ? (
52
+ <p className="text-sm text-text-muted">Loading&hellip;</p>
53
+ ) : signatures.length === 0 ? (
54
+ <p className="text-sm text-text-muted">No signatures yet.</p>
55
+ ) : (
56
+ <ul className="flex flex-col gap-2">
57
+ {signatures.map((sig) => (
58
+ <li key={sig.uid} className="flex items-center justify-between border border-border rounded-md p-3">
59
+ <div>
60
+ <div className="text-sm font-semibold">{sig.name}</div>
61
+ {(sig.isDefaultForNewMessages || sig.isDefaultForReplyForward) && (
62
+ <div className="text-xs text-text-muted mt-0.5">
63
+ {[
64
+ sig.isDefaultForNewMessages && "Default for new messages",
65
+ sig.isDefaultForReplyForward && "Default for replies/forwards",
66
+ ]
67
+ .filter(Boolean)
68
+ .join(" · ")}
69
+ </div>
70
+ )}
71
+ </div>
72
+ <a
73
+ href={`/settings/signatures/${encodeURIComponent(sig.uid)}?mailboxUid=${encodeURIComponent(mailboxUid!)}`}
74
+ className="text-primary-dark hover:underline font-medium text-sm"
75
+ >
76
+ Edit
77
+ </a>
78
+ </li>
79
+ ))}
80
+ </ul>
81
+ )}
82
+ </div>
83
+ </div>
84
+ );
85
+ }
@@ -0,0 +1,129 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import React, { FormEvent, useState } from "react";
6
+ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
7
+ import { createMailSignature, listMailSignatures } from "@rapidmx/react-shared/mail/mailSignaturesApi.js";
8
+ import { clearPreviousDefaults } from "../signatureDefaults.js";
9
+ import SettingsShell, { SettingsShellProps, useSettingsShell } from "../../../../shared/components/settings/layout/SettingsShell.js";
10
+ import RichTextEditor from "../../../../shared/components/mail/compose/RichTextEditor.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 NewSignaturePageProps = Omit<SettingsShellProps, "active">;
19
+
20
+ export default function NewSignaturePage(props: NewSignaturePageProps) {
21
+ return (
22
+ <SettingsShell {...props} active="signatures">
23
+ <NewSignatureForm />
24
+ </SettingsShell>
25
+ );
26
+ }
27
+
28
+ /** Signatures aren't backed by a draft/attachment record the way Compose's own inline images are (see
29
+ * `ComposeWindow.handleUploadImage()`) — inline images in a signature are out of scope for this phase
30
+ * (`.claude/NOTES.md`'s Phase 12 entry), so this is a real, deliberate no-op, not a stub left unfinished. */
31
+ async function handleUploadImage(): Promise<string | null> {
32
+ return null;
33
+ }
34
+
35
+ function NewSignatureForm() {
36
+ const { mailboxUid } = useSettingsShell();
37
+ const [name, setName] = useState("");
38
+ const [contentHtml, setContentHtml] = useState("");
39
+ const [isDefaultForNewMessages, setIsDefaultForNewMessages] = useState(false);
40
+ const [isDefaultForReplyForward, setIsDefaultForReplyForward] = useState(false);
41
+ const [error, setError] = useState<string | null>(null);
42
+ const [saving, setSaving] = useState(false);
43
+
44
+ async function handleSubmit(e: FormEvent) {
45
+ e.preventDefault();
46
+ setError(null);
47
+
48
+ if (!name.trim()) {
49
+ setError("A name is required.");
50
+ return;
51
+ }
52
+
53
+ setSaving(true);
54
+ try {
55
+ if (isDefaultForNewMessages || isDefaultForReplyForward) {
56
+ const existing = await listMailSignatures(mailboxUid!, { limit: 100 });
57
+ await clearPreviousDefaults(existing, undefined, isDefaultForNewMessages, isDefaultForReplyForward);
58
+ }
59
+ const created = await createMailSignature({
60
+ mailboxUid: mailboxUid!,
61
+ name: name.trim(),
62
+ contentHtml,
63
+ isDefaultForNewMessages,
64
+ isDefaultForReplyForward,
65
+ });
66
+ window.location.href = `/settings/signatures/${encodeURIComponent(created.uid)}?mailboxUid=${encodeURIComponent(mailboxUid!)}`;
67
+ } catch (err) {
68
+ setError(err instanceof ApiRequestError ? err.message : "Could not create the signature.");
69
+ } finally {
70
+ setSaving(false);
71
+ }
72
+ }
73
+
74
+ return (
75
+ <div className="flex-1 min-w-0 overflow-y-auto p-6">
76
+ <div className="max-w-3xl">
77
+ <h1 className="text-lg font-bold tracking-tight mb-5">New signature</h1>
78
+
79
+ {error && <Alert>{error}</Alert>}
80
+
81
+ <form onSubmit={handleSubmit} className="flex flex-col gap-5">
82
+ <div className="bg-surface border border-border rounded-md p-6 flex flex-col gap-4">
83
+ <FormField label="Name" htmlFor="name">
84
+ <input
85
+ id="name"
86
+ type="text"
87
+ className={INPUT_CLASS}
88
+ value={name}
89
+ onChange={(e) => setName(e.target.value)}
90
+ placeholder="Work signature"
91
+ />
92
+ </FormField>
93
+ <label className="flex items-center gap-2 text-sm">
94
+ <input
95
+ type="checkbox"
96
+ checked={isDefaultForNewMessages}
97
+ onChange={(e) => setIsDefaultForNewMessages(e.target.checked)}
98
+ />
99
+ Use for new messages
100
+ </label>
101
+ <label className="flex items-center gap-2 text-sm">
102
+ <input
103
+ type="checkbox"
104
+ checked={isDefaultForReplyForward}
105
+ onChange={(e) => setIsDefaultForReplyForward(e.target.checked)}
106
+ />
107
+ Use for replies and forwards
108
+ </label>
109
+ </div>
110
+
111
+ <div className="h-64">
112
+ <RichTextEditor value={contentHtml} onChange={setContentHtml} fill onUploadImage={handleUploadImage} />
113
+ </div>
114
+
115
+ <div className="flex gap-3">
116
+ <Button type="submit" loading={saving} disabled={saving} className="!w-auto">
117
+ Create signature
118
+ </Button>
119
+ <a href={`/settings/signatures?mailboxUid=${encodeURIComponent(mailboxUid!)}`}>
120
+ <Button type="button" variant="secondary" className="!w-auto">
121
+ Cancel
122
+ </Button>
123
+ </a>
124
+ </div>
125
+ </form>
126
+ </div>
127
+ </div>
128
+ );
129
+ }
@@ -0,0 +1,36 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import { MailSignature, updateMailSignature } from "@rapidmx/react-shared/mail/mailSignaturesApi.js";
6
+
7
+ /**
8
+ * `MailSignature.isDefaultForNewMessages`/`isDefaultForReplyForward` are each meant to hold on at most
9
+ * one signature per mailbox — enforced by convention, not a database constraint (see
10
+ * `mailSignaturesApi.ts`'s own doc comment, quoting restapi's). Before saving a signature with one of
11
+ * these flags newly turned on, this turns the flag off on whichever *other* signature in `signatures`
12
+ * currently has it — the "the composing client toggles the previous default off" responsibility that
13
+ * convention assigns to a caller like the New/Edit signature forms.
14
+ */
15
+ export async function clearPreviousDefaults(
16
+ signatures: MailSignature[],
17
+ savingUid: string | undefined,
18
+ isDefaultForNewMessages: boolean,
19
+ isDefaultForReplyForward: boolean,
20
+ ): Promise<void> {
21
+ for (const signature of signatures) {
22
+ if (signature.uid === savingUid) {
23
+ continue;
24
+ }
25
+ const patch: { isDefaultForNewMessages?: boolean; isDefaultForReplyForward?: boolean } = {};
26
+ if (isDefaultForNewMessages && signature.isDefaultForNewMessages) {
27
+ patch.isDefaultForNewMessages = false;
28
+ }
29
+ if (isDefaultForReplyForward && signature.isDefaultForReplyForward) {
30
+ patch.isDefaultForReplyForward = false;
31
+ }
32
+ if (Object.keys(patch).length > 0) {
33
+ await updateMailSignature({ uid: signature.uid, version: signature.version, ...patch });
34
+ }
35
+ }
36
+ }