diff --git a/public/css/app.css b/public/css/app.css
index 975a7fb..e042a9b 100644
--- a/public/css/app.css
+++ b/public/css/app.css
@@ -661,6 +661,245 @@ main a:hover {
text-decoration: none;
}
+.manage {
+ display: grid;
+ gap: 0.35rem 0;
+ width: min(64rem, 100%);
+ margin-inline: auto;
+}
+
+.manage-intro h1 {
+ margin-bottom: 0.35rem;
+}
+
+.manage-intro h2,
+.manage-intro p {
+ margin: 0.15rem 0;
+}
+
+.manage-intro .status {
+ margin: 0.15rem 0 0.65rem;
+}
+
+.status.is-cancelled {
+ display: inline-block;
+ width: fit-content;
+ padding: 0.15rem 0.7rem;
+ border: 1px solid var(--hope-full-edge);
+ border-radius: 999px;
+ background: var(--hope-full);
+ color: var(--hope-ink);
+}
+
+.manage-record {
+ position: relative;
+ margin-top: 0.85rem;
+ padding: 1.15rem 1.25rem 1.25rem;
+ background: var(--hope-blue-100);
+ border-radius: 1.75rem;
+ box-shadow: var(--hope-shadow);
+}
+
+.manage-follow {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ align-items: stretch;
+ margin-top: 1.15rem;
+ padding-top: 1.15rem;
+ border-top: 1px solid var(--hope-border-2);
+}
+
+.manage-follow:has(> :only-child) {
+ grid-template-columns: minmax(0, 1fr);
+}
+
+.manage-follow > .manage-action,
+.manage-follow > .hint {
+ min-width: 0;
+ margin: 0;
+ padding: 0 1.35rem;
+}
+
+.manage-follow > :first-child {
+ padding-left: 0;
+}
+
+.manage-follow > :only-child {
+ padding-right: 0;
+}
+
+.manage-follow > :last-child:not(:only-child) {
+ padding-right: 0;
+ border-left: 1px solid var(--hope-border-2);
+}
+
+.manage-record .move-form {
+ margin: 0;
+}
+
+.manage-follow .move-form {
+ gap: 0.55rem;
+}
+
+.manage-follow .hint,
+.manage-follow .field-error {
+ margin: 0;
+}
+
+.manage-action-row {
+ display: grid;
+ gap: 0.55rem;
+}
+
+.manage-follow .manage-action-row label,
+.manage-follow .manage-action-row select {
+ width: 100%;
+ min-width: 0;
+ max-width: 100%;
+}
+
+.manage-follow .manage-action-row button {
+ width: 7.5rem;
+ min-height: 48px;
+}
+
+.manage > .move-form {
+ max-width: none;
+ margin-top: 1rem;
+ padding: 1.15rem 1.25rem 1.25rem;
+ background: var(--hope-blue-100);
+ border-radius: 1.75rem;
+ box-shadow: var(--hope-shadow);
+}
+
+.manage .cancel-form,
+.manage-actions {
+ max-width: none;
+ margin-top: 1rem;
+}
+
+.manage .error {
+ margin: 0.5rem 0 0;
+}
+
+.manage-tools {
+ position: absolute;
+ z-index: 2;
+ top: 1.05rem;
+ right: 1.05rem;
+ display: flex;
+ align-items: center;
+ gap: 0.4rem;
+ margin: 0;
+}
+
+.manage-cancel {
+ margin: 0;
+}
+
+.manage-x {
+ width: 2.5rem;
+ height: 2.5rem;
+ min-height: 2.5rem;
+ padding: 0;
+ border-color: var(--hope-border);
+ background: #fff;
+ box-shadow: none;
+}
+
+.manage-x::before {
+ background: var(--hope-yellow);
+}
+
+.manage-x span {
+ position: relative;
+ width: 0.7rem;
+ height: 0.7rem;
+ font-size: 0;
+}
+
+.manage-x span::before,
+.manage-x span::after {
+ content: "";
+ position: absolute;
+ left: 50%;
+ top: 50%;
+ width: 0.7rem;
+ height: 2px;
+ border-radius: 1px;
+ background: currentColor;
+}
+
+.manage-x span::before {
+ transform: translate(-50%, -50%) rotate(45deg);
+}
+
+.manage-x span::after {
+ transform: translate(-50%, -50%) rotate(-45deg);
+}
+
+.manage-menu {
+ position: relative;
+}
+
+.manage-menu > summary {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.4rem;
+ min-height: 2.5rem;
+ padding: 0.2rem 0.8rem;
+ list-style: none;
+ cursor: pointer;
+ background: #fff;
+ border: 1px solid var(--hope-border-2);
+ border-radius: 999px;
+ font-weight: 650;
+}
+
+.manage-menu > summary::-webkit-details-marker {
+ display: none;
+}
+
+.manage-menu > summary::marker {
+ content: "";
+}
+
+.manage-menu > summary::after {
+ content: "";
+ width: 0.4rem;
+ height: 0.4rem;
+ border-right: 2px solid currentColor;
+ border-bottom: 2px solid currentColor;
+ transform: translateY(-0.12rem) rotate(45deg);
+}
+
+.manage-menu[open] > summary::after {
+ transform: translateY(0.1rem) rotate(225deg);
+}
+
+.manage-menu-panel {
+ position: absolute;
+ z-index: 4;
+ top: calc(100% + 0.25rem);
+ right: 0;
+ display: flex;
+ width: max-content;
+ margin: 0;
+ padding: 0.35rem 0.6rem;
+ background: #fff;
+ border-radius: 0.75rem;
+ box-shadow: var(--hope-shadow);
+}
+
+.manage-menu-panel .check {
+ min-height: 0;
+ gap: 0.4rem;
+}
+
+.manage-menu-panel .check input {
+ accent-color: var(--hope-blue-quiet-ink);
+}
+
.signup-board {
margin-top: 1.25rem;
}
@@ -786,7 +1025,7 @@ main a:hover {
.day-card {
overflow: hidden;
- background: var(--hope-blue-50);
+ background: #fff;
border-radius: 1.75rem;
box-shadow: var(--hope-shadow);
container: day / inline-size;
@@ -848,7 +1087,7 @@ main a:hover {
display: flex;
flex-direction: column;
min-width: 0;
- background: var(--hope-blue-50);
+ background: #fff;
}
.shift-pane.is-ended::after {
@@ -1776,15 +2015,20 @@ article.shift-card {
}
.details {
- margin: 1.25rem 0;
- padding: 0.4rem 1.15rem 0.9rem;
- background: var(--hope-blue-100);
- border-radius: 1.5rem;
- box-shadow: var(--hope-shadow);
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 0.85rem 1.5rem;
+ margin: 0;
+ padding: 0;
}
.details div {
- margin: 0.7rem 0;
+ margin: 0;
+ min-width: 0;
+}
+
+.details .is-wide {
+ grid-column: 1 / -1;
}
.details dt {
@@ -1793,6 +2037,7 @@ article.shift-card {
.details dd {
margin: 0;
+ overflow-wrap: anywhere;
}
.hp {
@@ -2083,13 +2328,24 @@ html:has(#signup-dialog[open]) {
margin: 0;
}
-.confirm-form h2 {
+.confirm-form h2,
+.confirm-card > h2 {
margin: 0 1.8rem 0.1rem 0;
font-size: 1.2rem;
line-height: 1.3;
overflow-wrap: anywhere;
}
+.confirm-card > p {
+ margin: 0;
+ font-size: 0.95rem;
+ line-height: 1.45;
+}
+
+#manage-cancel-dialog .confirm-card {
+ width: min(28rem, 100%);
+}
+
.confirm-form p,
.confirm-detail,
.confirm-note {
@@ -3755,6 +4011,38 @@ button.btn-quiet::before {
grid-template-columns: 1fr;
}
+ .details {
+ grid-template-columns: 1fr;
+ }
+
+ .manage-follow {
+ grid-template-columns: minmax(0, 1fr);
+ }
+
+ .manage-follow > .manage-action,
+ .manage-follow > .hint {
+ padding: 0;
+ }
+
+ .manage-follow > :last-child:not(:only-child) {
+ margin-top: 1.15rem;
+ padding-top: 1.15rem;
+ border-top: 1px solid var(--hope-border-2);
+ border-left: 0;
+ }
+
+ .manage-follow .manage-action-row button {
+ width: 100%;
+ }
+
+ .manage-record:has(.manage-tools) {
+ padding-top: 4.35rem;
+ }
+
+ .manage-record:has(.manage-tools) .details {
+ padding-right: 0;
+ }
+
.signup-form button,
.cancel-form button,
.move-form button {
diff --git a/public/js/enhance.js b/public/js/enhance.js
index dfd605d..c6ccefd 100644
--- a/public/js/enhance.js
+++ b/public/js/enhance.js
@@ -2,6 +2,7 @@
bindNav();
bindCalendar();
bindViewMenu();
+ bindManage();
document.querySelectorAll('[data-contact]').forEach(bindContact);
document.querySelectorAll('[data-see-more]').forEach(bindSeeMore);
@@ -25,7 +26,7 @@
}
function bindViewMenu() {
- var menus = document.querySelectorAll('details.view-menu');
+ var menus = document.querySelectorAll('details.view-menu, details.manage-menu');
if (!menus.length) return;
document.addEventListener('click', function (event) {
for (var i = 0; i < menus.length; i += 1) {
@@ -74,6 +75,29 @@
}
}
+ function bindManage() {
+ document.querySelectorAll('[data-reminder-toggle]').forEach(function (box) {
+ box.addEventListener('change', function () {
+ if (box.form) box.form.submit();
+ });
+ });
+ var opener = document.querySelector('[data-manage-cancel]');
+ var dialog = document.getElementById('manage-cancel-dialog');
+ if (!opener || !dialog || typeof dialog.showModal !== 'function') return;
+ opener.addEventListener('click', function (event) {
+ event.preventDefault();
+ if (dialog.open) dialog.close();
+ dialog.showModal();
+ dialog.classList.add('is-modal');
+ });
+ dialog.addEventListener('click', function (event) {
+ if (event.target === dialog) dialog.close();
+ });
+ dialog.addEventListener('close', function () {
+ dialog.classList.remove('is-modal');
+ });
+ }
+
function bindSeeMore(link) {
var list = document.getElementById('contacts-list');
if (!list) return;
diff --git a/src/pages.tsx b/src/pages.tsx
index f87703d..8092e0f 100644
--- a/src/pages.tsx
+++ b/src/pages.tsx
@@ -370,117 +370,182 @@ export function ManagePage(props: {
cancel: { action: string; token: string } | null;
switches: SwitchForm | null;
party?: PartyForm | null;
- reminders?: { action: string; token: string } | 'off' | null;
+ reminders?: { action: string; token: string; on: boolean } | null;
notice?: string;
note?: string;
}) {
const signup = props.signup;
+ const cancelled = signup.status !== 'confirmed';
return (
- <>
-
Your signup
- {signup.status === 'confirmed' ? 'Confirmed' : 'Cancelled'}
- {signup.eventTitle}
- {signup.role}
-
- {signup.when.dateLabel} {signup.when.timeLabel} {signup.when.abbreviation}
-
- {signup.location ? {signup.location}
: null}
-
-
-
Name
- {signup.name}
-
-
-
People
- {signup.groupSize}
-
-
-
Email
- {signup.email}
-
- {signup.phone ? (
-
-
Phone
- {signup.phone}
-
- ) : null}
- {signup.notes ? (
-
-
Notes
- {signup.notes}
-
- ) : null}
-
+
+
+ Your signup
+ {cancelled ? 'Cancelled' : 'Confirmed'}
+ {signup.eventTitle}
+ {signup.role}
+
+ {signup.when.dateLabel} {signup.when.timeLabel} {signup.when.abbreviation}
+
+ {signup.location ? {signup.location}
: null}
+
{props.note ? {props.note}
: null}
{props.notice ? (
{props.notice}
) : null}
- {props.party ? (
-
- ) : null}
- {props.switches ? (
- props.switches.targets.length === 0 ? (
-
- {signup.groupSize > 1
- ? 'There is no other open shift with room for everyone on this signup.'
- : 'There is no other open shift you can switch to.'}
-
- ) : (
-
- )
- ) : null}
- {props.reminders === 'off' ? (
- Reminder emails for this signup are off. The signup stays. Confirmation, change, and cancellation emails still arrive.
- ) : null}
-
- {props.reminders && props.reminders !== 'off' ? (
-
+
+ {props.cancel || props.reminders ? (
+
+
+ {props.cancel ? (
+
+ ) : null}
+
) : null}
- {props.cancel ? (
-
+ {props.cancel ? (
+
+
+
+
+ ×
+
+
+
Are you sure you want to cancel?
{signup.groupSize > 1
? `Cancel this signup to open these ${signup.groupSize} spots for someone else. A cancellation email is queued when you cancel.`
: 'Cancel this signup to open the spot for someone else. A cancellation email is queued when you cancel.'}
-
-
Cancel this signup
-
- ) : (
-
- {signup.groupSize > 1
- ? `This signup is cancelled. The ${signup.groupSize} spots it held are open for someone else. A cancellation email is queued.`
- : 'This signup is cancelled. The spot is open for someone else. A cancellation email is queued.'}
-
- )}
-
- >
+
+
+ Cancel this signup
+
+
+ Go back
+
+
+
+
+ ) : (
+
+ {signup.groupSize > 1
+ ? `This signup is cancelled. The ${signup.groupSize} spots it held are open for someone else. A cancellation email is queued.`
+ : 'This signup is cancelled. The spot is open for someone else. A cancellation email is queued.'}
+
+ )}
+
+ );
+}
+
+function ReminderMenu(props: { reminders?: { action: string; token: string; on: boolean } | null }) {
+ if (!props.reminders) return null;
+ return (
+
);
}
diff --git a/src/reminders.ts b/src/reminders.ts
index c46dc55..8076f25 100644
--- a/src/reminders.ts
+++ b/src/reminders.ts
@@ -75,6 +75,8 @@ export function queueDueReminders(db: Database.Database, mail: MailIdentity, sec
}).immediate();
}
+const REMINDERS_OFF_REASON = 'Reminders were turned off before this message was sent.';
+
/** Turns reminders off for one signup. Confirmation, change, and cancellation mail still queue. */
export function disableReminders(
db: Database.Database,
@@ -89,11 +91,34 @@ export function disableReminders(
if (row.reminders_off !== 1) {
db.prepare('UPDATE signups SET reminders_off = 1, updated_at = ? WHERE id = ? AND anonymized_at IS NULL').run(now, signupId);
}
- cancelPendingReminders(db, signupId, 'Reminders were turned off before this message was sent.');
+ cancelPendingReminders(db, signupId, REMINDERS_OFF_REASON);
return { ok: true, already: row.reminders_off === 1 };
}).immediate();
}
+/** Turns reminders back on and restores a reminder that was cancelled only because they were off. */
+export function enableReminders(
+ db: Database.Database,
+ signupId: number,
+ now: string,
+): { ok: true } | { ok: false } {
+ return db.transaction((): { ok: true } | { ok: false } => {
+ const row = db
+ .prepare('SELECT reminders_off AS reminders_off FROM signups WHERE id = ? AND anonymized_at IS NULL')
+ .get(signupId) as { reminders_off: number } | undefined;
+ if (!row) return { ok: false };
+ if (row.reminders_off === 1) {
+ db.prepare('UPDATE signups SET reminders_off = 0, updated_at = ? WHERE id = ? AND anonymized_at IS NULL').run(now, signupId);
+ }
+ db.prepare(
+ `UPDATE outbox
+ SET status = 'pending', last_error = NULL
+ WHERE signup_id = ? AND kind = 'reminder' AND status = 'cancelled' AND last_error = ?`,
+ ).run(signupId, REMINDERS_OFF_REASON);
+ return { ok: true };
+ }).immediate();
+}
+
export function issueReminderOffToken(secret: string, signupId: number): string {
const id = String(signupId);
const mac = createHmac('sha256', secret).update(`hope-reminder-off-v1\0${id}`).digest('base64url');
diff --git a/src/signup-http.tsx b/src/signup-http.tsx
index 9aa5069..decd24b 100644
--- a/src/signup-http.tsx
+++ b/src/signup-http.tsx
@@ -30,7 +30,7 @@ import { getPublicShift, type PublicShift } from './schedule.js';
import { SIGNUP_TOO_EARLY } from './signup-window.js';
import { EMPTY_SIGNUP, parsePartySize, parseSignupForm, spotsLeftMessage, type SignupErrors, type SignupValues } from './signup-form.js';
import type { MailIdentity } from './mail/types.js';
-import { disableReminders } from './reminders.js';
+import { disableReminders, enableReminders, queueDueReminders } from './reminders.js';
import { cancelSignup, changePartySize, confirmedOperationShift, findSignupByOperation, managePartyLimit, readManageSignup, reserveSignup } from './signup.js';
import { verifyTurnstile, type TurnstileCheck, type TurnstileVerdict } from './turnstile.js';
import { appPath, cookiePath } from './url.js';
@@ -105,7 +105,7 @@ export function registerPublicSignup(app: Hono, services: SignupServices): void
app.post(appPath(config, '/m/:token/switch'), (c) => submitSwitch(c, services));
app.post(appPath(config, '/m/:token/party'), (c) => submitParty(c, services));
- app.post(appPath(config, '/m/:token/reminders'), (c) => submitRemindersOff(c, services));
+ app.post(appPath(config, '/m/:token/reminders'), (c) => submitReminders(c, services));
app.post(appPath(config, '/m/:token'), (c) => submitCancel(c, services));
}
@@ -503,16 +503,16 @@ function reminderForm(
services: SignupServices,
token: string,
signup: { status: 'confirmed' | 'cancelled'; remindersOff: boolean },
-): { action: string; token: string } | 'off' | null {
+): { action: string; token: string; on: boolean } | null {
if (signup.status !== 'confirmed') return null;
- if (signup.remindersOff) return 'off';
return {
action: appPath(services.config, `/m/${token}/reminders`),
token: issueReminderPageToken(services.config.sessionSecret, token),
+ on: !signup.remindersOff,
};
}
-async function submitRemindersOff(c: Context, services: SignupServices): Promise {
+async function submitReminders(c: Context, services: SignupServices): Promise {
const token = c.req.param('token') ?? '';
const signup = readManageSignup(services.db, token, services.now());
if (!signup) return missingManage(c, services);
@@ -523,12 +523,16 @@ async function submitRemindersOff(c: Context, services: SignupServices): Promise
if (!reminderPageTokenMatches(services.config.sessionSecret, token, textField(body, 'reminder_token'))) {
return showManage(c, services, token, 400, CANCEL_REJECTED);
}
+ const on = textField(body, 'reminders') === 'on';
try {
- const result = disableReminders(services.db, signup.signupId, services.now());
+ const result = on
+ ? enableReminders(services.db, signup.signupId, services.now())
+ : disableReminders(services.db, signup.signupId, services.now());
if (!result.ok) return missingManage(c, services);
+ if (on) queueDueReminders(services.db, mailIdentity(services.db, services.config), services.config.sessionSecret, services.now());
} catch (err) {
if (!isBusy(err)) throw err;
- console.error('Reminder opt-out could not lock the database.');
+ console.error('Reminder setting could not lock the database.');
return showManage(c, services, token, 503, CANCEL_UNAVAILABLE);
}
c.header('Cache-Control', 'no-store');
diff --git a/tests/cancel.test.ts b/tests/cancel.test.ts
index 3c20d42..f592b69 100644
--- a/tests/cancel.test.ts
+++ b/tests/cancel.test.ts
@@ -333,10 +333,8 @@ describe('manage-link party size', () => {
const html = await viewed.text();
expect(viewed.status).toBe(200);
expect(html).toContain('How many people?');
- expect(html).toContain('This signup holds that many spots.');
- expect(html).toContain('You don't need to add their names.');
- expect(html).toContain('Change how many people are coming. The signup stays, and the name stays the same.');
- expect(html).toContain('Save the number of people');
+ expect(html).toContain('Including you. This holds that many spots, and the name stays the same.');
+ expect(html).toContain('>Save<');
expect(partyOptions(html)).toEqual(['1', '2', '3', '4', '5', '6']);
expect(html).toContain('4 ');
expect(db.prepare('SELECT group_size, updated_at FROM signups').get()).toEqual({
diff --git a/tests/reminders.test.ts b/tests/reminders.test.ts
index 9eb4b53..b5dca76 100644
--- a/tests/reminders.test.ts
+++ b/tests/reminders.test.ts
@@ -176,10 +176,11 @@ describe('reminder mail', () => {
const saved = reserveSignup(db, reservation(shiftId));
expect(saved.ok && saved.manageToken).toBeTruthy();
if (!saved.ok || !saved.manageToken) return;
+ queueDueReminders(db, MAIL, SECRET, NOW);
const page = await app.request(`/m/${saved.manageToken}`);
const html = await page.text();
const token = /name="reminder_token"[^>]*value="([^"]*)"/.exec(html)?.[1] ?? '';
- expect(html).toContain('Stop reminder emails');
+ expect(html).toContain('data-reminder-toggle');
const stopped = await app.request(`/m/${saved.manageToken}/reminders`, {
method: 'POST',
@@ -188,10 +189,22 @@ describe('reminder mail', () => {
});
expect(stopped.status).toBe(303);
expect(db.prepare(`SELECT reminders_off, status FROM signups`).get()).toEqual({ reminders_off: 1, status: 'confirmed' });
+ expect(db.prepare(`SELECT status FROM outbox WHERE kind = 'reminder'`).get()).toEqual({ status: 'cancelled' });
const after = await app.request(`/m/${saved.manageToken}`);
const afterHtml = await after.text();
- expect(afterHtml).toContain('Reminder emails for this signup are off.');
- expect(afterHtml).not.toContain('name="reminder_token"');
+ expect(afterHtml).toContain('name="reminder_token"');
+ expect(afterHtml).not.toContain('checked');
+
+ const resumed = await app.request(`/m/${saved.manageToken}/reminders`, {
+ method: 'POST',
+ headers: { origin: ORIGIN, 'content-type': 'application/x-www-form-urlencoded' },
+ body: new URLSearchParams({ reminder_token: token, reminders: 'on' }),
+ });
+ expect(resumed.status).toBe(303);
+ expect(db.prepare(`SELECT reminders_off, status FROM signups`).get()).toEqual({ reminders_off: 0, status: 'confirmed' });
+ expect(db.prepare(`SELECT status FROM outbox WHERE kind = 'reminder'`).get()).toEqual({ status: 'pending' });
+ const resumedHtml = await (await app.request(`/m/${saved.manageToken}`)).text();
+ expect(resumedHtml).toContain('checked');
});
});