feat: drop attendance marks and bullet volunteer names with the sunburst

Coordinators no longer record who came. Public roster names use the sunburst as a bullet.
This commit is contained in:
blake committed 2026-10-26 16:10:49 -05:00
1 parent 1a8959c86a
commit df3165f6a8
15 files changed
+68 -247

No files matched your search

-35
View File
@@ -40,11 +40,9 @@ import {
listMoveTargets,
listOpenShiftsForPerson,
moveSignup,
setAttendance,
updateEvent,
updateShift,
updateTemplate,
type AttendanceMark,
} from './admin/store.js';
import {
AdminHome,
@@ -191,7 +189,6 @@ export function registerAdmin(app: Hono, services: AdminServices): void {
app.post(appPath(config, '/admin/signups/:id/remove'), (c) => submitRemoveSignup(c, services));
app.get(appPath(config, '/admin/signups/:id/cancel'), (c) => showCancelSignup(c, services));
app.post(appPath(config, '/admin/signups/:id/cancel'), (c) => submitCancelSignup(c, services));
app.post(appPath(config, '/admin/signups/:id/attendance'), (c) => submitAttendance(c, services));
app.post(appPath(config, '/admin/signups/:id/move'), (c) => submitMove(c, services));
}
@@ -1391,31 +1388,6 @@ async function submitCancelShift(c: Context, services: AdminServices): Promise<R
}
}
async function submitAttendance(c: Context, services: AdminServices): Promise<Response> {
const session = await postedSession(c, services);
if (session instanceof Response) return session;
const mark = textField(session.body, 'mark');
if (!isAttendanceMark(mark)) {
return html(c, services, 'Coordinator · Hope Volunteer', <MessagePage heading="Coordinator" message="Choose attended or no-show." />, {
status: 400,
account: session,
});
}
try {
const result = setAttendance(services.db, session.coordinatorId, idFrom(c), mark, services.now());
if (!result.ok) {
return html(c, services, 'Coordinator · Hope Volunteer', <MessagePage heading="Coordinator" message={result.error} />, {
status: 400,
account: session,
});
}
const notice = mark === 'attended' ? 'attended' : mark === 'no-show' ? 'no-show' : 'attendance-cleared';
return c.redirect(appPath(services.config, `/admin/shifts/${result.shiftId}?notice=${notice}`), 303);
} catch (err) {
return saveFailed(c, services, session, err);
}
}
async function submitMove(c: Context, services: AdminServices): Promise<Response> {
const session = await postedSession(c, services);
if (session instanceof Response) return session;
@@ -1595,9 +1567,6 @@ function knownNotice(value: string | undefined): string | undefined {
value === 'shift-cancelled' ||
value === 'shift-closed' ||
value === 'walk-in' ||
value === 'attended' ||
value === 'no-show' ||
value === 'attendance-cleared' ||
value === 'moved' ||
value === 'generated' ||
value === 'no-template' ||
@@ -1646,10 +1615,6 @@ function blankWalkIn(
};
}
function isAttendanceMark(value: string): value is AttendanceMark {
return value === 'attended' || value === 'no-show' || value === 'clear';
}
function signupValuesFrom(body: Record<string, unknown>): SignupValues {
return {
name: textField(body, 'name'),
-25
View File
@@ -974,7 +974,6 @@ export function ShiftRoster(props: {
) : null}
</div>
<p class="panel-note">Cancelling a signup emails them. Their old private link stops working, and the email includes a new one.</p>
<p class="panel-note">Attendance stays on this roster. It does not send email, and it does not change how many spots are open.</p>
<p class="panel-note">Moving a confirmed signup opens this spot and queues a change email. Their old private link stops working.</p>
{props.moves && props.moves.targets.length === 0 ? <p class="panel-note">No other open shift in this event has room.</p> : null}
{props.shift.people.length === 0 ? (
@@ -1782,21 +1781,6 @@ function Roster(props: { config: AppConfig; csrf: string; people: RosterPerson[]
) : null}
{person.status === 'confirmed' ? (
<>
<p>{attendanceLabel(person.attendance)}</p>
<form method="post" action={appPath(props.config, `/admin/signups/${person.id}/attendance`)} class="attendance-actions">
<input type="hidden" name="csrf" value={props.csrf} />
<button type="submit" name="mark" value="attended" aria-pressed={person.attendance === 'attended' ? 'true' : 'false'}>
Attended
</button>
<button type="submit" name="mark" value="no-show" aria-pressed={person.attendance === 'no-show' ? 'true' : 'false'}>
No-show
</button>
{person.attendance ? (
<button type="submit" name="mark" value="clear">
Clear
</button>
) : null}
</form>
<p>
<ConfirmAnchor
class="text-action"
@@ -1912,12 +1896,6 @@ function MassRemove(props: { pick: 'shift' | 'signup'; action: string; title: st
);
}
function attendanceLabel(attendance: RosterPerson['attendance']): string {
if (attendance === 'attended') return 'Attended.';
if (attendance === 'no-show') return 'No-show.';
return 'Attendance is not marked.';
}
function spotClass(shift: Pick<AdminShiftSummary, 'capacity' | 'occupied' | 'cancelled'>): string {
if (shift.cancelled) return 'event-pill is-hidden';
return shift.occupied >= shift.capacity ? 'event-pill is-full' : 'event-pill is-open';
@@ -1935,9 +1913,6 @@ const NOTICES: Record<string, string> = {
'shift-cancelled': 'The shift is cancelled. Cancellation emails are queued.',
'shift-closed': 'The shift is cancelled. No one needed an email.',
'walk-in': 'They are on this shift. A confirmation email is queued.',
attended: 'Marked attended.',
'no-show': 'Marked as a no-show.',
'attendance-cleared': 'The attendance mark is cleared.',
moved: 'They are on this shift. A change email is queued.',
generated: 'Weekly shifts for the next three months are on the schedule. Existing shifts were left as they are.',
'no-template': 'There is no active weekly template.',
+1 -46
View File
@@ -88,7 +88,6 @@ export type RosterPerson = {
phone: string | null;
notes: string | null;
status: 'confirmed' | 'cancelled';
attendance: 'attended' | 'no-show' | null;
};
export type AdminShift = AdminShiftSummary & {
@@ -292,7 +291,7 @@ export function getAdminShift(db: Database.Database, id: number): AdminShift | n
if (!row) return null;
const people = db
.prepare(
`SELECT id, name, email, phone, notes, status, attended
`SELECT id, name, email, phone, notes, status
FROM signups
WHERE shift_id = ? AND anonymized_at IS NULL AND name IS NOT NULL AND email IS NOT NULL
ORDER BY CASE status WHEN 'confirmed' THEN 0 ELSE 1 END, id`,
@@ -304,7 +303,6 @@ export function getAdminShift(db: Database.Database, id: number): AdminShift | n
phone: string | null;
notes: string | null;
status: string;
attended: number | null;
}>;
return {
...presentShift(row, row.tz),
@@ -321,7 +319,6 @@ export function getAdminShift(db: Database.Database, id: number): AdminShift | n
phone: person.phone,
notes: person.notes,
status: person.status,
attendance: person.attended === 1 ? 'attended' : person.attended === 0 ? 'no-show' : null,
}];
}),
};
@@ -946,48 +943,6 @@ export function cancelSignupAsCoordinator(
}).immediate();
}
export type AttendanceMark = 'attended' | 'no-show' | 'clear';
export type AttendanceResult =
| { ok: true; shiftId: number; already: boolean }
| { ok: false; error: string };
/** Records whether a confirmed person came. It does not change the spot or send email. */
export function setAttendance(
db: Database.Database,
coordinatorId: number,
signupId: number,
mark: AttendanceMark,
now: string,
): AttendanceResult {
return db.transaction((): AttendanceResult => {
const row = db
.prepare(
`SELECT id AS id, shift_id AS shift_id, status AS status, attended AS attended, anonymized_at AS anonymized_at
FROM signups WHERE id = ?`,
)
.get(signupId) as
| { id: number; shift_id: number; status: string; attended: number | null; anonymized_at: string | null }
| undefined;
if (!row || row.anonymized_at) return { ok: false, error: 'That signup is not available.' };
if (row.status !== 'confirmed') return { ok: false, error: 'That signup is cancelled.' };
const next = mark === 'attended' ? 1 : mark === 'no-show' ? 0 : null;
const current = row.attended === null ? null : Number(row.attended);
if (current === next) return { ok: true, shiftId: row.shift_id, already: true };
const updated = db
.prepare(
`UPDATE signups
SET attended = ?, updated_at = ?
WHERE id = ? AND status = 'confirmed' AND anonymized_at IS NULL`,
)
.run(next, now, signupId);
if (updated.changes !== 1) return { ok: false, error: 'That signup is not available.' };
if (next === null) writeAudit(db, coordinatorId, 'signup.attend.clear', { signupId: row.id, shiftId: row.shift_id }, now);
else writeAudit(db, coordinatorId, 'signup.attend', { signupId: row.id, shiftId: row.shift_id, attended: next }, now);
return { ok: true, shiftId: row.shift_id, already: false };
}).immediate();
}
export function findSignupShift(db: Database.Database, signupId: number): number | null {
const row = db
.prepare('SELECT shift_id AS shift_id FROM signups WHERE id = ? AND anonymized_at IS NULL')
+2 -2
View File
@@ -144,8 +144,8 @@ function insertFakeSignups(db: Database.Database, shiftId: number, createdAt: st
`INSERT INTO signups (
shift_id, name, email, email_norm, phone, is_minor, guardian_name, guardian_email,
group_size, notes, status, manage_token_hash, token_expires_at, reminders_off,
attended, created_at, updated_at, anonymized_at
) VALUES (?, ?, ?, ?, ?, 0, NULL, NULL, 1, ?, ?, NULL, NULL, 0, NULL, ?, ?, NULL)`,
created_at, updated_at, anonymized_at
) VALUES (?, ?, ?, ?, ?, 0, NULL, NULL, 1, ?, ?, NULL, NULL, 0, ?, ?, NULL)`,
);
return people.map((person) =>
insertId(
+1 -4
View File
@@ -18,7 +18,6 @@ const COLUMNS = [
'Group size',
'Notes',
'Status',
'Attended',
] as const;
export type RosterExport = { csv: string; rows: number };
@@ -34,13 +33,12 @@ type RosterRecord = {
group_size: number;
notes: string | null;
status: string;
attended: number | null;
anonymized_at: string | null;
};
const ROSTER_SQL = `SELECT s.starts_at_utc AS starts_at_utc, s.ends_at_utc AS ends_at_utc, e.tz AS tz, s.role AS role,
su.name AS name, su.email AS email, su.phone AS phone, su.group_size AS group_size,
su.notes AS notes, su.status AS status, su.attended AS attended, su.anonymized_at AS anonymized_at
su.notes AS notes, su.status AS status, su.anonymized_at AS anonymized_at
FROM signups su
JOIN shifts s ON s.id = su.shift_id
JOIN events e ON e.id = s.event_id`;
@@ -131,7 +129,6 @@ function present(row: RosterRecord): string[] {
String(row.group_size),
row.notes ?? '',
row.status === 'cancelled' ? 'Cancelled' : 'Confirmed',
row.attended === 1 ? 'Attended' : row.attended === 0 ? 'No-show' : '',
];
}
+17 -9
View File
@@ -614,15 +614,7 @@ function ShiftPane(props: { config: AppConfig; shift: PublicShift }) {
{shift.inProgress ? <p class="status">In progress</p> : null}
<Spots shift={shift} />
<h4 class="roster-label">Volunteers</h4>
{shift.volunteers.length === 0 ? (
<p class="roster-empty">No one signed up yet.</p>
) : (
<ul class="roster-names">
{shift.volunteers.map((name, index) => (
<li key={`${shift.id}-${index}`}>{name}</li>
))}
</ul>
)}
<RosterNames config={props.config} shiftId={shift.id} names={shift.volunteers} />
</div>
{shift.full ? (
<p class="btn-card is-static">
@@ -831,6 +823,22 @@ function CalendarShift(props: { config: AppConfig; shift: PublicShift }) {
);
}
function RosterNames(props: { config: AppConfig; shiftId: number; names: string[] }) {
if (props.names.length === 0) {
return <p class="roster-empty">No one signed up yet.</p>;
}
return (
<ul class="roster-names">
{props.names.map((name, index) => (
<li key={`${props.shiftId}-${index}`}>
<img class="roster-mark" src={asset(props.config, '/img/sunburst.png')} alt="" />
<span>{name}</span>
</li>
))}
</ul>
);
}
function ShiftWhen(props: { shift: PublicShift }) {
const shift = props.shift;
return (