The sign-up dialog decides "See alternatives" with its own copy of the rule behind "Pick another slot."

Aperta
#803 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@dafeiyupola ci sta già lavorando.

Dal 6/11/2026.

  • #806 di @dafeiyupola — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
next.js, react, typescript
Ambito
frontend, testing

Direzione di ricerca

Read src/app/s/[slug]/capacity-message.ts and src/app/s/[slug]/commit-dialog.tsx, then inspect src/app/s/[slug]/capacity-message.test.ts and the server's SlotAlternative type in src/services/commitments.ts. Add a unit test for empty and missing alternatives, and confirm the shared rule drives both the suggestion and link; the issue also requires the listed lint, format, typecheck, knip, and test commands to pass. Pull request #806 is already open.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement good first issue pipeline:ready

What happens

When a slot fills while someone is signing up, the dialog decides twice whether to point them at other slots:

  • The words. capacityMessage in src/app/s/[slug]/capacity-message.ts adds "Pick another slot." only when the error is capacity_full, remaining and requested are numbers, remaining <= 0, and details.alternatives is a non-empty array.
  • The link. CommitDialog in src/app/s/[slug]/commit-dialog.tsx shows its "See alternatives" link with its own inline check: error.details?.alternatives?.length && error.details.remaining === 0. That check doesn't look at the error code or requested, and uses === 0 where the other uses <= 0.

The dialog's local ApiError type also describes the alternatives wrongly, as { id: string; title: string }[]. The server sends SlotAlternative, which is { id, ref, slotAt } (src/services/commitments.ts). Nothing reads title, so nothing renders wrong, but the type misleads the next person who does.

Today the two checks agree on every payload the server can send, because capacityFull always sends remaining and requested as numbers and clamps remaining at 0. They only disagree on payloads the server never sends. So this is drift waiting to happen, and nobody sees a difference now.

Fix, in outline

  • In capacity-message.ts, export one small function (for example offersAlternatives(error)) that holds the rule: capacity_full, a finite remaining <= 0, and a non-empty alternatives array. Use it in capacityMessage's join branch.
  • In commit-dialog.tsx, show "See alternatives" from that same function instead of the inline condition.
  • Fix the alternatives type in the dialog's ApiError to match SlotAlternative (or unknown[], since only its length is used).
  • Add a unit test in capacity-message.test.ts for the new function, including an empty alternatives array and a payload with no alternatives key (the change-quantity path sends none).

Watch for

  • No visible change. The hint and the link must still appear together, only when the slot is full and the server found at least one open slot. The wording and the link target (/s/<slug>) stay as they are.
  • Server side is done. #782 / #787 fixed which slots the server offers. Leave src/services/commitments.ts alone.
  • participantErrorCopy in participant-error.ts calls capacityMessage; it shouldn't need to change.

Done when

  • The "See alternatives" link and the "Pick another slot." suggestion are decided by one function.
  • The dialog's alternatives type matches what the server sends.
  • A unit test pins the function.
  • pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test pass.

Found by the pipeline's refactor scout in the participant pages (src/app/s/[slug]), at d1e9e14. Checked by an independent verify agent, which ran a scratch vitest of both conditions over every payload shape the server sends (19 of 19 agree) and over synthetic ones where they differ, and grepped every use of alternatives. https://claude.ai/code/session_016YZ9SSPmh7nC1k9RsPc5NE

Lingua principale
TypeScript
Stelle
19
Fork
4
Merge medio
19h 27m
PR unite (30g)
199

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di richshaw/OpenSignup

Tutte le issue di richshaw/OpenSignup

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.