diff --git a/README.md b/README.md index b71e2ef..228c196 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ A reminder is queued at each saved time before a confirmed signup, while the shi **Download this roster**, on a shift, and **Download this event**, on an event, save a spreadsheet of the signups. **Download this date range**, on the coordinator page, uses each event's local shift date. The file includes cancelled signups and attendance. A cell that would be a spreadsheet formula is saved as text. The download is not cached. A copy on a coordinator's computer is outside this app, and the app does not delete it later. -**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. **Import this list** 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 blank phone does not erase a phone already saved. 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 contacts** 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**, then choose the shift from **Shift**. 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. **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. +**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. **Import this list** 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 blank phone does not erase a phone already saved. 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 contacts** 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**, then choose the shift from **Shift**. 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. **Correct this 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. A blank phone removes the saved number. 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. diff --git a/public/css/app.css b/public/css/app.css index 8562c04..a8672b0 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -446,6 +446,16 @@ main a:hover { color: var(--hope-ink-2); } +.saved-link { + margin: 0.85rem 0 0.2rem; + overflow-wrap: anywhere; + line-height: 1.45; +} + +.saved-link a { + user-select: all; +} + .shift-calendar { margin-top: 1.25rem; } @@ -2228,6 +2238,11 @@ button.btn-quiet::before { flex-direction: column; } + .event-page .desk-actions .btn, + .event-page .desk-actions .desk-inline { + flex: 0 0 auto; + } + .event-page .desk-actions .btn, .event-page .desk-actions .desk-inline, .desk-actions .desk-inline button, diff --git a/src/admin-http.tsx b/src/admin-http.tsx index bf716c8..45ec525 100644 --- a/src/admin-http.tsx +++ b/src/admin-http.tsx @@ -79,6 +79,7 @@ import type { MailIdentity } from './mail/types.js'; import { issueFormToken, newOperationId, readFormToken } from './form-token.js'; import { contactListLimit, + correctContact, exportContacts, formatContactSkips, getContact, @@ -149,6 +150,7 @@ export function registerAdmin(app: Hono, services: AdminServices): void { app.post(appPath(config, '/admin/contacts/:id/remove'), (c) => submitRemoveContact(c, services)); app.post(appPath(config, '/admin/contacts/:id/add'), (c) => submitAddContactToShift(c, services)); app.get(appPath(config, '/admin/contacts/:id'), (c) => showContact(c, services)); + app.post(appPath(config, '/admin/contacts/:id'), (c) => submitCorrectContact(c, services)); app.get(appPath(config, '/admin/events/new'), (c) => showNewEvent(c, services)); app.post(appPath(config, '/admin/events'), (c) => submitNewEvent(c, services)); app.get(appPath(config, '/admin/events/:id/remove'), (c) => showRemoveEvent(c, services)); @@ -440,7 +442,13 @@ function showRemoveContact(c: Context, services: AdminServices, error?: string, function showContact( c: Context, services: AdminServices, - state?: { error?: string; status?: 200 | 400; form?: WalkInState; shiftId?: string }, + state?: { + error?: string; + status?: 200 | 400; + form?: WalkInState; + shiftId?: string; + correction?: { values: ContactManualValues; errors: ContactManualErrors }; + }, ) { const session = requireSession(c, services); if (session instanceof Response) return session; @@ -457,12 +465,37 @@ function showContact( shifts={listOpenShiftsForPerson(services.db, { email: contact.email, name: contact.name }, services.now())} form={state?.form ?? blankWalkIn(services, contact.id)} shiftId={state?.shiftId ?? ''} + notice={state?.status === 400 ? undefined : knownNotice(c.req.query('notice'))} + correction={state?.correction} error={state?.error} />, { account: session, status: state?.status ?? 200 }, ); } +async function submitCorrectContact(c: Context, services: AdminServices): Promise { + const session = await postedSession(c, services); + if (session instanceof Response) return session; + const id = idFrom(c); + const values = { + firstName: textField(session.body, 'first_name'), + lastName: textField(session.body, 'last_name'), + email: textField(session.body, 'email'), + phone: textField(session.body, 'phone'), + }; + try { + const saved = correctContact(services.db, session.coordinatorId, id, values, services.now()); + if (!saved.ok) { + if ('missing' in saved) return missing(c, services); + return showContact(c, services, { status: 400, correction: { values, errors: saved.errors } }); + } + const notice = saved.status === 'changed' ? 'contact-corrected' : 'contact-same'; + return c.redirect(appPath(services.config, `/admin/contacts/${id}?notice=${notice}`), 303); + } catch (err) { + return saveFailed(c, services, session, err); + } +} + function contactShiftUnavailable(c: Context, services: AdminServices, email: string, name: string, shiftId: number, form: WalkInState) { const already = shiftId > 0 && confirmedPersonOnShift(services.db, shiftId, email, name); return showContact(c, services, { @@ -1484,7 +1517,9 @@ function knownNotice(value: string | undefined): string | undefined { value === 'contact-removed' || value === 'contact-saved' || value === 'contact-updated' || - value === 'contact-matched' + value === 'contact-matched' || + value === 'contact-corrected' || + value === 'contact-same' ) { return value; } diff --git a/src/admin-pages.tsx b/src/admin-pages.tsx index e70b1b3..f2ac6a5 100644 --- a/src/admin-pages.tsx +++ b/src/admin-pages.tsx @@ -15,6 +15,7 @@ import { } from './contacts.js'; import type { SignupErrors, SignupValues } from './signup-form.js'; import { addLocalDays, todayInZone } from './time.js'; +import { ShiftTargetOptions } from './shift-options.js'; import { appPath } from './url.js'; export type WalkInState = { @@ -353,7 +354,7 @@ export function ContactsPage(props: { ) : null} {hiddenSkips > 0 ?

{hiddenSkips === 1 ? '1 more row was skipped.' : `${hiddenSkips} more rows were skipped.`}

: null}

- Someone who signs up is saved here. Cancelling that signup does not remove them. A different name is a separate contact, even when the email matches. To add someone who has not signed up, import a spreadsheet or save them below. That does not take a spot and does not send email. Choose a name to add that person to an open shift. Old signups lose their details after the retention period. This list stays until you remove someone. + Someone who signs up is saved here. Cancelling that signup does not remove them. A different name is a separate contact, even when the email matches. To add someone who has not signed up, import a spreadsheet or save them below. That does not take a spot and does not send email. Choose a name to correct that person or add them to an open shift. Old signups lose their details after the retention period. This list stays until you remove someone.

@@ -440,11 +441,22 @@ export function ContactPage(props: { shifts: MoveTarget[]; form: WalkInState; shiftId: string; + notice?: string; + correction?: { values: ContactManualValues; errors: ContactManualErrors }; error?: string; }) { const values = props.form.values; const errors = props.form.errors; const errorEntries = Object.entries(errors).filter((entry): entry is [string, string] => Boolean(entry[1])); + const correction = props.correction ?? { + values: { + firstName: props.contact.firstName, + lastName: props.contact.lastName, + email: props.contact.email, + phone: props.contact.phone ?? '', + }, + errors: {}, + }; return ( <>

@@ -453,6 +465,27 @@ export function ContactPage(props: {

{props.contact.name}

{props.contact.email}

{props.contact.phone ?

{props.contact.phone}

: null} + + + +

Correct this contact

+

+ This changes the saved person. A different name stays this contact and does not create a second person. It does not change a signup, take a spot, or send email. Names are capitalized. A 10-digit phone is saved with dashes, like 712-555-0100. A blank phone removes the saved number. +

+ + + + + + {props.error ?

{props.error}

: null}

Add to a shift

Choose an open shift. This uses their saved name, email, and phone. It takes one spot and queues a confirmation email. Their name stays off the public list. Full, cancelled, and ended shifts are left off this list, and so is a shift they are already on.

@@ -474,14 +507,7 @@ export function ContactPage(props: {