diff --git a/README.md b/README.md
index b08a57f..f50f029 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
You should have received a copy of the GNU General Public License along with this program. If not, see .
-**This is not ready for a public launch, and it is not ready for real volunteer records.** Phase 1A has public browsing, individual signup, cancellation, queued email, and coordinator sign-in for events, one-off shifts, rosters, and cancellation. A coordinator can add a walk-in and move a signup from a shift roster. A volunteer can switch shifts from their private link. An active weekly template fills shifts for the next three months. A coordinator can add, change, or end a weekly template, and can remove a cancelled person, a finished empty shift, an ended template, or an event that is off the public list and already empty. A confirmed signup can receive a reminder 48 hours before the shift and again 2 hours before, and can turn reminders off without cancelling. A coordinator can download a roster for one shift, one event, or a local date range. A coordinator can import a contact list, download it, open a person to see current and past shifts, use a saved contact when adding a walk-in, and add a saved contact to an open shift. A coordinator can set the two reminder times, the reply-to address, how many months to keep a signup, and the wording on the privacy page. A signed-in administrator can add another administrator. Removing someone takes away their sign-in access. The last administrator cannot be removed. After 1:00 AM Central Time, signups older than that many months lose their name and contact details in this app. After 2:30 AM Central Time, the app saves a database backup on this computer. A container can run that same app on this computer, on port 3020, without opening it to the network. This is not a public launch. Around 1:00 AM in each event's time zone, the app adds any missing weekly shifts for the next eight weeks, once that local day. Development prints mail in the server log. It does not send real email.
+**This is not ready for a public launch, and it is not ready for real volunteer records.** Phase 1A has public browsing, individual signup, cancellation, queued email, and coordinator sign-in for events, one-off shifts, rosters, and cancellation. A coordinator can add a walk-in and move a signup from a shift roster. A volunteer can switch shifts from their private link. An active weekly template fills shifts for the next three months. A coordinator can add, change, or end a weekly template, and can remove a cancelled person, a finished empty shift, an ended template, or an event that is off the public list and already empty. A confirmed signup can receive a reminder 48 hours before the shift and again 2 hours before, and can turn reminders off without cancelling. A coordinator can download a roster for one shift, one event, or a local date range. A coordinator can import a contact list, download it, open a person to see current and past shifts, use a saved contact when adding a walk-in, and add a saved contact to an open shift. A coordinator can set when reminder emails go out, where replies go, and how long signup details stay in the app. A signed-in administrator can add another administrator. Removing someone takes away their sign-in access. The last administrator cannot be removed. After 1:00 AM Central Time, signups older than that many months lose their name and contact details in this app. After 2:30 AM Central Time, the app saves a database backup on this computer. A container can run that same app on this computer, on port 3020, without opening it to the network. This is not a public launch. Around 1:00 AM in each event's time zone, the app adds any missing weekly shifts for the next eight weeks, once that local day. Development prints mail in the server log. It does not send real email.
## Current step
@@ -32,7 +32,7 @@ You should have received a copy of the GNU General Public License along with thi
| Reminder emails, 48 hours and 2 hours, with a way to stop them | Done |
| Download a roster for a shift, an event, or a date range | Done |
| Import and download a contact list | Done |
-| Set reminder times, reply-to, privacy wording, and retention months | Done |
+| Set reminder times, where replies go, and how long signup details are kept | Done |
| Refill weekly shifts around 1:00 AM in each event time zone | Done |
| Remove personal details after the saved retention period | Done |
| Save a database backup after 2:30 AM Central Time | Done |
@@ -42,11 +42,11 @@ The core tables for later steps are already in `migrations/001_init.sql`. Behavi
## Decisions still open
-Do not treat this repository as an approved privacy policy or an approved operating setup.
+Do not treat this repository as an approved operating setup.
- [ ] **D1.** SMTP2GO is the email provider. The pantry verifies the sender and the reply-to.
- [ ] **D2.** Whether a group signup is essential. A shared email can already sign up more than one person on the same shift. Each person takes one spot and gets their own confirmation and private link. The same person, matched by name and email, cannot take a second spot on that shift. `group_size` stays 1. Group signup still needs its own decision: who the reservation is for, what happens when the count changes, and who receives mail.
-- [ ] **D3.** The pantry approves privacy wording and retention periods, including copies and exports.
+- [ ] **D3.** The pantry approves how long signup details are kept, including copies and exports.
- [ ] **D4.** The pantry confirms the coordinator list, who owns the administrator account, and the recovery contact.
- [ ] **D5.** Configure production Turnstile keys and the allowed hostname.
- [ ] **D6.** The host owner confirms the offsite backup destination, who owns it, the recovery target, and a restore test.
@@ -70,7 +70,7 @@ npm run seed
`npm run dev` serves the site on `127.0.0.1` at `BASE_URL` (from `.env`, `http://127.0.0.1:3000`). It is loopback only. Stop it with Ctrl+C.
-Open `/` for the weekly pantry sign-up page. **View** starts on **List**: a card for each day with a shift in the next three months, split into that day's shifts. Each shift lists the names of the people who are signed up. A shift that has already ended stays on that day's card, grayed out, until midnight in the event's time zone. At midnight the day leaves the list. Emails, phone numbers, and notes stay off the page. **Calendar** is the other choice in that menu, at `/?view=calendar`, and it stops at that same three-month date. A shift later than that date is left off both views, and the signup form does not take a reservation for it. `/e/weekly-pantry` is the same seeded event. `/privacy` is the unapproved privacy notice. `/healthz` returns `{"ok":true,"database":"ok"}` and nothing else. A shift shows how many spots are filled, such as 3/5 spots filled. A shift with space left uses a soft green label. A full shift uses a soft red label.
+Open `/` for the weekly pantry sign-up page. **View** starts on **List**: a card for each day with a shift in the next three months, split into that day's shifts. Each shift lists the names of the people who are signed up. A shift that has already ended stays on that day's card, grayed out, until midnight in the event's time zone. At midnight the day leaves the list. Emails, phone numbers, and notes stay off the page. **Calendar** is the other choice in that menu, at `/?view=calendar`, and it stops at that same three-month date. A shift later than that date is left off both views, and the signup form does not take a reservation for it. `/e/weekly-pantry` is the same seeded event. `/healthz` returns `{"ok":true,"database":"ok"}` and nothing else. A shift shows how many spots are filled, such as 3/5 spots filled. A shift with space left uses a soft green label. A full shift uses a soft red label.
An open shift has a signup form. It asks for one person. Another person can use the same email and takes another spot. The same person cannot take a second spot. The form needs JavaScript because of the Turnstile check. Wait a few seconds after the page loads before submitting. The confirmation page shows a private link and says a confirmation email is on the way. That page works without JavaScript. Cancel this signup there to open the spot again. A cancellation email is queued, and a confirmation that has not been sent yet is dropped. That person can sign up again once the cancellation is saved. Someone else can use the email while the first signup is still confirmed. A cancelled signup stays on that private page until the link expires. A private link controls only that signup. Use the separate link for each signup.
@@ -104,7 +104,7 @@ A reminder is queued at each saved time before a confirmed signup, while the shi
**Contacts**, on the coordinator page, keeps a list of people. A confirmed signup is saved on this list. The name is split at the last space. A signup name with no space is saved with a hyphen as the last name. A different name is a separate contact, even when the email matches. The same name and email updates that contact. Cancelling the signup does not remove the contact. Saving someone here does not sign them up for a shift. The list is at the top of this page. **Add a contact**, **Import**, and **Download** stay closed until one is opened. **Import** reads a spreadsheet with First Name, Last Name, Email, and Phone, including the SignUpGenius people export. An Address column is ignored. The same name and email updates that person. A different name stays a separate person, even when the email matches. A different email stays a separate person, even when the name matches. A row without a phone is skipped. Names are capitalized. A word that already mixes upper and lower case stays as written. A phone number with ten digits is saved with dashes, like 712-555-0100. A leading 1 is left off. Email addresses are stored in lowercase. Importing does not take a spot and does not send email. **Download** saves that list. A cell that would be a spreadsheet formula is saved as text. A downloaded copy stays on the coordinator's computer. The signup retention job does not clear this list. The list is the contacts table in `app.db`. The list shows 20 people. **See more** shows the next 20 on this page, without returning to the top, and keeps a search. **Choose a name** to see the shifts they are signed up for and every past shift they signed up for. The signup has to use the same name and email. A signup name with no space matches the contact saved with a hyphen for the last name. A confirmed signup on a shift that has not ended is listed under Signed up for. A shift that has ended is listed under Past shifts, including a cancelled signup, which is marked cancelled. Choosing the shift opens it. Signup details cleared by retention drop off this page. **Edit contact** and **Add to a shift** stay closed until opened. **Add to a shift** uses their saved name, email, and phone. That takes one spot and queues a confirmation email. A full, cancelled, or ended shift is not in that list, and a shift they are already on is not in that list. A shift that is not on the public list can still be chosen. **Edit contact**, on that page, saves a corrected name, email, or phone on the same person. A phone typo can be replaced. A hyphen saved as the last name can be replaced with the real last name. Changing the name does not create a second person, even when the email stays the same. Phone is required. It does not change a signup, take a spot, or send email. **Remove** deletes that person from the list only. On an open shift, **Saved contact** fills a walk-in. The walk-in still takes one spot and queues a confirmation email. **Add a contact** saves one person who has not signed up. It does not take a spot and does not send email. The same name and email updates that person. A different name is saved separately, even with the same email. Typing a walk-in who is not on the list saves them here too.
-**Settings**, on the coordinator page, saves the two reminder times, the reply-to address, the privacy-page wording, and how many months to keep a signup after the shift ends. The defaults are 48 hours, 2 hours, the reply-to address from the server configuration, a blank privacy notice, and 24 months. The two reminder times have to be different whole hours from 1 to 336. The month count is a whole number from 1 to 120. A blank privacy notice leaves the public page saying a notice is not approved yet. Saved wording is shown on `/privacy` as written. Saving it does not by itself make that wording an approved privacy policy. New mail uses the saved reply-to address. Mail already queued keeps the address it was given. The sending address stays in the server configuration.
+**Settings**, on the coordinator page, is three choices: when the two reminder emails go out, which inbox receives replies, and how long a signup keeps a person's name, email, and phone. The usual reminders are 2 days before the shift, then 2 hours before. The lists also offer 1 week, 3 days, and 1 day for the first email, and 1 day, 12 hours, 4 hours, and 1 hour for the second. The two times have to be different. A time already saved that is not on the list still appears, when it is a whole number of hours from 1 to 336. The usual keep time is 2 years. The list also offers 6 months, 1 year, 3 years, 5 years, and 10 years. A count already saved that is not on the list still appears, from 1 to 120 months. The reply address starts as the one in the server configuration. New mail uses the saved reply address. Mail already queued keeps the address it was given. The sending address stays in the server configuration. There is no privacy page.
**Administrators**, on the coordinator page, lists who can sign in. **Add an administrator** saves a name and email. It does not send email. That person requests a sign-in link at `/login`. Saving an address that was removed earlier gives that person access again and updates the name. **Remove** takes away access, signs that person out, and stops unused sign-in links. It does not send email. A roster notice that has not been sent yet is not sent to that address. The last administrator cannot be removed. Any administrator can add or remove the others, including themselves when someone else still has access.
@@ -279,4 +279,4 @@ The command prints the coordinator id, not the address. It does not deactivate a
## What is still unverified
-Real inbox delivery, a production host, and a public launch. The container was checked on this computer with a temporary database, separate from the development database: it starts, the weekly page loads, `/healthz` answers, a path prefix is included in that health address, and a restart keeps the database. The development settings were refused. This computer does not have the Docker daemon running, so that check used Podman. It has not been deployed. Decision D6 is still open. The console driver only prints mail. SMTP2GO is the selected provider and is not connected on this computer yet. Gmail is not connected. The privacy page is waiting on decision D3 and is not a privacy policy. A real Turnstile hostname check still needs the production keys from decision D5. Development uses Cloudflare's always-pass test keys. Those keys succeed with hostname `example.com` and no action, so the hostname and action checks apply to real keys. Coordinator sign-in is covered here with the console driver, not with a real inbox.
+Real inbox delivery, a production host, and a public launch. The container was checked on this computer with a temporary database, separate from the development database: it starts, the weekly page loads, `/healthz` answers, a path prefix is included in that health address, and a restart keeps the database. The development settings were refused. This computer does not have the Docker daemon running, so that check used Podman. It has not been deployed. Decision D6 is still open. The console driver only prints mail. SMTP2GO is the selected provider and is not connected on this computer yet. Gmail is not connected. A real Turnstile hostname check still needs the production keys from decision D5. Development uses Cloudflare's always-pass test keys. Those keys succeed with hostname `example.com` and no action, so the hostname and action checks apply to real keys. Coordinator sign-in is covered here with the console driver, not with a real inbox.
diff --git a/public/css/app.css b/public/css/app.css
index d0a8b1f..975a7fb 100644
--- a/public/css/app.css
+++ b/public/css/app.css
@@ -1661,6 +1661,101 @@ article.shift-card {
color: var(--hope-ink-2);
}
+.settings-intro {
+ max-width: 40rem;
+ margin-bottom: 0.35rem;
+}
+
+.settings-intro h1 {
+ margin-bottom: 0.35rem;
+}
+
+.settings-intro p {
+ margin: 0;
+ color: var(--hope-ink-2);
+}
+
+.settings-form {
+ display: grid;
+ gap: 1rem;
+ max-width: 46rem;
+ margin-top: 1.15rem;
+}
+
+.settings-card {
+ display: grid;
+ gap: 1rem;
+ margin: 0;
+ padding: 1.25rem 1.35rem 1.35rem;
+ background: #fff;
+ border: 1px solid #e6eef3;
+ border-radius: 1.35rem;
+ box-shadow: 0 8px 24px rgb(34 55 70 / 0.05);
+}
+
+.settings-card h2 {
+ margin: 0;
+ font-size: 1.45rem;
+ font-weight: 650;
+}
+
+.settings-card-copy p,
+.settings-form .hint {
+ margin: 0.35rem 0 0;
+ font-weight: 400;
+ color: var(--hope-ink-2);
+}
+
+.settings-form label {
+ display: grid;
+ gap: 0.35rem;
+ margin: 0;
+ font-weight: 650;
+}
+
+.settings-fields {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 0.95rem;
+ align-items: start;
+}
+
+.settings-form select,
+.settings-form input[type="email"] {
+ width: 100%;
+ min-height: 48px;
+ padding: 0.7rem 1rem;
+ background: var(--hope-blue-50);
+ border: 0;
+ border-radius: 999px;
+ box-shadow: var(--hope-shadow);
+ font: inherit;
+ color: var(--hope-ink);
+}
+
+.settings-preview {
+ margin: 0;
+ padding: 0.85rem 1.05rem;
+ background: var(--hope-blue-wash);
+ border-radius: 1rem;
+ color: var(--hope-ink);
+ font-weight: 650;
+}
+
+.settings-save {
+ display: flex;
+}
+
+@media (max-width: 42em) {
+ .settings-fields {
+ grid-template-columns: 1fr;
+ }
+
+ .settings-form button {
+ width: 100%;
+ }
+}
+
.error,
.field-error {
font-weight: 650;
@@ -2312,10 +2407,20 @@ button.btn-quiet::before {
}
.event-page .shift-card {
- background: var(--hope-blue-50);
+ background: #f3f7fb;
box-shadow: var(--hope-shadow-soft);
}
+.event-page .desk-events {
+ background: #fff;
+ border: 1px solid #e6eef3;
+ box-shadow: 0 8px 24px rgb(34 55 70 / 0.05);
+}
+
+.event-page .desk-events .empty {
+ background: #f3f7fb;
+}
+
.pick-bar {
align-items: center;
justify-content: flex-end;
@@ -2723,22 +2828,49 @@ button.btn-quiet::before {
display: grid;
grid-template-columns: auto minmax(0, 1fr);
align-items: center;
- gap: 0.35rem;
+ gap: 0.55rem;
+ padding-left: 0.55rem;
+ background: #f3f7fb;
+ border-radius: 0.95rem;
+ color: var(--hope-ink);
+}
+
+.event-page .need-pick:hover,
+.event-page .need-pick:has(.desk-row:focus-visible) {
+ background: #e8f1f7;
+}
+
+.event-page .need-pick:has(.desk-row:focus-visible) {
+ outline: 3px solid var(--hope-ink);
+ outline-offset: 3px;
+}
+
+.event-page .need-pick .pick {
+ min-height: 0;
}
.event-page .need-pick .desk-row {
min-width: 0;
+ padding: 0.48rem 0.75rem 0.48rem 0;
+ background: transparent;
+ border-radius: 0;
}
-.event-page .desk-row.is-ended {
+.event-page .need-pick .desk-row:hover,
+.event-page .need-pick .desk-row:focus-visible {
+ background: transparent;
+ color: inherit;
+ outline: none;
+}
+
+.event-page .need-pick:has(.desk-row.is-ended) {
background: #eef1f4;
color: #6b7784;
}
-.event-page .desk-row.is-ended:hover,
-.event-page .desk-row.is-ended:focus-visible {
+.event-page .need-pick:has(.desk-row.is-ended):hover,
+.event-page .need-pick:has(.desk-row.is-ended:focus-visible) {
background: #e4e9ee;
- color: #6b7784;
}
.need-day .desk-rows {
@@ -2773,7 +2905,7 @@ button.btn-quiet::before {
gap: 0.75rem 1rem;
min-height: 4.15rem;
padding: 0.7rem 0.95rem;
- background: var(--hope-blue-75);
+ background: #f3f7fb;
border-radius: 0.95rem;
color: var(--hope-ink);
text-decoration: none;
@@ -2781,7 +2913,7 @@ button.btn-quiet::before {
.desk-row:hover,
.desk-row:focus-visible {
- background: var(--hope-blue-100);
+ background: #e8f1f7;
color: var(--hope-ink);
text-decoration: none;
}
@@ -2913,7 +3045,7 @@ button.btn-quiet::before {
.coordinator-board .desk-panel .empty {
margin: 0;
padding: 0.85rem 1rem;
- background: var(--hope-blue-75);
+ background: #f3f7fb;
border-radius: 0.95rem;
box-shadow: none;
}
@@ -4330,7 +4462,9 @@ main > .crumb,
display: contents;
}
-.event-edit:not([open]) > form {
+/* The closed details content is still a grid row. Hiding it drops the row gap that was sitting under the summary. */
+.event-edit:not([open]) > form,
+.event-edit:not([open])::details-content {
display: none;
}
@@ -4357,11 +4491,80 @@ main > .crumb,
display: none;
}
-.event-edit[open] > form {
+.event-edit[open] > form,
+.event-edit[open]::details-content {
grid-column: 1 / -1;
grid-row: 2;
}
+.event-edit[open] > summary {
+ background: #f4f8fb;
+}
+
+.event-strip:has(.event-edit[open] .event-fields) {
+ padding-bottom: 0;
+}
+
+.event-fields {
+ max-width: none;
+ margin: 0.2rem -1rem 0;
+ padding: 1rem 1rem 1.05rem;
+ border-top: 1px solid #e6eef3;
+ border-radius: 0 0 0.9rem 0.9rem;
+ background: var(--hope-blue-75);
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 0.85rem 1rem;
+ align-items: start;
+}
+
+.event-fields > .error,
+.event-fields > label:not(.check) {
+ grid-column: 1 / -1;
+}
+
+.event-fields label {
+ line-height: 1.35;
+}
+
+.event-fields .hint {
+ font-size: 0.86rem;
+ line-height: 1.4;
+ color: #5c6b78;
+}
+
+.event-fields input[type="text"],
+.event-fields textarea {
+ background: #fff;
+ border: 1px solid #d5dee6;
+ box-shadow: none;
+}
+
+.event-fields textarea {
+ min-height: 5.75rem;
+}
+
+.event-fields > .check {
+ display: flex;
+ align-items: center;
+ align-self: center;
+ min-height: 2.75rem;
+}
+
+.event-fields > button {
+ justify-self: end;
+ align-self: center;
+}
+
+@media (max-width: 42em) {
+ .event-fields {
+ grid-template-columns: 1fr;
+ }
+
+ .event-fields > button {
+ justify-self: start;
+ }
+}
+
.edit-chevron {
width: 0.4rem;
height: 0.4rem;
diff --git a/public/js/settings.js b/public/js/settings.js
new file mode 100644
index 0000000..4e12e91
--- /dev/null
+++ b/public/js/settings.js
@@ -0,0 +1,49 @@
+(function () {
+ var form = document.querySelector('[data-settings]');
+ if (!form) return;
+ var far = form.querySelector('select[name="reminder_far"]');
+ var near = form.querySelector('select[name="reminder_near"]');
+ var months = form.querySelector('select[name="retention_months"]');
+ var reminderPreview = form.querySelector('[data-reminder-preview]');
+ var retentionPreview = form.querySelector('[data-retention-preview]');
+
+ var phrase = function (select) {
+ if (!select || select.selectedIndex < 0) return '';
+ return select.options[select.selectedIndex].text.replace(' (usual)', '');
+ };
+
+ var clearError = function (select) {
+ if (!select) return;
+ var label = select.closest('label');
+ var error = label && label.querySelector('.error');
+ if (error) error.remove();
+ };
+
+ var paintReminders = function () {
+ clearError(far);
+ clearError(near);
+ if (!far || !near || !reminderPreview) return;
+ var first = phrase(far);
+ var second = phrase(near);
+ if (!first || !second) return;
+ if (far.value === near.value) {
+ reminderPreview.textContent = 'Choose two different times. One email should go out earlier than the other.';
+ return;
+ }
+ var earlier = Number(far.value) >= Number(near.value) ? first : second;
+ var closer = Number(far.value) >= Number(near.value) ? second : first;
+ reminderPreview.textContent = 'Volunteers get an email ' + earlier + ' the shift, and another ' + closer + ' the shift.';
+ };
+
+ var paintRetention = function () {
+ clearError(months);
+ if (!months || !retentionPreview) return;
+ var kept = phrase(months);
+ if (!kept) return;
+ retentionPreview.textContent = 'Names, email addresses, and phone numbers come off a signup ' + kept + ' after the shift ends.';
+ };
+
+ if (far) far.addEventListener('change', paintReminders);
+ if (near) near.addEventListener('change', paintReminders);
+ if (months) months.addEventListener('change', paintRetention);
+})();
diff --git a/src/admin-http.tsx b/src/admin-http.tsx
index 847c8ad..eb69921 100644
--- a/src/admin-http.tsx
+++ b/src/admin-http.tsx
@@ -726,7 +726,6 @@ function settingsFormFromBody(body: Record): SettingsForm {
reminderNear: textField(body, 'reminder_near'),
replyTo: textField(body, 'reply_to'),
retentionMonths: textField(body, 'retention_months'),
- privacyText: textField(body, 'privacy_text'),
};
}
diff --git a/src/admin-pages.tsx b/src/admin-pages.tsx
index fdadb9e..9aa9ed2 100644
--- a/src/admin-pages.tsx
+++ b/src/admin-pages.tsx
@@ -2,7 +2,7 @@ import { Temporal } from '@js-temporal/polyfill';
import { DESK_WINDOW_DAYS, type AdminEvent, type HomeEvent, type HomeShift, type AdminShift, type AdminShiftSummary, type AdminTemplate, type MoveTarget, type RosterPerson } from './admin/store.js';
import { spotsSentence } from './schedule.js';
import type { EventValues, ShiftValues, TemplateValues } from './admin/forms.js';
-import type { SettingsErrors, SettingsForm } from './settings.js';
+import { MAX_REMINDER_HOURS, MAX_RETENTION_MONTHS, type SettingsErrors, type SettingsForm } from './settings.js';
import type { AppConfig } from './config.js';
import {
CONTACT_LIST_PAGE,
@@ -337,6 +337,13 @@ export function AdminHome(props: {
);
}
+const FIRST_REMINDER_HOURS = [168, 72, 48, 24] as const;
+const SECOND_REMINDER_HOURS = [24, 12, 4, 2, 1] as const;
+const RETENTION_MONTHS = [6, 12, 24, 36, 60, 120] as const;
+const USUAL_FIRST_HOURS = 48;
+const USUAL_SECOND_HOURS = 2;
+const USUAL_RETENTION_MONTHS = 24;
+
export function SettingsPage(props: {
config: AppConfig;
csrf: string;
@@ -345,50 +352,149 @@ export function SettingsPage(props: {
notice?: string;
}) {
const errors = props.errors ?? {};
+ const reminderNote = reminderPreview(props.values.reminderFar, props.values.reminderNear);
+ const keepNote = retentionPreview(props.values.retentionMonths);
return (
<>
-
Settings
+
+
Settings
+
Choose when volunteers get a reminder, where their replies go, and how long signup details stay here. This applies to email that has not gone out yet.
+
-
+
>
);
}
+function ReminderOptions(props: { selected: string; choices: readonly number[]; usual: number }) {
+ return listedHours(props.selected, props.choices).map((hours) => (
+
+ ));
+}
+
+function RetentionOptions(props: { selected: string }) {
+ return listedMonths(props.selected).map((months) => (
+
+ ));
+}
+
+function listedHours(selected: string, choices: readonly number[]): number[] {
+ const current = wholeInRange(selected, 1, MAX_REMINDER_HOURS);
+ if (current === null || choices.includes(current)) return [...choices];
+ return [...choices, current].sort((a, b) => b - a);
+}
+
+function listedMonths(selected: string): number[] {
+ const current = wholeInRange(selected, 1, MAX_RETENTION_MONTHS);
+ if (current === null || (RETENTION_MONTHS as readonly number[]).includes(current)) return [...RETENTION_MONTHS];
+ return [...RETENTION_MONTHS, current].sort((a, b) => a - b);
+}
+
+function reminderPreview(far: string, near: string): string | null {
+ const first = wholeInRange(far, 1, MAX_REMINDER_HOURS);
+ const second = wholeInRange(near, 1, MAX_REMINDER_HOURS);
+ if (first === null || second === null) return null;
+ if (first === second) return 'Choose two different times. One email should go out earlier than the other.';
+ const earlier = Math.max(first, second);
+ const closer = Math.min(first, second);
+ return `Volunteers get an email ${aheadChoice(earlier)} the shift, and another ${aheadChoice(closer)} the shift.`;
+}
+
+function retentionPreview(months: string): string | null {
+ const count = wholeInRange(months, 1, MAX_RETENTION_MONTHS);
+ if (count === null) return null;
+ return `Names, email addresses, and phone numbers come off a signup ${keepPhrase(count)} after the shift ends.`;
+}
+
+function aheadChoice(hours: number): string {
+ if (hours === 1) return '1 hour before';
+ if (hours % 168 === 0) {
+ const weeks = hours / 168;
+ return weeks === 1 ? '1 week before' : `${weeks} weeks before`;
+ }
+ if (hours % 24 === 0) {
+ const days = hours / 24;
+ return days === 1 ? '1 day before' : `${days} days before`;
+ }
+ return `${hours} hours before`;
+}
+
+function keepPhrase(months: number): string {
+ if (months % 12 === 0) {
+ const years = months / 12;
+ return years === 1 ? '1 year' : `${years} years`;
+ }
+ return months === 1 ? '1 month' : `${months} months`;
+}
+
+function wholeInRange(value: string, min: number, max: number): number | null {
+ const trimmed = value.trim();
+ if (!/^[1-9][0-9]{0,2}$/.test(trimmed)) return null;
+ const count = Number(trimmed);
+ return count >= min && count <= max ? count : null;
+}
+
export function AdminsPage(props: {
config: AppConfig;
csrf: string;
@@ -796,7 +902,7 @@ export function EventEditor(props: {
Edit details
-
+
) : (
@@ -1659,41 +1765,30 @@ function EventForm(props: {
heading?: string;
headingId?: string;
wide?: boolean;
+ panel?: boolean;
}) {
+ const formClass = ['signup-form', props.wide ? 'event-details-form' : '', props.panel ? 'event-fields' : ''].filter(Boolean).join(' ');
return (
-