feat: update shift display logic and styles for ended shifts

Enhanced the user interface to visually indicate when shifts have ended, including graying out past shifts and adding labels for clarity. Updated styles for both the public and admin views to reflect these changes, ensuring a consistent experience. Adjusted the logic to keep ended shifts visible until midnight in their respective time zones, improving user understanding of shift availability.
This commit is contained in:
blake committed 2026-10-28 16:07:37 -05:00
1 parent b039eef5ae
commit 208f08753e
6 files changed
+108 -15

No files matched your search

+1 -1
View File
@@ -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 Wednesday in the next three months, split into that day's shifts. Each shift lists the names of the people who are signed up. 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. Shifts on other weekdays stay on the calendar. `/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 Wednesday 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. Shifts on other weekdays stay on the calendar. `/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.
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.
+53 -2
View File
@@ -37,6 +37,8 @@
--hope-open-edge: #c5d7b4;
--hope-full: #f6e2de;
--hope-full-edge: #e4c4be;
--hope-blue-quiet: #d7ebf8;
--hope-blue-quiet-ink: #2d5f86;
--hope-scrollbar-size: 14px;
--hope-scrollbar-thumb: var(--hope-gold);
--hope-scrollbar-thumb-hover: color-mix(in srgb, var(--hope-gold) 72%, var(--hope-ink));
@@ -849,13 +851,42 @@ main a:hover {
background: var(--hope-blue-50);
}
.shift-pane.is-ended::after {
content: "";
position: absolute;
inset: 0;
z-index: 1;
background: rgb(255 255 255 / 0.5);
pointer-events: none;
}
.shift-pane.is-ended {
position: relative;
}
/* Full is two lines and Sign up uses the large type. One height keeps that band even. */
.shift-pane > .btn-card {
min-height: calc(1.7rem + 2.125rem);
}
.shift-pane-body {
display: grid;
align-content: start;
gap: 0.15rem;
flex: 1;
padding: 1rem 1.2rem 0.85rem;
}
/* A shift with no status line still holds that row when a neighbor has one, so the pills line up. */
.shift-pane-body > .status:empty {
display: none;
}
.day-card-shifts:has(.status:not(:empty)) .shift-pane-body > .status:empty {
display: block;
min-height: 1.7em;
}
.shift-pane-body h3 {
margin-bottom: 0.15rem;
}
@@ -1140,6 +1171,25 @@ main a:hover {
background: rgb(255 255 255 / 0.45);
}
.cal-shift.is-ended {
position: relative;
}
.cal-shift.is-ended .cal-line {
position: relative;
}
.cal-shift.is-ended .cal-line::after,
.cal-shift.is-ended .cal-detail::after {
content: "";
position: absolute;
inset: 0;
z-index: 1;
border-radius: inherit;
background: rgb(255 255 255 / 0.5);
pointer-events: none;
}
.cal-hold {
position: absolute;
z-index: 2;
@@ -2647,8 +2697,8 @@ button.btn-quiet::before {
}
.need-pill.is-public {
background: #d7ebf8;
color: #2d5f86;
background: var(--hope-blue-quiet);
color: var(--hope-blue-quiet-ink);
font-weight: 600;
}
@@ -3724,6 +3774,7 @@ button.btn-quiet::before {
.cal-detail .spots.is-full {
margin-top: 0.25rem;
}
}
/* Wider hamburger layout: one even week row, shifts open underneath it. */
+1 -1
View File
@@ -1251,7 +1251,7 @@ function ShiftList(props: { config: AppConfig; event: AdminEvent; csrf: string;
<details class="help-tip">
<summary aria-label="About upcoming shifts">?</summary>
<p>
Shifts show on the public list when this event is public, the shift is not cancelled, and it has not ended. Repeating shifts add dates for the next three months. Add weekly shifts fills those dates. Shifts already on the schedule stay as they are, including cancelled ones.
Shifts show on the public list when this event is public and the shift is not cancelled. A shift that has already ended stays on today's card, grayed out, until midnight. Then that day leaves the list. Repeating shifts add dates for the next three months. Add weekly shifts fills those dates. Shifts already on the schedule stay as they are, including cancelled ones.
</p>
</details>
</div>
+11 -4
View File
@@ -673,16 +673,20 @@ function ShiftPane(props: { config: AppConfig; shift: PublicShift }) {
const closed = shift.full || shift.cancelled || shift.ended;
const action = closed ? 'View shift' : 'Sign up';
return (
<section class="shift-pane">
<section class={shift.ended ? 'shift-pane is-ended' : 'shift-pane'}>
<div class="shift-pane-body">
<h3>{shift.role}</h3>
<ShiftWhen shift={shift} />
{shift.inProgress ? <p class="status">In progress</p> : null}
<p class="status">{shift.inProgress ? 'In progress' : ''}</p>
<Spots shift={shift} />
<h4 class="roster-label">Volunteers</h4>
<RosterNames config={props.config} shiftId={shift.id} names={shift.volunteers} />
</div>
{shift.full ? (
{shift.ended ? (
<p class="btn-card is-static">
<span class="shift-full-label">Ended</span>
</p>
) : shift.full ? (
<p class="btn-card is-static">
<span class="shift-full-label">Full</span>
<span>Not accepting more signups</span>
@@ -860,14 +864,16 @@ function CalendarShift(props: { config: AppConfig; shift: PublicShift }) {
const closed = shift.full || shift.cancelled || shift.ended;
const action = closed ? 'View shift' : 'Sign up';
return (
<a class="cal-shift" href={appPath(props.config, `/s/${shift.id}`)} data-signup={closed ? undefined : ''}>
<a class={shift.ended ? 'cal-shift is-ended' : 'cal-shift'} href={appPath(props.config, `/s/${shift.id}`)} data-signup={closed ? undefined : ''}>
<span class="cal-line">
{shift.when.startLabel} {shift.role}
{shift.ended ? ' · Ended' : ''}
</span>
<span class="sr-only">
{'. '}
{action} for {shift.role} on {shift.when.dateLabel}, {shift.when.startLabel} to {shift.when.endLabel}{' '}
{shift.when.abbreviation}. {spotsSentence(shift)}
{shift.ended ? ' Ended.' : ''}
{shift.inProgress ? ' In progress.' : ''}
{shift.volunteers.length > 0 ? ` Volunteers: ${shift.volunteers.join(', ')}.` : ' No one signed up yet.'}
</span>
@@ -880,6 +886,7 @@ function CalendarShift(props: { config: AppConfig; shift: PublicShift }) {
{shift.when.sameDay ? null : <time dateTime={shift.endsAtUtc}>{shift.when.endDateLabel} </time>}
<time dateTime={shift.endsAtUtc}>{shift.when.endLabel}</time> {shift.when.abbreviation}
</span>
{shift.ended ? <span class="status">Ended</span> : null}
{shift.inProgress ? <span class="status">In progress</span> : null}
<Spots shift={shift} />
<span class="cal-names">{shift.volunteers.length > 0 ? shift.volunteers.join(', ') : 'No one signed up yet.'}</span>
+5 -3
View File
@@ -1,7 +1,7 @@
import { Temporal } from '@js-temporal/polyfill';
import type Database from 'better-sqlite3';
import { isWithinSignupWindow } from './signup-window.js';
import { formatInstantInZone, todayInZone } from './time.js';
import { formatInstantInZone, localToUtc, todayInZone } from './time.js';
/** Weekday 0 is Sunday, matching the zoned clock. The public sign-up cards use Wednesday. */
export const WEDNESDAY = 3;
@@ -110,15 +110,17 @@ export function getPublishedEvent(db: Database.Database, slug: string, now: stri
}
| undefined;
if (!event || event.published !== 1) return null;
// A shift that already ended stays through the rest of its local day, then leaves at midnight.
const todayStart = localToUtc(todayInZone(event.tz, Temporal.Instant.from(now)), '00:00', event.tz);
const rows = db
.prepare(
`SELECT ${SHIFT_COLUMNS}
${SHIFT_FROM}
WHERE e.id = ? AND s.cancelled = 0 AND s.ends_at_utc > ?
WHERE e.id = ? AND s.cancelled = 0 AND (s.ends_at_utc > ? OR s.starts_at_utc >= ?)
GROUP BY s.id
ORDER BY s.starts_at_utc, s.role, s.id`,
)
.all(event.id, now) as ShiftRow[];
.all(event.id, now, todayStart) as ShiftRow[];
const names = volunteerNamesByShift(db, rows.map((row) => row.id));
return {
id: event.id,
+37 -4
View File
@@ -48,7 +48,8 @@ describe('public pages', () => {
expect(html).toContain('class="day-card"');
expect(html).toContain('class="shift-pane"');
expect(html.match(/class="day-card"/g)).toHaveLength(2);
expect(html.match(/class="shift-pane"/g)).toHaveLength(3);
expect(html.match(/<section class="shift-pane/g)).toHaveLength(4);
expect(html.match(/class="shift-pane is-ended"/g)).toHaveLength(1);
expect(html).not.toContain('shift-calendar');
expect(html).not.toContain('Open Sorting');
expect(html).not.toContain('Full Intake');
@@ -80,7 +81,8 @@ describe('public pages', () => {
expect(footer).not.toContain('Privacy');
expect(footer).not.toContain('Coordinator');
expect(html).not.toContain('Cancelled Distribution');
expect(html).not.toContain('Past Setup');
expect(html).toContain('Past Setup');
expect(html).not.toContain(`href="/s/${ids.past}"`);
expect(html).not.toContain('Hidden draft');
expect(html).not.toContain('Secret Person');
expect(html).not.toContain('secret.person@example.invalid');
@@ -126,6 +128,10 @@ describe('public pages', () => {
expect(calendar).toContain('1/3 spots filled');
expect(calendar).toContain('1/1 spots filled');
expect(calendar).toContain('class="cal-line"');
expect(calendar).toContain('Past Setup');
expect(calendar).toContain('class="cal-shift is-ended"');
expect(calendar).toContain('· Ended');
expect(calendar).toContain(`href="/s/${ids.past}"`);
expect(calendar).toContain('class="cal-hold"');
expect(calendar).toContain('class="cal-detail"');
expect(calendar).toContain('>Sun</span>');
@@ -460,6 +466,33 @@ describe('public pages', () => {
expect(openPane).toContain('data-signup=""');
});
it('keeps a finished shift on today and drops that day at midnight', async () => {
const { app, db } = await buildApp();
const event = db.prepare(`SELECT id AS id FROM events WHERE slug = 'weekly-pantry'`).get() as { id: number };
insertShift(db, event.id, 'Yesterday Setup', '2026-10-13', '09:00', '12:00', 2, 0);
const html = await (await app.request('/')).text();
expect(html).not.toContain('Yesterday Setup');
const start = html.indexOf('Past Setup');
const pane = html.slice(html.lastIndexOf('<section class="shift-pane is-ended"', start), html.indexOf('</section>', start));
expect(pane).toContain('>Ended</span>');
expect(pane).toContain('9:00 AM');
expect(pane).not.toContain('href=');
expect(pane).not.toContain('data-signup');
expect(pane).not.toContain('Sign up');
const todayCard = html.slice(html.indexOf('aria-current="date"'), html.indexOf('October 21'));
expect(todayCard).toContain('Past Setup');
expect(todayCard).toContain('Live Greeting');
expect(todayCard).toContain('is-ended');
const { app: nextDay } = await buildApp({ now: '2026-10-15T05:00:00.000Z' });
const later = await (await nextDay.request('/')).text();
expect(later).not.toContain('Past Setup');
expect(later).not.toContain('Live Greeting');
expect(later).not.toContain('October 14');
expect(later).not.toContain('is-ended');
expect(later).toContain('Wednesday Sorting');
});
it('shows an empty list when nothing is upcoming', async () => {
const { app } = await buildApp({ empty: true });
const html = await (await app.request('/')).text();
@@ -467,7 +500,7 @@ describe('public pages', () => {
});
});
async function buildApp(options?: { basePath?: string; empty?: boolean }) {
async function buildApp(options?: { basePath?: string; empty?: boolean; now?: string }) {
const dataDir = path.join(mkdtempSync(path.join(tmpdir(), 'hope-volunteer-')), 'data');
dirs.push(path.dirname(dataDir));
const config = loadConfig(
@@ -479,7 +512,7 @@ async function buildApp(options?: { basePath?: string; empty?: boolean }) {
const db = await openAppDatabase(config);
databases.push(db);
const ids = options?.empty ? emptyIds() : seedCatalog(db);
const app = createApp(config, db, { now: NOW, publicDir: publicDirectory() });
const app = createApp(config, db, { now: options?.now ?? NOW, publicDir: publicDirectory() });
return { app, ids, db, close: () => db.close() };
}