Enforce three-volunteer slot cap#98
Open
zzawook wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enforces a hard cap of 3 volunteers per walk slot across the admin create/update flows and bulk-create pipeline, aligning UI constraints, server-side validation, and the bulk-create edge function with the same 1..3 rule (per Issue #96).
Changes:
- Tighten server-side validation in
admin-round-actionsto requiremaxVolunteersbe an integer in [1, 3], and default to 3 when omitted. - Enforce the same 1..3 validation and defaulting in the
bulk-create-walksSupabase edge function. - Update admin UI number inputs to cap max volunteers at 3 and adjust tests for the new validation/error message.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/lib/actions/admin-round-actions.test.ts | Updates/extends action tests to reflect the 1..3 max volunteers cap (including bulk-create validation). |
| supabase/functions/bulk-create-walks/index.ts | Adds a shared cap constant and validates/normalizes slot capacity before inserting rows. |
| lib/actions/admin-round-actions.ts | Enforces integer-only max volunteers validation and applies the 3-volunteer default via nullish coalescing. |
| app/(app)/admin/walks/walks-client.tsx | Updates admin inputs to cap max volunteers at 3 (with follow-up UX concerns noted in comments). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+354
to
355
| <input type="number" min="1" max={MAX_VOLUNTEERS_PER_SLOT} value={maxVol} onChange={e => setMaxVol(e.target.valueAsNumber)} | ||
| className="w-full px-4 py-3 border border-gray-300 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-green-500" /> |
Comment on lines
+580
to
581
| <input type="number" min="1" max={MAX_VOLUNTEERS_PER_SLOT} value={bulkRule.maxVolunteers} | ||
| onChange={e => setBulkRule(r => ({ ...r, maxVolunteers: e.target.valueAsNumber }))} |
Comment on lines
45
to
47
| const DAY_LABELS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] | ||
| const MAX_VOLUNTEERS_PER_SLOT = 3 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
npm test -- tests/lib/actions/admin-round-actions.test.tsnpm test -- tests/app/walk/page.test.tsx tests/app/walk/walk-detail-client.test.tsx tests/lib/actions/walk-actions.test.tsnpx eslint "lib/actions/admin-round-actions.ts" "app/(app)/admin/walks/walks-client.tsx" "supabase/functions/bulk-create-walks/index.ts" "tests/lib/actions/admin-round-actions.test.ts"npm testCloses #96